Remove cyclic dependency#656
Open
marcpaterno wants to merge 18 commits into
Open
Conversation
Regenerate conda-lock files for Python 3.12, 3.13, and 3.14 with updated dependency versions.
…data Expand exception handling in SACC file loading operations to catch both OSError and ValueError. The sacc library can raise ValueError for invalid file formats or corrupted data, so this ensures those errors are properly handled during format detection and file loading attempts. This is needed to support sacc v2.2
…ng SACC data" This reverts commit e33299e. SACC 2.2 can no longer read compressed files, and that needs to be fixed before we can start supporting the new version.
This is needed because SACC 2.2 no longer transparently handles compressed files. I have filed an issue in SACC and will follow up with a PR there to implement the needed support.
Regenerate conda-lock files for Python 3.12, 3.13, and 3.14 with updated dependency versions.
Move load_sacc_data and ensure_path from the private module firecrown.likelihood.factories._sacc_utils into firecrown.utils (via _sacc_ops). The old module is kept as a backward-compatible re-export shim with a deprecation notice. Replace the manual try-HDF5/try-FITS fallback in load_sacc_data and Transform.detect_format with a call to sacc.utils.detect_sacc_file_type, delegating format detection to SACC itself.
Remove a duplicate sacc.utils.detect_sacc_file_type import in _transform.py. In _sacc_utils.py, import ensure_path and load_sacc_data directly from firecrown.utils._sacc_ops instead of the firecrown.utils package, and declare them explicitly in __all__ for re-export.
Update conda-lock.yml files to synchronize dependency versions and reformat YAML indentation for consistency. - py3.12: updated package hashes and dependencies - py3.13: updated package hashes and dependencies - py3.14: updated package hashes and dependencies
Move core likelihood base classes from _base.py to a new likelihood_base.py at the package root. This breaks a cyclic dependency by decoupling the base classes from the likelihood subpackage, allowing cleaner imports throughout the codebase. All imports across the package have been updated to reference the new module location.
This organization follows the rules applied by ruff, i.e.
1. standard library imports
2. third-parth imports
3. project imports
4. relative imports
Within each group, imports are in alphabetical order.
modified: firecrown/fctools/link_checker.py
Change imports of ConstGaussian and TwoPointFactory to use private modules directly, which avoids circular dependency issues while maintaining the same functionality.
Merge branch 'master' into remove-cyclic-dependency
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #656 +/- ##
=======================================
Coverage 100.0% 100.0%
=======================================
Files 146 147 +1
Lines 8715 8697 -18
Branches 1038 1038
=======================================
- Hits 8715 8697 -18
🚀 New features to boost your workflow:
|
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.
Description
This PR restructures the likelihood package architecture to break a circular dependency between modules. The key changes are:
New file:
firecrown/likelihood_base.py- Core likelihood base classes (Likelihood,Statistic,TrivialStatistic,ConstGaussian,ConstGaussianPM,StudentT,TwoPoint) have been moved from_base.pyto the package root. This decouples the base classes from the likelihood subpackage.Updated imports: All modules across the codebase now import base classes from
firecrown.likelihood_baseinstead offirecrown.likelihood._base.Private module re-exports: The
firecrown.likelihood._basemodule now re-exports fromfirecrown.likelihood_basewith deprecation notices to maintain backward compatibility.SACC utility refactoring: SACC-related helper functions (
load_sacc_data,ensure_path) were moved fromfirecrown.likelihood.factories._sacc_utilstofirecrown.utils._sacc_ops, with the old module kept as a backward-compatible shim.Import path updates: All internal imports were updated to reference the new module locations. Test files were updated to use the new import paths.
Type of change
Dependencies
sacc >= 2.4- Required forsacc.utils.detect_sacc_file_typeused in SACC file format detection.Testing
Checklist
The following checklist will make sure that you are following the code style and
guidelines of the project as described in the
contributing page.
make pre-commitand fixed any issues