Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix missing run command in metadata panel for task nodes #2055

Merged
merged 9 commits into from
Aug 22, 2024
1 change: 1 addition & 0 deletions RELEASE.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ Please follow the established format:
## Bug fixes and other changes

- Fixes design issues in metadata panel. (#2009)
- Fix missing run command in metadata panel for task nodes. (#2055)

# Release 9.2.0

Expand Down
9 changes: 1 addition & 8 deletions package/kedro_viz/models/flowchart.py
Original file line number Diff line number Diff line change
Expand Up @@ -452,14 +452,7 @@ def set_parameters(cls, _):
@field_validator("run_command")
@classmethod
def set_run_command(cls, _):
# if a node doesn't have a user-supplied `_name` attribute,
# a human-readable run command `kedro run --to-nodes/nodes` is not available
if cls.kedro_node._name is not None:
if cls.task_node.namespace is not None:
return f"kedro run --to-nodes={cls.task_node.namespace}.{cls.kedro_node._name}"
return f"kedro run --to-nodes={cls.kedro_node._name}"

return None
return f"kedro run --to-nodes='{cls.kedro_node.name}'"

@field_validator("inputs")
@classmethod
Expand Down
2 changes: 1 addition & 1 deletion package/tests/test_api/test_rest/test_responses.py
Original file line number Diff line number Diff line change
Expand Up @@ -637,7 +637,7 @@ def test_task_node_metadata(self, client):
assert metadata["outputs"] == ["model_inputs"]
assert (
metadata["run_command"]
== "kedro run --to-nodes=uk.data_processing.process_data"
== "kedro run --to-nodes='uk.data_processing.process_data'"
)
assert str(Path("package/tests/conftest.py")) in metadata["filepath"]

Expand Down
11 changes: 7 additions & 4 deletions package/tests/test_models/test_flowchart.py
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,7 @@ def identity(x):
assert not task_node_metadata.parameters
assert (
task_node_metadata.run_command
== "kedro run --to-nodes=namespace.identity_node"
== "kedro run --to-nodes='namespace.identity_node'"
)

def test_task_node_metadata_no_namespace(self):
Expand All @@ -338,9 +338,9 @@ def identity(x):
Path(__file__).relative_to(Path.cwd().parent).expanduser()
)
assert not task_node_metadata.parameters
assert task_node_metadata.run_command == "kedro run --to-nodes=identity_node"
assert task_node_metadata.run_command == "kedro run --to-nodes='identity_node'"

def test_task_node_metadata_no_run_command(self):
def test_task_node_metadata_no_name(self):
kedro_node = node(
identity,
inputs="x",
Expand All @@ -352,7 +352,10 @@ def test_task_node_metadata_no_run_command(self):
kedro_node, "identity_node", set(["namespace"])
)
task_node_metadata = TaskNodeMetadata(task_node=task_node)
assert task_node_metadata.run_command is None
assert (
task_node_metadata.run_command
== f"kedro run --to-nodes='{kedro_node.name}'"
)

def test_task_node_metadata_with_decorated_func(self):
kedro_node = node(
Expand Down
Loading