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
15 changes: 14 additions & 1 deletion petab/petablint.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,10 +160,23 @@ def main():
try:
validate(args.yaml_file_name)
except SchemaValidationError as e:
path = ""
if e.absolute_path:
# construct a path to the error location inside the YAML file
path = list(e.absolute_path)
path = (
f" at {path[0]}"
+ "".join(f"[{str(p)}]" for p in path[1:])
+ ": "
)
logger.error(
f"Provided YAML file does not adhere to PEtab schema: {e}"
"Provided YAML file does not adhere to the PEtab schema"
f"{path}: {e.args[0]}"
)
sys.exit(1)
except ValueError as e:
logger.error(e)
sys.exit(1)

if petab.is_composite_problem(args.yaml_file_name):
# TODO: further checking:
Expand Down
6 changes: 2 additions & 4 deletions petab/v1/yaml.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,16 +77,14 @@ def validate_yaml_syntax(
# but let's still use the latest PEtab schema for full validation
version = yaml_config.get(FORMAT_VERSION, None)
version = (
parse_version(version)[:2]
if version
else list(SCHEMAS.values())[-1]
parse_version(version)[:2] if version else list(SCHEMAS.keys())[-1]
)

try:
schema = SCHEMAS[version]
except KeyError as e:
raise ValueError(
"Unknown PEtab version given in problem "
"No or unknown PEtab version given in problem "
f"specification: {version}"
) from e
schema = load_yaml(schema)
Expand Down