Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
include petab/petab_schema.yaml
recursive-include petab/visualize/templates
recursive-include petab/schemas *.yaml
recursive-include petab/visualize/templates *
File renamed without changes.
20 changes: 15 additions & 5 deletions petab/yaml.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,14 @@

from .C import * # noqa: F403

SCHEMA = os.path.join(os.path.abspath(os.path.dirname(__file__)),
"petab_schema.yaml")
# directory with PEtab yaml schema files
SCHEMA_DIR = Path(__file__).parent / "schemas"
# map of version number to validation schema
SCHEMAS = {
'1': SCHEMA_DIR / "petab_schema.v1.0.0.yaml",
'1.0.0': SCHEMA_DIR / "petab_schema.v1.0.0.yaml",
}

__all__ = ['validate', 'validate_yaml_syntax', 'validate_yaml_semantics',
'load_yaml', 'is_composite_problem',
'assert_single_condition_and_sbml_file', 'write_yaml',
Expand Down Expand Up @@ -52,13 +58,17 @@ def validate_yaml_syntax(
Raises:
see jsonschema.validate
"""
yaml_config = load_yaml(yaml_config)

if schema is None:
schema = SCHEMA
# try get PEtab version from yaml file
# if this is not the available, the file is not valid anyways,
# but let's still use the latest PEtab schema for full validation
version = yaml_config.get(FORMAT_VERSION, None) \
or list(SCHEMAS.values())[-1]
schema = SCHEMAS[str(version)]

schema = load_yaml(schema)
yaml_config = load_yaml(yaml_config)

jsonschema.validate(instance=yaml_config, schema=schema)


Expand Down