-
Notifications
You must be signed in to change notification settings - Fork 7
Update petab.v2 #361
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
Update petab.v2 #361
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## develop #361 +/- ##
===========================================
+ Coverage 74.44% 74.55% +0.10%
===========================================
Files 57 57
Lines 5987 6075 +88
Branches 1039 1057 +18
===========================================
+ Hits 4457 4529 +72
- Misses 1133 1141 +8
- Partials 397 405 +8 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
@dweindl Is this usable already? I want to implement the timecourses in my tools but would need the updated petab library for that. Is this the right branch and working. If not what is still missing here? |
I'd suggest to wait another week. The whole I am currently aligning things with PEtab-dev/PEtab#581 and switching from DataFrame based functions to pydantic-objects-based ones for |
Perfect. |
e6db0d1
to
3b8fc54
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.
Looks good so far!
@@ -43,6 +49,43 @@ | |||
] | |||
|
|||
|
|||
def _is_finite_or_neg_inf(v: float, info: ValidationInfo) -> float: |
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.
Move these methods to the lint module? I guess they might be used there too, or is all validation intended to take place in the constructor of these pydantic objects?
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.
That is still somewhat of an open question. I wouldn't want to duplicate the validation logic. However, the question is, which validations might have to be made optional at some point to work with future extensions. Probably too worry about that though.
So far, I would see everything that concerns the files and the presence of columns, as well as everything that cannot be validated inside a specific pydantic model to be in the lint module.
Another open question related to validation is whether it should still be possible to construct the pydantic objects from an invalid table.
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.
No strong opinion but I guess that could be useful for e.g. loading partial problems into Paul's PEtab GUI
petab/v2/core.py
Outdated
if isinstance(v, int) or isinstance(v, float) and v.is_integer(): | ||
if v == 0: | ||
return False | ||
if v == 1: | ||
return True | ||
|
||
if isinstance(v, str): | ||
if v == "0": | ||
return False | ||
if v == "1": | ||
return True |
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.
Sufficient? Could also add True
and False
to remove the above code too...
if isinstance(v, int) or isinstance(v, float) and v.is_integer(): | |
if v == 0: | |
return False | |
if v == 1: | |
return True | |
if isinstance(v, str): | |
if v == "0": | |
return False | |
if v == "1": | |
return True | |
if v in [0, 1, "0", "1"]: | |
return bool(int(v)) |
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 think that should work. But meanwhile PEtab-dev/PEtab#614 happened. Needs updating.
Extra whitespace is not allowed, except for math expressions, right?
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.
Extra whitespace is not allowed, except for math expressions, right?
Sounds fine to me. I don't see an issue either way, so whichever is more convenient
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.
Same here. To be discussed at https://github.com/PEtab-dev/PEtab/.
if problem.model.has_entity_with_id(x) | ||
} | ||
if disallowed_in_condition: | ||
is_or_are = "is" if len(disallowed_in_condition) == 1 else "are" |
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.
🤌
if problem_id == "Froehlich_CellSystems2018": | ||
# this is mostly about 6M sympifications in the condition table | ||
pytest.skip("Too slow. Re-enable once we are faster.") |
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.
Not sure but maybe caching helps, e.g. https://github.com/AMICI-dev/AMICI/pull/1672/files
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 had the feeling that caching is the problem here (inside sympy), but that needs further investigation.
Adapt petab.v2 to the updated specs draft.
Make the new pydantic objects the primary objects and generate the DataFrames only on demand.
Validation is still a bit rough. We'll need nicer error messages and pydantic settings are too lax for validating files.