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

[WIP] Fix/remove-tags-from-datasets #1099

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion package/kedro_viz/api/rest/responses.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ class BaseGraphNodeAPIResponse(BaseAPIResponse):
id: str
name: str
full_name: str
tags: List[str]
pipelines: List[str]
type: str

Expand All @@ -31,6 +30,7 @@ class BaseGraphNodeAPIResponse(BaseAPIResponse):

class TaskNodeAPIResponse(BaseGraphNodeAPIResponse):
parameters: Dict
tags: List[str]

class Config:
schema_extra = {
Expand Down
4 changes: 0 additions & 4 deletions package/kedro_viz/data_access/managers.py
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,6 @@ def add_node_input(
graph_node = self.add_dataset(
registered_pipeline_id, input_dataset, is_free_input=is_free_input
)
graph_node.tags.update(task_node.tags)
self.edges[registered_pipeline_id].add_edge(
GraphEdge(source=graph_node.id, target=task_node.id)
)
Expand All @@ -217,7 +216,6 @@ def add_node_output(
The GraphNode instance representing the node's output that was added to the graph.
"""
graph_node = self.add_dataset(registered_pipeline_id, output_dataset)
graph_node.tags.update(task_node.tags)
self.edges[registered_pipeline_id].add_edge(
GraphEdge(source=task_node.id, target=graph_node.id)
)
Expand Down Expand Up @@ -247,14 +245,12 @@ def add_dataset(
graph_node = GraphNode.create_parameters_node(
full_name=dataset_name,
layer=layer,
tags=set(),
parameters=obj,
)
else:
graph_node = GraphNode.create_data_node(
full_name=dataset_name,
layer=layer,
tags=set(),
dataset=obj,
is_free_input=is_free_input,
)
Expand Down
16 changes: 3 additions & 13 deletions package/kedro_viz/models/flowchart.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,9 +103,6 @@ class GraphNode(abc.ABC):
# the underlying Kedro object for each graph node, if any
kedro_obj: Optional[Union[KedroNode, AbstractDataSet]] = field(default=None)

# the tags associated with this node
tags: Set[str] = field(default_factory=set)

# the set of registered pipeline IDs this node belongs to
pipelines: Set[str] = field(default_factory=set)

Expand Down Expand Up @@ -176,7 +173,6 @@ def create_task_node(cls, node: KedroNode) -> "TaskNode":
id=cls._hash(str(node)),
name=_pretty_name(node_name),
full_name=node_name,
tags=set(node.tags),
kedro_obj=node,
)

Expand All @@ -185,7 +181,6 @@ def create_data_node(
cls,
full_name: str,
layer: Optional[str],
tags: Set[str],
dataset: AbstractDataSet,
is_free_input: bool = False,
) -> Union["DataNode", "TranscodedDataNode"]:
Expand All @@ -194,8 +189,6 @@ def create_data_node(
full_name: The fullname of the dataset, including namespace, e.g.
data_science.master_table.
layer: The optional layer that the dataset belongs to.
tags: The set of tags assigned to assign to the graph representation
of this dataset. N.B. currently it's derived from the node's tags.
dataset: A dataset in a Kedro pipeline.
is_free_input: Whether the dataset is a free input in the pipeline
Returns:
Expand All @@ -208,7 +201,6 @@ def create_data_node(
id=cls._hash(dataset_name),
name=_pretty_name(_strip_namespace(dataset_name)),
full_name=dataset_name,
tags=tags,
layer=layer,
is_free_input=is_free_input,
)
Expand All @@ -217,7 +209,6 @@ def create_data_node(
id=cls._hash(full_name),
name=_pretty_name(_strip_namespace(full_name)),
full_name=full_name,
tags=tags,
layer=layer,
kedro_obj=dataset,
is_free_input=is_free_input,
Expand All @@ -228,16 +219,13 @@ def create_parameters_node(
cls,
full_name: str,
layer: Optional[str],
tags: Set[str],
parameters: AbstractDataSet,
) -> "ParametersNode":
"""Create a graph node of type PARAMETERS for a given Kedro parameters dataset instance.
Args:
full_name: The fullname of the dataset, including namespace, e.g.
data_science.test_split_ratio
layer: The optional layer that the parameters belong to.
tags: The set of tags assigned to assign to the graph representation
of this dataset. N.B. currently it's derived from the node's tags.
parameters: A parameters dataset in a Kedro pipeline.
Returns:
An instance of ParametersNode.
Expand All @@ -246,7 +234,6 @@ def create_parameters_node(
id=cls._hash(full_name),
name=_pretty_name(_strip_namespace(full_name)),
full_name=full_name,
tags=tags,
layer=layer,
kedro_obj=parameters,
)
Expand Down Expand Up @@ -299,6 +286,8 @@ class TaskNode(GraphNode):
"""Represent a graph node of type TASK"""

modular_pipelines: List[str] = field(init=False)
# the tags associated with this TaskNode
tags: Set[str] = field(default_factory=set)
parameters: Dict = field(init=False, default_factory=dict)
type: str = GraphNodeType.TASK.value

Expand All @@ -307,6 +296,7 @@ def __post_init__(self):

# the modular pipelines that a task node belongs to are derived from its namespace.
self.modular_pipelines = self._expand_namespaces(self.kedro_obj.namespace)
self.tags = set(self.kedro_obj.tags)


def _extract_wrapped_func(func: FunctionType) -> FunctionType:
Expand Down
14 changes: 8 additions & 6 deletions src/components/metadata/metadata.js
Original file line number Diff line number Diff line change
Expand Up @@ -190,12 +190,14 @@ const MetaData = ({
visible={isTaskNode}
value={metadata.outputs}
/>
<MetaDataRow
label="Tags:"
kind="token"
commas={false}
value={metadata.tags}
/>
{metadata.type === 'task' && (
<MetaDataRow
label="Tags:"
kind="token"
commas={false}
value={metadata.tags}
/>
)}
<MetaDataRow label="Run Command:" visible={Boolean(runCommand)}>
<CommandCopier command={runCommand} />
</MetaDataRow>
Expand Down
8 changes: 4 additions & 4 deletions src/components/metadata/metadata.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -309,13 +309,13 @@ describe('MetaData', () => {
]);
});

it('shows the node tags', () => {
it('shows empty node tags as tags only exist in TaskNode', () => {
const wrapper = mount({
nodeId: modelInputDataSetNodeId,
mockMetadata: nodeData,
});
const row = rowByLabel(wrapper, 'Tags:');
expect(textOf(rowValue(row))).toEqual(['Features', 'Split']);
expect(textOf(rowValue(row))).toEqual([]);
});

describe('when there is a runCommand returned by the backend', () => {
Expand Down Expand Up @@ -487,13 +487,13 @@ describe('MetaData', () => {
);
});

it('shows the node tags', () => {
it('shows empty node tags as tags only exist in TaskNode', () => {
const wrapper = mount({
nodeId: parametersNodeId,
mockMetadata: nodeParameters,
});
const row = rowByLabel(wrapper, 'Tags:');
expect(textOf(rowValue(row))).toEqual(['Split']);
expect(textOf(rowValue(row))).toEqual([]);
});
});

Expand Down