Skip to content

Commit

Permalink
Move transcoding constant/utils back to pipeline (#3826)
Browse files Browse the repository at this point in the history
Signed-off-by: Deepyaman Datta <deepyaman.datta@utexas.edu>
  • Loading branch information
deepyaman committed May 21, 2024
1 parent 3ac8b52 commit 8eff357
Show file tree
Hide file tree
Showing 7 changed files with 30 additions and 10 deletions.
2 changes: 1 addition & 1 deletion kedro/framework/context/context.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
from kedro.config import AbstractConfigLoader, MissingConfigException
from kedro.framework.project import settings
from kedro.io import DataCatalog
from kedro.pipeline._transcoding import _transcode_split
from kedro.pipeline.transcoding import _transcode_split


def _is_relative_path(path_string: str) -> bool:
Expand Down
3 changes: 1 addition & 2 deletions kedro/pipeline/modular_pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from kedro.pipeline.node import Node
from kedro.pipeline.pipeline import Pipeline

from ._transcoding import TRANSCODING_SEPARATOR, _strip_transcoding, _transcode_split
from .transcoding import TRANSCODING_SEPARATOR, _strip_transcoding, _transcode_split


class ModularPipelineError(Exception):
Expand Down Expand Up @@ -223,7 +223,6 @@ def pipeline( # noqa: PLR0913
if not any([inputs, outputs, parameters, namespace]):
return pipe

# noqa: protected-access
inputs = _get_dataset_names_mapping(inputs)
outputs = _get_dataset_names_mapping(outputs)
parameters = _get_param_names_mapping(parameters)
Expand Down
2 changes: 1 addition & 1 deletion kedro/pipeline/node.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

from more_itertools import spy, unzip

from ._transcoding import _strip_transcoding
from .transcoding import _strip_transcoding


class Node:
Expand Down
21 changes: 17 additions & 4 deletions kedro/pipeline/pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,23 @@
import kedro
from kedro.pipeline.node import Node, _to_list

from ._transcoding import (
TRANSCODING_SEPARATOR, # noqa: F401 for 0.19.x backward compatibility
_strip_transcoding,
)
from .transcoding import _strip_transcoding


def __getattr__(name: str) -> Any:
if name == "TRANSCODING_SEPARATOR":
import warnings

from kedro.pipeline.transcoding import TRANSCODING_SEPARATOR

warnings.warn(
f"{repr(name)} has been moved to 'kedro.pipeline.transcoding', "
f"and the alias will be removed in Kedro 0.20.0",
kedro.KedroDeprecationWarning,
stacklevel=2,
)
return TRANSCODING_SEPARATOR
raise AttributeError(f"module {repr(__name__)} has no attribute {repr(name)}")


class OutputNotUniqueError(Exception):
Expand Down
File renamed without changes.
10 changes: 9 additions & 1 deletion tests/pipeline/test_pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,22 @@
import pytest

import kedro
from kedro import KedroDeprecationWarning
from kedro.pipeline import node
from kedro.pipeline._transcoding import _strip_transcoding, _transcode_split
from kedro.pipeline.modular_pipeline import pipeline as modular_pipeline
from kedro.pipeline.pipeline import (
CircularDependencyError,
ConfirmNotUniqueError,
OutputNotUniqueError,
)
from kedro.pipeline.transcoding import _strip_transcoding, _transcode_split


def test_deprecation():
with pytest.warns(
KedroDeprecationWarning, match="'TRANSCODING_SEPARATOR' has been moved"
):
from kedro.pipeline.pipeline import TRANSCODING_SEPARATOR # noqa: F401


class TestTranscodeHelpers:
Expand Down
2 changes: 1 addition & 1 deletion tests/pipeline/test_pipeline_with_transcoding.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@

import kedro
from kedro.pipeline import node
from kedro.pipeline._transcoding import _strip_transcoding
from kedro.pipeline.modular_pipeline import pipeline as modular_pipeline
from kedro.pipeline.pipeline import (
CircularDependencyError,
OutputNotUniqueError,
)
from kedro.pipeline.transcoding import _strip_transcoding


# Different dummy func based on the number of arguments
Expand Down

0 comments on commit 8eff357

Please sign in to comment.