-
Notifications
You must be signed in to change notification settings - Fork 18
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
♻️ Refactor Result and Scheme loading to to use 'file' fields #903
Conversation
Codecov Report
@@ Coverage Diff @@
## main #903 +/- ##
=======================================
+ Coverage 84.8% 85.1% +0.3%
=======================================
Files 81 85 +4
Lines 4610 4761 +151
Branches 851 880 +29
=======================================
+ Hits 3910 4053 +143
- Misses 558 561 +3
- Partials 142 147 +5
Continue to review full report at Codecov.
|
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.
Impressive piece of refactoring ♻️. LGTM.
65586ac
to
e5ccd12
Compare
If the field isn't an instance of the targetClass it will try to load the class instance from file. This also allows classes like scheme to be initialized with file paths directly. When dataclasses with file loadable fileds are serialized the objects will be replaced with their source path. In addition projectIO load and save functions will set the ``source_path`` attribute of the class instances.
Also ensure that paths are passed as posix formatted path
and file loadable wrapper class 'DatasetMapping'. This also allows to load all datasets need for a opimization directly from file path passing a dict with the keys used for the dataset names and the paths as values.
This way it will update when the source_path of the dataset is updated e.g. by calling 'save_dataset'.
Also, removed file_representation_field compleatly.
and added support for Sequence like FileLoadable classes
instead of pathlib.Pathrelative_to This prevents crashes as long at the files are on the same drive.
e5ccd12
to
ecdb930
Compare
Sourcery Code Quality Report❌ Merging this PR will decrease code quality in the affected files by 0.73%.
Here are some functions in these files that still need a tune-up:
Legend and ExplanationThe emojis denote the absolute quality of the code:
The 👍 and 👎 indicate whether the quality has improved or gotten worse with this pull request. Please see our documentation here for details on how these metrics are calculated. We are actively working on this report - lots more documentation and extra metrics to come! Help us improve this quality report! |
Kudos, SonarCloud Quality Gate passed!
|
Benchmark is done. Checkout the benchmark result page. Benchmark diff v0.5.0rc1 vs. mainParametrized benchmark signatures: BenchmarkOptimize.time_optimize(index_dependent, grouped, weight)
Benchmark diff main vs. PRParametrized benchmark signatures: BenchmarkOptimize.time_optimize(index_dependent, grouped, weight)
|
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.
Changes (ecdb930) after last review (Changed implementation of relative_posix_path to use os.path.relpath ), reviewed as as ok.
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.
Lgtm
This PR removes the file representation fields from the augmented dataclasses completely and thus simplifies the API
from:
pyglotaran/glotaran/builtin/io/yml/test/test_save_scheme.py
Lines 38 to 45 in ded0711
to
Additional side effects and improvements:
glotaran.typing
moduleFileLoadable
classes (Model
,ParameterGroup
,Scheme
,Result
,DatasetMapping
) know their own file originload_datasets
which can load datasets in bulk, which then can be consumed by SchemeChange summary
Checklist
Closes issues
closes #858