diff --git a/petab/petablint.py b/petab/petablint.py index 244b7536..413f67db 100755 --- a/petab/petablint.py +++ b/petab/petablint.py @@ -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: diff --git a/petab/v1/yaml.py b/petab/v1/yaml.py index b8330028..0c092049 100644 --- a/petab/v1/yaml.py +++ b/petab/v1/yaml.py @@ -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)