Skip to content

Commit

Permalink
fix package name, change _parse_connection_name function name, add te…
Browse files Browse the repository at this point in the history
…sts (#126)
  • Loading branch information
masci authored Oct 11, 2023
1 parent 3555315 commit 5357ae5
Show file tree
Hide file tree
Showing 21 changed files with 12 additions and 5 deletions.
2 changes: 1 addition & 1 deletion canals/pipeline/connections.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
logger = logging.getLogger(__name__)


def _parse_connection_name(connection: str) -> Tuple[str, Optional[str]]:
def parse_connection(connection: str) -> Tuple[str, Optional[str]]:
"""
Returns component-connection pairs from a connect_to/from string
"""
Expand Down
6 changes: 3 additions & 3 deletions canals/pipeline/pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
from canals.pipeline.draw import _draw, _convert_for_debug, RenderingEngines
from canals.pipeline.sockets import InputSocket, OutputSocket
from canals.pipeline.validation import _validate_pipeline_input
from canals.pipeline.connections import _parse_connection_name, _find_unambiguous_connection
from canals.pipeline.connections import parse_connection, _find_unambiguous_connection
from canals.utils import _type_name
from canals.serialization import component_to_dict, component_from_dict

Expand Down Expand Up @@ -249,8 +249,8 @@ def connect(self, connect_from: str, connect_to: str) -> None:
not present in the pipeline, or the connections don't match by type, and so on).
"""
# Edges may be named explicitly by passing 'node_name.edge_name' to connect().
from_node, from_socket_name = _parse_connection_name(connect_from)
to_node, to_socket_name = _parse_connection_name(connect_to)
from_node, from_socket_name = parse_connection(connect_from)
to_node, to_socket_name = parse_connection(connect_to)

# Get the nodes data.
try:
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,10 @@

import pytest

from canals import Pipeline, component
from canals import Pipeline
from canals.errors import PipelineConnectError
from canals.testing import factory
from canals.pipeline.connections import parse_connection
from sample_components import AddFixedValue


Expand Down Expand Up @@ -407,3 +408,9 @@ def test_connect_many_connections_possible_no_name_matches():
pipe.add_component("c2", Component2())
with pytest.raises(PipelineConnectError, match=expected_message):
pipe.connect("c1", "c2")


def test_parse_connection():
assert parse_connection("foobar") == ("foobar", None)
assert parse_connection("foo.bar") == ("foo", "bar")
assert parse_connection("foo.bar.baz") == ("foo", "bar.baz")
File renamed without changes.
File renamed without changes.

0 comments on commit 5357ae5

Please sign in to comment.