-
Notifications
You must be signed in to change notification settings - Fork 7
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
PEtab v1 to v2 converter #281
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## develop #281 +/- ##
===========================================
+ Coverage 72.92% 74.01% +1.08%
===========================================
Files 72 73 +1
Lines 4717 4798 +81
Branches 1012 1029 +17
===========================================
+ Hits 3440 3551 +111
+ Misses 983 953 -30
Partials 294 294 ☔ View full report in Codecov by Sentry. |
9613b58
to
face12f
Compare
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.
👍
petab/v2/petab1to2.py
Outdated
if str(yaml_config[petab.C.FORMAT_VERSION]) != "1": | ||
# TODO: Other valid version numbers? |
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.
Currently 1.0.0
is possible
https://github.com/search?q=repo%3APEtab-dev%2Flibpetab-python+1.0.0&type=code
if output_dir is None: | ||
# TODO requires petab.v2.Problem | ||
raise NotImplementedError("Not implemented yet.") | ||
elif isinstance(yaml_config, dict): | ||
raise ValueError("If output_dir is given, yaml_config must be a file.") | ||
|
||
if isinstance(yaml_config, Path | str): | ||
yaml_file = str(yaml_config) | ||
path_prefix = get_path_prefix(yaml_file) | ||
yaml_config = load_yaml(yaml_config) | ||
get_src_path = lambda filename: f"{path_prefix}/{filename}" # noqa: E731 | ||
else: | ||
yaml_file = None | ||
path_prefix = None | ||
get_src_path = lambda filename: filename # noqa: E731 | ||
|
||
get_dest_path = lambda filename: f"{output_dir}/{filename}" # noqa: E731 |
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.
Keeping file names the same when upgrading is nice, but this is more intuitive to me. Fine as is, if you think this is nicer for most users.
problem1 = petab.v1.Problem.get_problem(yaml_config, validate=True)
experiment_df, measurement_df = convert_measurement_df_1to2(problem1)
problem2 = petab.v2.Problem(
problem1.condition_df,
experiment_df,
measurement_df,
...,
)
problem2.validate(raise=True)
if output_dir:
# alternatively `to_files` if you want to keep file names consistent...
problem2.to_files_generic(output_dir)
return problem2
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.
The thing is, if you had multiple measurement files, condition files, ... then you most likely still want to have them as separate files in your v2 problem. That's not possible anymore once you read them into a v1 Problem, they will all get merged. And I don't want to rename all files afterwards.
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.
Makes sense! I have thought elsewhere that tracking a file ID for e.g. measurements, as an index subset, could improve things a bit. If you're not against this, I can open an issue for it.
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.
Also happy to add that to this PR, today or tomorrow.
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.
I'm generally open to tracking that information somewhere. To be discussed how that could look in details.
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.
Also happy to add that to this PR, today or tomorrow.
I'd rather have it done separately. (That doesn't preclude changing anything that was introduced here.)
Draft. Closes PEtab-dev#272.
5b3405a
to
9222a64
Compare
Co-authored-by: Dilan Pathirana <59329744+dilpath@users.noreply.github.com>
Converter for PEtab v1 problems to PEtab v2 problems.
Allows converting a set of PEtab v1 files to v2 files or creating a petab.v2.Problem from v1 yaml file.
To be extended/adapted as v2 matures.
Closes #272.