[AUTO-MERGE] Pass a deepcopy of config to verbs and Hyrax methods#757
[AUTO-MERGE] Pass a deepcopy of config to verbs and Hyrax methods#757
Conversation
…that take a config as input. Added unit tests to check for config leakage and prevent regressions.
|
Note, a larger change could involve cleaning up the config stuff throughout the various verbs. There is inconsistency about how the input configs are handled. In a later PR it might be nice to consolidate on one approach. |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #757 +/- ##
==========================================
- Coverage 64.70% 64.69% -0.02%
==========================================
Files 61 61
Lines 5888 5894 +6
==========================================
+ Hits 3810 3813 +3
- Misses 2078 2081 +3 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Pull request overview
This PR aims to prevent Hyrax runtime config “leakage” by ensuring verbs (and verb-like Hyrax methods) receive an isolated deep-copied config, addressing the regression described in issue #703 where sequential train()/infer() cycles could reuse stale weights due to mutated config.
Changes:
- Pass
deepcopy(self.config)into verb dispatch (Hyrax.__getattr__) and intodownload/prepare/rebuild_manifest/raw_data_dimensionscall paths. - Add regression tests ensuring sequential verb calls do not mutate
h.config. - Add a unit test demonstrating that
load_model_weights()mutations don’t affect the original config when a deepcopy is used.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
src/hyrax/hyrax.py |
Deep-copies self.config before dispatching to verbs and quasi-verbs to prevent mutation leaks into Hyrax.config. |
tests/hyrax/test_infer.py |
Adds a unit test asserting config isolation when load_model_weights() is called with a deep-copied config. |
tests/hyrax/test_config_isolation.py |
Adds regression tests to ensure train()/infer()/prepare() do not mutate the Hyrax instance’s config across calls. |
You can also share your feedback on Copilot code review. Take the survey.
Click here to view all benchmarks. |
Pass a deepcopy of the config to the various verbs and Hyrax methods that take a config as input. Added unit tests to check for config leakage and prevent regressions.
Change Description
Closes #703
This change will create a deep copy of the top level config before passing it to the verb (or quasi-verb that is called from a Hyrax method)
Perhaps we were trying to do this in the base Verb class with the
self.config = configline, but that was allowing config changes to leak back up to the top level where they weren't appropriate.This change allows user to pass in a config, and update the config interactively (i.e. in a notebook) but when a verb is called i.e.
h.infer(), the updates to the config that the verb makes will not be seen by subsequent verb calls.Issue #703 describes the scenario where this was first noticed.