Skip to content

Lint mapping table#480

Merged
BSnelling merged 16 commits into
mainfrom
lint_mapping_table
Jun 25, 2026
Merged

Lint mapping table#480
BSnelling merged 16 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 80.55556% with 7 lines in your changes missing coverage. Please review.
✅ Project coverage is 75.41%. Comparing base (3363e85) to head (72d7a29).

Files with missing lines Patch % Lines
petab/v2/lint.py 79.41% 3 Missing and 4 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #480      +/-   ##
==========================================
+ Coverage   75.29%   75.41%   +0.11%     
==========================================
  Files          62       62              
  Lines        6946     6975      +29     
  Branches     1229     1240      +11     
==========================================
+ Hits         5230     5260      +30     
+ Misses       1245     1239       -6     
- Partials      471      476       +5     

☔ 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 Outdated
Comment thread petab/v2/lint.py Outdated
Comment thread petab/v2/lint.py Outdated
Comment thread petab/v2/lint.py Outdated
Comment thread petab/v2/lint.py Outdated
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.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Yes, I've reworded to comment to make this clearer.

Comment thread petab/v2/lint.py Outdated
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.)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

a situation where the mapping table would contribute additional values allowed in the parameter table

SciML problems have this use case don't they? For example, we'd define net_ps as a PEtab id for the network parameters net1.parameters in the mapping table, and then also have net_ps specified in the parameters table with its bounds etc.

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.

Quite possible, I am not sufficiently familiar with petab-sciml. In that case, I would ignore it for now, revert the changes in get_valid_parameters_for_parameter_table, and address it after this PR and #482. It will probably require a bit more thought and changes.

@dweindl dweindl Jun 25, 2026

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.

The same for get_required_parameters_for_parameter_table. As far as I can tell, with the currently (pre-sciml) supported models, the mapping table won't affect what's allowed or required in the parameter table.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I have removed all the mapping table related changes from both functions and updated the unit test.

Comment thread petab/v2/lint.py Outdated
@BSnelling BSnelling force-pushed the lint_mapping_table branch from ef86844 to d903f22 Compare June 24, 2026 12:25
@BSnelling BSnelling requested a review from dweindl June 25, 2026 14:25

@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, looks good to me, except for that duplication!

Comment thread petab/v2/lint.py Outdated
Co-authored-by: Daniel Weindl <dweindl@users.noreply.github.com>

@dilpath dilpath 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 a lot. Looks good!

Comment thread petab/v2/lint.py Outdated
Comment on lines +559 to +560
This also ensures that the mapping table petab ids
are used in the PEtab problem."""

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.

Where does it do this? There is no ValidationError with a message like "Unused mapping table PEtab IDs: ...."

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Good point, it doesn't do this yet as I'm planning to handle mapping/parameter table interaction in the sciml branch. I've removed from the docstring.

@BSnelling BSnelling enabled auto-merge (squash) June 25, 2026 16:57
@BSnelling BSnelling merged commit 8a1909f into main Jun 25, 2026
13 checks passed
@BSnelling BSnelling deleted the lint_mapping_table branch June 25, 2026 16:58
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