|
11 | 11 |
|
12 | 12 | from .C import * # noqa: F403 |
13 | 13 |
|
14 | | -SCHEMA = os.path.join(os.path.abspath(os.path.dirname(__file__)), |
15 | | - "petab_schema.yaml") |
| 14 | +# directory with PEtab yaml schema files |
| 15 | +SCHEMA_DIR = Path(__file__).parent / "schemas" |
| 16 | +# map of version number to validation schema |
| 17 | +SCHEMAS = { |
| 18 | + '1': SCHEMA_DIR / "petab_schema.v1.0.0.yaml", |
| 19 | + '1.0.0': SCHEMA_DIR / "petab_schema.v1.0.0.yaml", |
| 20 | +} |
| 21 | + |
16 | 22 | __all__ = ['validate', 'validate_yaml_syntax', 'validate_yaml_semantics', |
17 | 23 | 'load_yaml', 'is_composite_problem', |
18 | 24 | 'assert_single_condition_and_sbml_file', 'write_yaml', |
@@ -52,13 +58,17 @@ def validate_yaml_syntax( |
52 | 58 | Raises: |
53 | 59 | see jsonschema.validate |
54 | 60 | """ |
| 61 | + yaml_config = load_yaml(yaml_config) |
55 | 62 |
|
56 | 63 | if schema is None: |
57 | | - schema = SCHEMA |
| 64 | + # try get PEtab version from yaml file |
| 65 | + # if this is not the available, the file is not valid anyways, |
| 66 | + # but let's still use the latest PEtab schema for full validation |
| 67 | + version = yaml_config.get(FORMAT_VERSION, None) \ |
| 68 | + or list(SCHEMAS.values())[-1] |
| 69 | + schema = SCHEMAS[str(version)] |
58 | 70 |
|
59 | 71 | schema = load_yaml(schema) |
60 | | - yaml_config = load_yaml(yaml_config) |
61 | | - |
62 | 72 | jsonschema.validate(instance=yaml_config, schema=schema) |
63 | 73 |
|
64 | 74 |
|
|
0 commit comments