fix: defer siac._rust and pyhdf imports to avoid import-time failures#37
Draft
Copilot wants to merge 3 commits intofeat/refactorfrom
Draft
fix: defer siac._rust and pyhdf imports to avoid import-time failures#37Copilot wants to merge 3 commits intofeat/refactorfrom
Copilot wants to merge 3 commits intofeat/refactorfrom
Conversation
…ures - Make pyhdf import lazy in earthdata_common.py (moved to read_hdf4_dataset function) - Make siac._rust imports lazy in brdf/kernels.py, brdf_whittaker.py, rt/emulator/two_nn.py, and solver/multigrid.py - Fix Sentinel2Preprocessor.sensor_config to fall back to built-in nominal configs when SRF download fails (network unavailable or offline environment) - Import SENTINEL2B_CONFIG and SENTINEL2C_CONFIG in satellite/sentinel2.py for proper fallback support Result: 412 tests passing → 580 tests passing; 11 failures → 22 failures (all remaining failures require actual siac._rust Rust extension at runtime) Co-authored-by: MarcYin <19539641+MarcYin@users.noreply.github.com>
- Add BLE001 noqa comment on bare Exception in sentinel2.py to document intentional broad catch - Change return type of _init_rust_nn to Any with explanatory docstring - Fix spelling: 'initialised' -> 'initialized' in kernels.py - Use Any type annotation for _rust_kernels attribute in BRDFKernels Co-authored-by: MarcYin <19539641+MarcYin@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Review codebase and implement fixes with passing tests
fix: defer siac._rust and pyhdf imports to avoid import-time failures
Mar 7, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Several optional/compiled dependencies were imported at module level, causing cascading import failures when
pyhdfwasn't installed or the Rust extension (siac._rust) hadn't been compiled — breaking 22 test collection sites and masking ~168 tests.Changes
earthdata_common.py— Movefrom pyhdf.SD import SD, SDCinsideread_hdf4_dataset(). HDF4 reading is an optional, infrequent path; it should not gate the entire package import.brdf/kernels.py,brdf_whittaker.py,rt/emulator/two_nn.py,solver/multigrid.py— Defer allfrom siac._rust import …calls to the point of first use (inside methods/functions). The Rust extension is a performance accelerator; classes that wrap it can now be instantiated and passed around without requiring a compiled extension, failing only when the accelerated code path is actually invoked.satellite/sentinel2.py—Sentinel2Preprocessor.sensor_confignow catches failures fromload_sensor_config_from_srf(network unavailable, no cache) and falls back to the built-in nominalSENTINEL2A/B/C_CONFIG. Adds missing imports forSENTINEL2B_CONFIGandSENTINEL2C_CONFIGto support all three platforms.Impact
siac._rust)siac._rustat runtime — correct)Warning
Firewall rules blocked me from connecting to one or more addresses (expand for details)
I tried to connect to the following addresses, but was blocked by firewall rules:
gws-access.jasmin.ac.uk/home/REDACTED/.local/bin/pytest pytest tests/unit/ --no-header -q --no-cov --ignore=tests/unit/test_solver.py python/siac/core/__init__.py stup/toolchains/stable-x86_64-REDACTED-linux-gnu/bin/rustc p -E " [0-9]{4,}bash _ d/mask.py stup/toolchains/stable-x86_64-unorigin --no�� --noprofile sh /opt/pipx_bin/uname " _ mulator/two_nn.p--noprofile uname(dns block)/home/REDACTED/.local/bin/pytest pytest tests/unit/ --no-header -q --no-cov --ignore=tests/unit/test_solver.py python/siac/srf/sources/landsat.py e python/siac/srf/lscpu python/siac/srf/--parse=core python/siac/srf/__init__.py uname -rs python/siac/srf/loaders.py python/siac/srf/repository.py bash p -E " [0-9]{4,}git .py rgo/bin/sh bash(dns block)sentiwiki.copernicus.eu/home/REDACTED/.local/bin/pytest pytest tests/ --no-header -q --no-cov --ignore=tests/integration --ignore=tests/benchmarks --ignore=tests/unit/test_brdf_monthly_composite.py --ignore=tests/unit/test_brdf_monthly_database.py --ignore=tests/unit/test_brdf_whittaker.py --ignore=tests/unit/test_coverage_lifts_batch1.py --ignore=tests/unit/test_coverage_lifts_batch2_earthaccess.py --ignore=tests/unit/test_coverage_lifts_batch3_emulator_registry.py --ignore=tests/unit/test_coverage_lifts_batch4_zip_store.py --ignore=tests/unit/test_coverage_lifts_batch5_assembler_prior.py --ignore=tests/unit/test_coverage_lifts_batch7_cams_zip.py --ignore=tests/unit/test_coverage_lut_backend.py --ignore=tests/unit/test_coverage_misc_modules.py --ignore=tests/unit/test_earthaccess_providers.py --ignore=tests/unit/test_earthdata_common.py(dns block)/usr/bin/python python -m pytest tests/unit/test_coverage_sentinel2_extra.py -v --no-cov rs/surface/spectral_mapping.py /home/REDACTED/work/_temp/ghcca-node/node/bin/grep "mcp-server-playbash(dns block)/usr/bin/python python -m pytest tests/unit/test_coverage_sentinel2_extra.py::TestSentinel2Internals::test_resolve_paths_variants tests/unit/test_package_exports.py -v --no-cov --tb=long " --global y grep -l print( ut/constants.py /home/REDACTED/.local/bin/grep get --local y _.py(dns block)If you need me to access, download, or install something from one of these locations, you can either:
Original prompt
💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.