File tree Expand file tree Collapse file tree 2 files changed +19
-13
lines changed
Expand file tree Collapse file tree 2 files changed +19
-13
lines changed Original file line number Diff line number Diff line change 1212
1313import petab .v1 as petab
1414from petab .v1 .C import FORMAT_VERSION
15- from petab .v2 . lint import lint_problem
15+ from petab .v1 . yaml import validate
1616from petab .versions import get_major_version
17- from petab .yaml import validate
1817
1918logger = logging .getLogger (__name__ )
2019
@@ -178,6 +177,8 @@ def main():
178177 ret = petab .lint .lint_problem (problem )
179178 sys .exit (ret )
180179 case 2 :
180+ from petab .v2 .lint import lint_problem
181+
181182 validation_issues = lint_problem (args .yaml_file_name )
182183 if validation_issues :
183184 validation_issues .log (logger = logger )
Original file line number Diff line number Diff line change 33
44from pathlib import Path
55
6+ import petab
67from petab .v1 import Problem as V1Problem
78from petab .v1 .C import FORMAT_VERSION
89from petab .v1 .yaml import load_yaml
9- from petab .v2 import Problem as V2Problem
1010
1111__all__ = [
1212 "get_major_version" ,
1313]
1414
1515
1616def get_major_version (
17- problem : str | dict | Path | V1Problem | V2Problem ,
17+ problem : str | dict | Path | V1Problem | petab . v2 . Problem ,
1818) -> int :
1919 """Get the major version number of the given problem."""
20- if isinstance (problem , V1Problem ):
21- return 1
22-
23- if isinstance (problem , V2Problem ):
24- return 2
20+ version = None
2521
2622 if isinstance (problem , str | Path ):
2723 yaml_config = load_yaml (problem )
2824 version = yaml_config .get (FORMAT_VERSION )
2925 elif isinstance (problem , dict ):
3026 version = problem .get (FORMAT_VERSION )
31- else :
32- raise ValueError (f"Unsupported argument type: { type (problem )} " )
3327
34- version = str (version )
35- return int (version .split ("." )[0 ])
28+ if version is not None :
29+ version = str (version )
30+ return int (version .split ("." )[0 ])
31+
32+ if isinstance (problem , V1Problem ):
33+ return 1
34+
35+ from . import v2
36+
37+ if isinstance (problem , v2 .Problem ):
38+ return 2
39+
40+ raise ValueError (f"Unsupported argument type: { type (problem )} " )
You can’t perform that action at this time.
0 commit comments