From c43fb03546059b25f54c4c4aff7d7d9a9ef6f195 Mon Sep 17 00:00:00 2001 From: Mehdi Naderi Varandi Date: Thu, 12 Oct 2023 15:13:02 +0100 Subject: [PATCH] Issue #1548: Fix improper display of 'run command' text (#1569) * Add conditional statement, prevent None values being added automatically Signed-off-by: mehdinv * Added new test for task_nodes w/ no namespace Signed-off-by: mehdinv * Updated Release.md file with bug fix mention Signed-off-by: mehdinv * Update RELEASE.md w/ PR number instead of Issue Co-authored-by: Tynan DeBold --------- Signed-off-by: mehdinv Co-authored-by: Tynan DeBold --- RELEASE.md | 5 +++++ package/kedro_viz/models/flowchart.py | 2 ++ package/tests/test_models/test_flowchart.py | 22 +++++++++++++++++++++ 3 files changed, 29 insertions(+) diff --git a/RELEASE.md b/RELEASE.md index 9badd8aa49..1af0992949 100644 --- a/RELEASE.md +++ b/RELEASE.md @@ -6,6 +6,11 @@ Please follow the established format: - Include the ID number for the related PR (or PRs) in parentheses --> +# Next Release + +## Bug fixes and other changes +- Fix improper display of 'run-command' inside the metadata panel. (#1569) + # Release 6.6.0 ## Major features and improvements diff --git a/package/kedro_viz/models/flowchart.py b/package/kedro_viz/models/flowchart.py index a59d11f4c5..e64187f1d1 100644 --- a/package/kedro_viz/models/flowchart.py +++ b/package/kedro_viz/models/flowchart.py @@ -411,6 +411,8 @@ def __post_init__(self, task_node: TaskNode): if kedro_node._name is not None: self.run_command = ( f"kedro run --to-nodes={task_node.namespace}.{kedro_node._name}" + if task_node.namespace is not None + else f"kedro run --to-nodes={kedro_node._name}" ) diff --git a/package/tests/test_models/test_flowchart.py b/package/tests/test_models/test_flowchart.py index 0caa179e1f..08521f6be3 100644 --- a/package/tests/test_models/test_flowchart.py +++ b/package/tests/test_models/test_flowchart.py @@ -304,6 +304,28 @@ def identity(x): == "kedro run --to-nodes=namespace.identity_node" ) + def test_task_node_metadata_no_namespace(self): + kedro_node = node( + identity, + inputs="x", + outputs="y", + name="identity_node", + tags={"tag"}, + ) + task_node = GraphNode.create_task_node(kedro_node) + task_node_metadata = TaskNodeMetadata(task_node=task_node) + assert task_node_metadata.code == dedent( + """\ + def identity(x): + return x + """ + ) + assert task_node_metadata.filepath == str( + Path(__file__).relative_to(Path.cwd().parent).expanduser() + ) + assert task_node_metadata.parameters == {} + assert task_node_metadata.run_command == "kedro run --to-nodes=identity_node" + def test_task_node_metadata_no_run_command(self): kedro_node = node( identity,