-
Notifications
You must be signed in to change notification settings - Fork 9
Cosmodesi observable load reworked #136
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: cosmodesi
Are you sure you want to change the base?
Conversation
…rameters, loading from paths as an option and handling legacy paths. Also solves some typing syntax
|
Also, this might have conflicts with #133 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR refactors the Observable class initialization to provide more flexibility in loading datasets and models. The refactoring splits the monolithic __init__ method into separate concerns and allows users to either provide pre-loaded data/models or load them from file paths.
Changes:
- Refactored
Observable.__init__to acceptdatasetandmodelas optional direct parameters, withpathsas a fallback for loading from files - Extracted dataset and model loading logic into separate class methods (
load_dataset_from_filesandload_model) - Added placeholder
load()andsave()methods for future implementation - Updated
__repr__to provide detailed object inspection
Reviewed changes
Copilot reviewed 1 out of 2 changed files in this pull request and generated 11 comments.
| File | Description |
|---|---|
| acm/observables/base.py | Refactored Observable class to support both direct parameter passing and file-based loading, extracted loading logic into separate class methods, and improved object representation |
| .gitignore | Added .vscode/ directory to ignored files |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| if model is None: | ||
| try: | ||
| if checkpoint_fn is not None: | ||
| self.logger.warning("The 'checkpoint_fn' parameter is deprecated. Please use 'paths['model_dir']/stat_name.ckpt' instead.") | ||
| checkpoint_fn = Path(checkpoint_fn) | ||
| else: | ||
| checkpoint_fn = Path(paths['model_dir']) / f'{stat_name}.ckpt' | ||
| model = self.load_model(checkpoint_fn) | ||
| except Exception as e: | ||
| self.logger.warning(f"Could not load model from checkpoint: {e}") | ||
|
|
||
| self.model = model |
Copilot
AI
Jan 21, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When model loading fails, model remains None and is assigned to self.model. While this may be intentional (as indicated by the warning message), this creates an inconsistent state where self.model exists but is None. This could lead to AttributeErrors in code that expects self.model to be defined when it exists. Consider either not setting self.model at all when loading fails, or documenting this behavior more clearly in the class docstring.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@epaillas what do you think would be the best approach here? In both case it will crash, but not defining the model seems more rigorous in term of error handling...
I split the
Observable.__init__method in several functions, which now allow to either load the datasets and models trough thepathsdict, or trough thedataset&modelarguments.I removed the checkpoint_fn attribute, which now has been passed as a legacy argument to
__init__Note
I still need to propagate this change to the EMC classes, which all have their checkpoint hardcoded (this should be changed along with the file structure for the next pipeline runs)
I added(Redundant with compressed files & model checkpoint, I'm giving up on this idea)load()andsave()methods to allow loading and saving for file, but those are not implemented yet