From 59a2d421e0a99860aa371890ed3de7d548bae152 Mon Sep 17 00:00:00 2001 From: Vassilis Vassiliadis Date: Fri, 20 Sep 2024 11:12:47 +0100 Subject: [PATCH] feat: include "signature", "name" in DSL errors about conflicting template names (#365) Resolves https://github.ibm.com/st4sd/st4sd-runtime-core/issues/364 Signed-off-by: Vassilis Vassiladis --- python/experiment/model/frontends/dsl.py | 2 +- tests/test_dsl.py | 6 +++--- tests/test_package_load.py | 6 +++--- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/python/experiment/model/frontends/dsl.py b/python/experiment/model/frontends/dsl.py index 1e93155..0eb2419 100644 --- a/python/experiment/model/frontends/dsl.py +++ b/python/experiment/model/frontends/dsl.py @@ -1781,7 +1781,7 @@ class Action(str, enum.Enum): template_type = known_template_names[temp.signature.name] dsl_error.underlying_errors.append( experiment.model.errors.DSLInvalidFieldError( - location=[kind.lower() + "s", idx], + location=[kind.lower() + "s", idx, "signature", "name"], underlying_error=KeyError(f"There already is a {template_type} " f"template called {temp.signature.name}") ) diff --git a/tests/test_dsl.py b/tests/test_dsl.py index 62f1178..4cd2f12 100644 --- a/tests/test_dsl.py +++ b/tests/test_dsl.py @@ -775,9 +775,9 @@ def test_dsl_conflicting_templates(dsl_conflicting_templates: typing.Dict[str, t experiment.model.frontends.dsl.lightweight_validate(namespace) assert e.value.errors() == [ - {'loc': ['workflows', 1], 'msg': 'There already is a Workflow template called main'}, - {'loc': ['components', 0], 'msg': 'There already is a Workflow template called main'}, - {'loc': ['components', 2], 'msg': 'There already is a Component template called comp'} + {'loc': ['workflows', 1, "signature", "name"], 'msg': 'There already is a Workflow template called main'}, + {'loc': ['components', 0, "signature", "name"], 'msg': 'There already is a Workflow template called main'}, + {'loc': ['components', 2, "signature", "name"], 'msg': 'There already is a Component template called comp'} ] diff --git a/tests/test_package_load.py b/tests/test_package_load.py index 6ebaff2..507cd5d 100644 --- a/tests/test_package_load.py +++ b/tests/test_package_load.py @@ -82,9 +82,9 @@ def test_load_dsl_with_bad_grammar(output_dir, dsl_conflicting_templates): assert isinstance(error.underlyingError, experiment.model.errors.DSLInvalidError) assert error.underlyingError.errors() == [ - {'loc': ['workflows', 1], 'msg': 'There already is a Workflow template called main'}, - {'loc': ['components', 0], 'msg': 'There already is a Workflow template called main'}, - {'loc': ['components', 2], 'msg': 'There already is a Component template called comp'} + {'loc': ['workflows', 1, "signature", "name"], 'msg': 'There already is a Workflow template called main'}, + {'loc': ['components', 0, "signature", "name"], 'msg': 'There already is a Workflow template called main'}, + {'loc': ['components', 2, "signature", "name"], 'msg': 'There already is a Component template called comp'} ]