-
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
New validation API #288
New validation API #288
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## develop #288 +/- ##
===========================================
- Coverage 74.37% 72.92% -1.45%
===========================================
Files 70 72 +2
Lines 4460 4717 +257
Branches 953 1012 +59
===========================================
+ Hits 3317 3440 +123
- Misses 872 983 +111
- Partials 271 294 +23 ☔ View full report in Codecov by Sentry. |
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 great 👍
import pandas as pd | ||
|
||
from petab.C import NOISE_PARAMETERS, OBSERVABLE_PARAMETERS | ||
from petab.v1 import ( |
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.
Any opinion whether this should import from petab
instead of petab.v1
, so it's designed to fail if we're still using v1
linters by the time we release v2
? Or do we expect that we continue to use v1
linters in v2
where relevant?
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.
So far, my approach was reusing what is reusable, and once something changes, we add our own implementation in .v2. So, yes, I would keep the import from v1.
if map_to in model_to_petab_mapping: | ||
model_to_petab_mapping[map_to].append(map_from) |
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.
Why would multiple model IDs map to a single PEtab ID? Is it e.g. to observe the sum of all species regardless of isotope state in rule-based modeling? Then I would have more questions.. but irrelevant here.
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.
Iirc, the only reason is that so far, it's not explicitly forbidden.
class CheckVisualizationTable(ValidationTask): | ||
"""A task to validate the visualization table of a PEtab problem.""" | ||
|
||
def run(self, problem: Problem) -> ValidationIssue | None: | ||
if problem.visualization_df is None: | ||
return | ||
|
||
from petab.visualize.lint import validate_visualization_df | ||
|
||
if validate_visualization_df(problem): | ||
return ValidationIssue( | ||
level=ValidationIssueSeverity.ERROR, | ||
message="Visualization table is invalid.", | ||
) |
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.
For this single-error cases, there could already be some SingleValidationTask
class like we discussed, e.g.
class CheckVisualizationTable(ValidationTask): | |
"""A task to validate the visualization table of a PEtab problem.""" | |
def run(self, problem: Problem) -> ValidationIssue | None: | |
if problem.visualization_df is None: | |
return | |
from petab.visualize.lint import validate_visualization_df | |
if validate_visualization_df(problem): | |
return ValidationIssue( | |
level=ValidationIssueSeverity.ERROR, | |
message="Visualization table is invalid.", | |
) | |
class CheckVisualizationTable(SingleValidationTask): | |
"""A task to validate the visualization table of a PEtab problem.""" | |
level = ValidationIssueSeverity.ERROR | |
message = "Visualization table is invalid." | |
def run(self, problem: Problem) -> ValidationIssue | None: | |
if problem.visualization_df is None: | |
return | |
from petab.visualize.lint import validate_visualization_df | |
return (not?) validate_visualization_df(problem) | |
or | |
return self.handle(validation_visualization_df(problem)) |
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 am not sure this will be more intuitive. People will always wonder whether true
indicates passed or failed. Where the message is context-specific, this wouldn't really save anything. Will leave as is for now.
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.
Ah, I intended self.handle
to return ValidationIssue
or None
like done elsewhere in this PR
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.
Where the message is context-specific
Are you saying, an error message for SingleValidationTasks
might be context-specific? Doesn't that contradict the idea of a SingleValidationTask
?
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 meant that instead of There are log-scaled parameters with negative bounds.
, we want to say There are log-scaled parameters with negative bounds: parameter1, parameter42.
, so one would have to modify self.message again somewhere, and wouldn't really gain much.
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 see, but not if self.handle
also accepts an optional level/message. Anyway, not important
Co-authored-by: Dilan Pathirana <[email protected]>
For petab.v2, refactor the current validation setup to
Also:
petablint
work with both v1 and v2 problems.