Skip to content
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

feat: check all SED-ML XPath targets and warn appropriately #102

Merged
merged 12 commits into from
Mar 28, 2022

Conversation

luciansmith
Copy link
Contributor

@luciansmith luciansmith commented Feb 23, 2022

This was part of the earlier change but somehow got dropped.

EDIT: fundamental changes due to comments; see below.

This was part of the earlier change but somehow got dropped.
@jonrkarr
Copy link
Member

I removed this because such attribute changes can also make changes that can break other XPaths. While this might not be the typical use pattern, this is possible. More nuanced analysis is needed to evaluate this.

@jonrkarr
Copy link
Member

Basically, every change should be considered a "structural" change. This is one of the insidious features of XPaths. For many reasons, I'd advocate L2 SED-ML use something else.

@luciansmith
Copy link
Contributor Author

OK, in that case I think we should validate the XPaths but put in warnings instead. Not validating the XPaths at all seems like a waste. (And again, I'm getting pages and pages of 'didn't check this xpath; didn't check the other xpath', which is not very helpful.)

@jonrkarr
Copy link
Member

The XPaths are still validated and a warning is generated

  • Adhere to valid XML XPath syntax
  • Namespaces in the XPath are defined

Here's the assumptions/insights that make this update work:
* A ComputeChange will never change the structure of a model.  Thus, no task change will invalidate any XPath.
* Similarly, has_structural_changes now additionally checks to see if any model attribute change is present.
* We need but a single warning that all valid XPaths could be made invalid by a rogue ModelChange.
* Conversely, if an XPath is *in*valid, it might too be made valid by the application of a ModelChange.

Overall:  All XPaths are validated, but if there are structural model changes present, all 'is there a target' validations are warnings, and we also add a single warning that 'valid' XPaths may be wrong anyway.
@luciansmith luciansmith changed the title Check datagen xpaths when no structural model changes. Check all xpath targets, and warn appropriately Feb 24, 2022
@jonrkarr
Copy link
Member

Could you add unit tests which illustrate the cases this impacts?

@jonrkarr jonrkarr marked this pull request as draft February 24, 2022 21:34
@jonrkarr
Copy link
Member

jonrkarr commented Feb 24, 2022

@luciansmith it looks like you're still working on this. I converted this to draft so I know not to merge this yet. When its ready, click the "Ready for review" button below.

@luciansmith
Copy link
Contributor Author

OK! Major update that fundamentally changes the goal of this pull request. See e72edd4 for details, but in general: given that attribute changes can make XPaths valid or invalid, we just acknowledge this everywhere, and validate targets anyway.

@luciansmith
Copy link
Contributor Author

Sure, adding tests is a good idea.

@jonrkarr
Copy link
Member

Because this can lead to the false identification of errors, such issues should be reported as warnings. An additional option (whose default value is OFF) could be added to report them as errors.

@luciansmith
Copy link
Contributor Author

Correct! XPath validation errors are only treated as errors if there are no model changes. See https://github.com/biosimulators/Biosimulators_utils/blob/check-datagens/biosimulators_utils/sedml/validation.py#L1659

@jonrkarr
Copy link
Member

That works. This should help close the remaining gap in the validation of the SED-ML files from BioModels.

@luciansmith
Copy link
Contributor Author

luciansmith commented Feb 25, 2022

I'm having a little trouble figuring out how best to fit the design of your unit test system. I have some SED-ML files that should each produce a different suite of errors and warnings, but I'm not sure how best to wrap them into your system. Should the SED-ML of each be created from scratch? Should I load just one and make changes to create the others internally? Should I just save all four and load them?

four_sedml_files.zip

The results should be:

No change, good xpath: no errors, no warnings
No change, bad xpath: error for bad xpath, no warnings
Change, good xpath: no errors, one general 'xpaths might be bad' warning.
Change, bad xpath: no errors, one 'xpaths might be bad' warning, and one 'the xpath is bad but might be fixed by change' warning.

I also feel like xpaths for elements other than data generators should be tested in the presence/absence of a model change, but figured the datagens could be first.

@jonrkarr
Copy link
Member

The SED-ML can either be generated in the code, or it could saved to the repository in tests/fixtures.

@jonrkarr
Copy link
Member

The new test cases can be added to tests/sedml/test_sedml_validation.py, or you could start a new file in the same directory.

@luciansmith
Copy link
Contributor Author

OK! I'll do that, then.

Several tests added that check XPath validation in various contexts in the presence and absence of a 'structural' model change.  To make things work, the model_etree had to be passed around a lot, and created earlier than it had been.  But everything else mostly worked out of the box.
@luciansmith luciansmith marked this pull request as ready for review February 25, 2022 22:55
@luciansmith luciansmith requested a review from jonrkarr February 25, 2022 22:55
@luciansmith
Copy link
Contributor Author

This should be good to go!

@jonrkarr jonrkarr changed the title Check all xpath targets, and warn appropriately feat: check all XPath targets and warn appropriately Mar 28, 2022
@jonrkarr jonrkarr changed the title feat: check all XPath targets and warn appropriately feat: check all SED-ML XPath targets and warn appropriately Mar 28, 2022
@sonarqubecloud
Copy link

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 8 Code Smells

No Coverage information No Coverage information
0.0% 0.0% Duplication

@codecov
Copy link

codecov bot commented Mar 28, 2022

Codecov Report

Merging #102 (6d0bd63) into dev (9dde3e9) will decrease coverage by 0.01%.
The diff coverage is 95.45%.

@@            Coverage Diff             @@
##              dev     #102      +/-   ##
==========================================
- Coverage   96.68%   96.66%   -0.02%     
==========================================
  Files          87       87              
  Lines        9294     9309      +15     
==========================================
+ Hits         8986     8999      +13     
- Misses        308      310       +2     
Flag Coverage Δ
unittests 96.66% <95.45%> (-0.02%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
biosimulators_utils/sedml/validation.py 99.57% <95.23%> (-0.21%) ⬇️
biosimulators_utils/_version.py 100.00% <100.00%> (ø)
biosimulators_utils/sedml/data_model.py 100.00% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 4afc7e8...6d0bd63. Read the comment docs.

@jonrkarr jonrkarr merged commit 76524bd into dev Mar 28, 2022
@jonrkarr jonrkarr deleted the check-datagens branch March 28, 2022 08:47
@jonrkarr
Copy link
Member

Will be released as 0.1.170 in a few minutes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants