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: Pipeline - disable autoshow on Jupyter #7397

Merged
merged 4 commits into from
Mar 21, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
simplify tests
  • Loading branch information
anakin87 committed Mar 21, 2024
commit b037ae549ab6fad5701ed002accca0b4a14623ae
23 changes: 2 additions & 21 deletions test/core/pipeline/test_pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -281,8 +281,7 @@ def test_get_component_name_not_added_to_pipeline():
assert pipe.get_component_name(some_component) == ""


@patch("haystack.core.pipeline.pipeline.is_in_jupyter")
def test_repr(mock_is_in_jupyter):
def test_repr():
pipe = Pipeline(metadata={"test": "test"}, max_loops_allowed=42)
pipe.add_component("add_two", AddFixedValue(add=2))
pipe.add_component("add_default", AddFixedValue())
Expand All @@ -302,26 +301,8 @@ def test_repr(mock_is_in_jupyter):
" - add_two.result -> double.value (int)\n"
" - double.value -> add_default.value (int)\n"
)
# Simulate not being in a notebook
mock_is_in_jupyter.return_value = False
assert repr(pipe) == expected_repr


@patch("haystack.core.pipeline.pipeline.is_in_jupyter")
def test_repr_in_notebook(mock_is_in_jupyter):
pipe = Pipeline(metadata={"test": "test"}, max_loops_allowed=42)
pipe.add_component("add_two", AddFixedValue(add=2))
pipe.add_component("add_default", AddFixedValue())
pipe.add_component("double", Double())
pipe.connect("add_two", "double")
pipe.connect("double", "add_default")

# Simulate being in a notebook
mock_is_in_jupyter.return_value = True

with patch.object(Pipeline, "show") as mock_show:
assert repr(pipe) == ""
mock_show.assert_called_once_with()
assert repr(pipe) == expected_repr


def test_run_raises_if_max_visits_reached():
Expand Down