Skip to content

Commit 6596099

Browse files
authored
Merge pull request #155 from biosimulators/combined_ids_for_multi_id_xpaths
Allow the return of combined IDs for multi-id xpaths.
2 parents 49e8a80 + fb037c3 commit 6596099

File tree

6 files changed

+748
-10
lines changed

6 files changed

+748
-10
lines changed

.github/workflows/ci.yml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,10 @@ jobs:
3838
fetch-depth: 1
3939

4040
- name: Install Java # for pyNeuroML
41-
uses: actions/setup-java@v2
41+
uses: actions/setup-java@v4
4242
with:
43-
distribution: 'adopt'
44-
java-version: '15'
43+
distribution: 'temurin'
44+
java-version: '21'
4545

4646
- name: Install Perl # for BioNetGen
4747
run: |
@@ -53,7 +53,7 @@ jobs:
5353
sudo apt-get install -y --no-install-recommends wget make gcc libx11-dev libc6-dev xppaut
5454
5555
- name: Install Singularity # to validate that the Docker image can be converted into a Singularity image
56-
uses: eWaterCycle/setup-singularity@v5
56+
uses: eWaterCycle/setup-singularity@v7
5757
with:
5858
singularity-version: 3.7.1
5959

@@ -67,15 +67,15 @@ jobs:
6767
run: poetry run python -m flake8
6868

6969
- name: Run the tests
70-
uses: GabrielBB/xvfb-action@v1
70+
uses: coactions/setup-xvfb@v1
7171
env:
7272
MPLBACKEND: PDF
7373
# BIOSIMULATORS_API_ENDPOINT: https://api.biosimulators.dev/ # uncomment to execute tests with the dev deployment
7474
with:
7575
run: poetry run python -m pytest tests/ --cov=./biosimulators_utils --cov-report=xml
7676

7777
- name: Upload the coverage report to Codecov
78-
uses: codecov/codecov-action@v2
78+
uses: codecov/codecov-action@v4
7979
with:
8080
token: ${{ secrets.CODECOV_TOKEN }}
8181
flags: unittests

biosimulators_utils/_version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
__version__ = '0.2.2'
1+
__version__ = '0.2.3'

biosimulators_utils/sedml/validation.py

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1715,14 +1715,16 @@ def validate_target(target, namespaces, context, language, model_id, model_etree
17151715
return errors, warnings
17161716

17171717

1718-
def validate_target_xpaths(targets, model_etree, attr='id'):
1718+
def validate_target_xpaths(targets, model_etree, attr='id', separator=None):
17191719
""" Validate that the target of each model change or variable matches one object in
1720-
an XML-encoded model and, optionally, return the value of one of its attributes
1720+
an XML-encoded model and, optionally, return the value of one of its attributes.
17211721
17221722
Args:
17231723
targets (:obj:`list` of :obj:`TargetGroupMixin`): model changes or variables
17241724
model_source (:obj:`lxml.etree._ElementTree`): element tree for the XML model document
17251725
attr (:obj:`str`, optional): attribute to get values of
1726+
separator (:obj:`str`, optional): string to use when combining attributes into a single id
1727+
(i.e. 'J0.n' from 'J0' and 'n'.) If None, don't combine and just use final id.
17261728
17271729
Returns:
17281730
:obj:`dict` of :obj:`str` to :obj:`str`: dictionary that maps each XPath to the
@@ -1736,6 +1738,17 @@ def validate_target_xpaths(targets, model_etree, attr='id'):
17361738
x_path, _, _ = x_path.rpartition('/@')
17371739
x_path_attrs[target.target] = validate_xpaths_ref_to_unique_objects(
17381740
model_etree, [x_path], target.target_namespaces, attr=attr)[x_path]
1741+
if separator is None:
1742+
return x_path_attrs
1743+
for xpath in x_path_attrs:
1744+
xpath_list = xpath.split("@" + attr + "=")
1745+
if len(xpath_list) < 3:
1746+
continue
1747+
combined_id = ""
1748+
for i in range(1, len(xpath_list)-1):
1749+
combined_id = combined_id + xpath_list[i].split(']')[0][1:-1] + separator
1750+
x_path_attrs[xpath] = combined_id + x_path_attrs[xpath]
1751+
17391752
return x_path_attrs
17401753

17411754

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[tool.poetry]
22
name = "biosimulators-utils"
3-
version = "0.2.2"
3+
version = "0.2.3"
44
description = "description"
55
license = "MIT"
66
authors = ["Center for Reproducible Biomedical Modeling <[email protected]>"]

0 commit comments

Comments
 (0)