Skip to content

Commit

Permalink
Use v2 linter for v2 problems (#71)
Browse files Browse the repository at this point in the history
So far only on libpetab-python/develop

Required for #14
  • Loading branch information
dweindl authored Jun 29, 2024
1 parent 42e7d4a commit e2e1528
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 6 deletions.
2 changes: 1 addition & 1 deletion .ci_pip_reqs.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
pytest
flake8
https://github.com/petab-dev/libpetab-python/archive/develop.zip
git+https://github.com/PEtab-dev/libpetab-python@develop
sympy>=1.12.1
1 change: 1 addition & 0 deletions .github/workflows/ci_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ jobs:
run: |
python -m pip install --upgrade pip wheel
pip install -e .
pip uninstall -y petab
pip install -r .ci_pip_reqs.txt
- name: Run tests
run: |
Expand Down
20 changes: 15 additions & 5 deletions petabtests/file.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
import petab
import yaml
from petab.C import * # noqa: F403

from petab.v1.lint import lint_problem as lint_problem_v1
from petab.v2.lint import lint_problem as lint_problem_v2
from .C import * # noqa: F403

__all__ = [
Expand Down Expand Up @@ -180,13 +181,22 @@ def write_problem(

# write yaml
yaml_file = problem_yaml_name(test_id)
with open(os.path.join(dir_, yaml_file), 'w') as outfile:
yaml_path = os.path.join(dir_, yaml_file)
with open(yaml_path, 'w') as outfile:
yaml.dump(config, outfile, default_flow_style=False)

# validate written PEtab files
problem = petab.Problem.from_yaml(os.path.join(dir_, yaml_file))
if petab.lint_problem(problem):
raise RuntimeError("Invalid PEtab problem, see messages above.")
if format_version == 1:
# PEtab v1
problem = petab.Problem.from_yaml(yaml_path)
if lint_problem_v1(problem):
raise RuntimeError("Invalid PEtab problem, see messages above.")
else:
# v2
validation_result = lint_problem_v2(yaml_path)
if validation_result:
print(validation_result)
raise RuntimeError("Invalid PEtab problem, see messages above.")


def write_solution(
Expand Down

0 comments on commit e2e1528

Please sign in to comment.