Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
Signed-off-by: Sajid Alam <sajid_alam@mckinsey.com>
  • Loading branch information
SajidAlamQB committed Oct 18, 2024
1 parent 29b3b3a commit 1d87c53
Show file tree
Hide file tree
Showing 20 changed files with 633 additions and 71 deletions.
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 @@ -13,7 +13,7 @@

from kedro_viz.api.rest.utils import get_package_compatibilities
from kedro_viz.data_access import data_access_manager
from kedro_viz.models.flowchart.flowchart import (
from kedro_viz.models.flowchart import (
DataNode,
DataNodeMetadata,
ParametersNodeMetadata,
Expand Down
2 changes: 1 addition & 1 deletion package/kedro_viz/data_access/managers.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

from kedro_viz.constants import DEFAULT_REGISTERED_PIPELINE_ID, ROOT_MODULAR_PIPELINE_ID
from kedro_viz.integrations.utils import UnavailableDataset
from kedro_viz.models.flowchart.flowchart import (
from kedro_viz.models.flowchart import (
DataNode,
GraphEdge,
GraphNode,
Expand Down
2 changes: 1 addition & 1 deletion package/kedro_viz/data_access/repositories/graph.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# pylint: disable=missing-class-docstring,missing-function-docstring
from typing import Dict, Generator, List, Optional, Set

from kedro_viz.models.flowchart.flowchart import GraphEdge, GraphNode
from kedro_viz.models.flowchart import GraphEdge, GraphNode


class GraphNodesRepository:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from kedro.pipeline.node import Node as KedroNode

from kedro_viz.constants import ROOT_MODULAR_PIPELINE_ID
from kedro_viz.models.flowchart.flowchart import (
from kedro_viz.models.flowchart import (
GraphNode,
GraphNodeType,
ModularPipelineChild,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from collections import OrderedDict, defaultdict
from typing import Dict, List, Optional, Set

from kedro_viz.models.flowchart.flowchart import RegisteredPipeline
from kedro_viz.models.flowchart import RegisteredPipeline


class RegisteredPipelinesRepository:
Expand Down
2 changes: 1 addition & 1 deletion package/kedro_viz/data_access/repositories/tags.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# pylint: disable=missing-class-docstring,missing-function-docstring
from typing import Iterable, List, Set

from kedro_viz.models.flowchart.flowchart import Tag
from kedro_viz.models.flowchart import Tag


class TagsRepository:
Expand Down
1 change: 1 addition & 0 deletions package/kedro_viz/models/flowchart/edges.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from pydantic import BaseModel


class GraphEdge(BaseModel, frozen=True):
"""Represent an edge in the graph
Expand Down
30 changes: 30 additions & 0 deletions package/kedro_viz/models/flowchart/entities.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
from pydantic import BaseModel, Field, ValidationInfo, field_validator
from typing import Optional


class NamedEntity(BaseModel):
"""Represent a named entity (Tag/Registered Pipeline) in a Kedro project."""

id: str
name: Optional[str] = Field(
default=None,
validate_default=True,
description="The name of the entity",
)

@field_validator("name")
@classmethod
def set_name(cls, _, info: ValidationInfo):
assert "id" in info.data
return info.data["id"]


class RegisteredPipeline(NamedEntity):
"""Represent a registered pipeline in a Kedro project."""


class Tag(NamedEntity):
"""Represent a tag in a Kedro project."""

def __hash__(self) -> int:
return hash(self.id)
10 changes: 10 additions & 0 deletions package/kedro_viz/models/flowchart/enums.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
from enum import Enum


class GraphNodeType(str, Enum):
"""Represent all possible node types in the graph representation of a Kedro pipeline."""

TASK = "task"
DATA = "data"
PARAMETERS = "parameters"
MODULAR_PIPELINE = "modularPipeline" # CamelCase for frontend compatibility
Loading

0 comments on commit 1d87c53

Please sign in to comment.