Skip to content

Lint mapping table#480

Open
m-philipps wants to merge 12 commits into
mainfrom
lint_mapping_table
Open

Lint mapping table#480
m-philipps wants to merge 12 commits into
mainfrom
lint_mapping_table

Conversation

@m-philipps

Copy link
Copy Markdown
Collaborator
  • core: Update Fields/Annotations to match the PEtab v2 docs
  • add a lint check for the mapping table
  • Change the logic in petab.v2.lint.get_valid_parameters_for_parameter_table: add mapping table petabEntityId regardless of whether the corresponding modelEntityId would be valid (was L937->L1036)
  • add a test for mapping table linting

@m-philipps m-philipps requested a review from a team as a code owner May 13, 2026 20:13
Comment thread petab/v2/lint.py
str_p
for p in overrides
if isinstance(p, sp.Symbol)
and (str_p := str(p)) not in condition_targets

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not necessary since this is collected as a set and the condition_targets are removed further down.

@codecov-commenter

codecov-commenter commented May 13, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 75.00000% with 10 lines in your changes missing coverage. Please review.
✅ Project coverage is 75.28%. Comparing base (5a3b361) to head (ef86844).

Files with missing lines Patch % Lines
petab/v2/lint.py 73.68% 4 Missing and 6 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #480      +/-   ##
==========================================
- Coverage   75.29%   75.28%   -0.01%     
==========================================
  Files          62       62              
  Lines        6946     6976      +30     
  Branches     1229     1241      +12     
==========================================
+ Hits         5230     5252      +22     
- Misses       1245     1247       +2     
- Partials      471      477       +6     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@m-philipps m-philipps marked this pull request as draft May 14, 2026 07:04
@BSnelling BSnelling force-pushed the lint_mapping_table branch from 4df4635 to e1c3d3d Compare June 22, 2026 13:03
@BSnelling BSnelling marked this pull request as ready for review June 23, 2026 13:12
@BSnelling BSnelling requested a review from dweindl June 23, 2026 13:12

@dweindl dweindl left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks. Almost there, I think.

Comment thread petab/v2/core.py
#: Nominal value.
nominal_value: Annotated[
float | None, BeforeValidator(_convert_nan_to_none)
float | Literal["array"] | None, BeforeValidator(_convert_nan_to_none)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Belongs to #482.

Comment thread petab/v2/lint.py Outdated
Comment thread petab/v2/lint.py
Comment on lines +905 to +908
messages = []

# Mapping table is optional
if problem.mappings:

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
messages = []
# Mapping table is optional
if problem.mappings:
# Mapping table is optional
if problem.mappings:
return None
messages = []
...

Reduce indentation.

Comment thread petab/v2/lint.py
Comment on lines +913 to +914
petab_id = getattr(mapping, "petab_id", None)
model_id = getattr(mapping, "model_id", None)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In which situation is this preferable over just petab_id = mapping.petab_id?

Comment thread petab/v2/lint.py
Comment on lines +918 to +919
# Duplicates for annotation-only rows (identity mappings)
# are permitted.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

By duplicates, you mean petab_id == model_id, not multiple rows with the same petab_id or model_id, right?
It's not super clear from the specs whether the latter would be allowed or not.

Comment thread petab/v2/lint.py
old_petab_ids = (
{c.id for c in problem.conditions}
| {e.id for e in problem.experiments}
| {o.id for o in problem.observables}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also check for parameter table parameters?

Comment thread petab/v2/lint.py
for mapping in problem.mappings:
if mapping.model_id and mapping.model_id in parameter_ids.keys():
if mapping.petab_id not in invalid:
parameter_ids[mapping.petab_id] = None

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This might add all kinds of entities to the allowed-in-parameter-table dict. Species, observables, experiments, ...
For the currently supported model types (SBML, PySB), I don't think there can be a situation where the mapping table would contribute additional values allowed in the parameter table. For a model type where this could happen, we'd need some API for accessing parameters that are allowed in the parameter table if they had proper IDs. This doesn't exist yet. So either we need to add it now, or completely ignore the mapping table in this function. (The same holds for get_required_parameters_for_parameter_table below.)

Comment thread petab/v2/lint.py
# Start with mapping table petab ids
parameter_ids = {m.petab_id for m in problem.mappings}

# Add parameters from measurement table, unless they are fixed parameters

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With the changes below, this is no longer true.

@BSnelling BSnelling force-pushed the lint_mapping_table branch from ef86844 to d903f22 Compare June 24, 2026 12:25
Co-authored-by: Daniel Weindl <dweindl@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants