From d52b21859927446ddb35f65fc59bbae53d61b55e Mon Sep 17 00:00:00 2001 From: anakin87 Date: Thu, 21 Mar 2024 09:50:56 +0100 Subject: [PATCH 1/4] try --- haystack/core/pipeline/pipeline.py | 5 ----- 1 file changed, 5 deletions(-) diff --git a/haystack/core/pipeline/pipeline.py b/haystack/core/pipeline/pipeline.py index 3fd91fbce1..8442bfdd30 100644 --- a/haystack/core/pipeline/pipeline.py +++ b/haystack/core/pipeline/pipeline.py @@ -88,11 +88,6 @@ def __repr__(self) -> str: Returns a text representation of the Pipeline. If this runs in a Jupyter notebook, it will instead display the Pipeline image. """ - if is_in_jupyter(): - # If we're in a Jupyter notebook we want to display the image instead of the text repr. - self.show() - return "" - res = f"{object.__repr__(self)}\n" if self.metadata: res += "🧱 Metadata\n" From a5b7dcb56626682459834d17cfd9ed3690801f20 Mon Sep 17 00:00:00 2001 From: anakin87 Date: Thu, 21 Mar 2024 10:20:31 +0100 Subject: [PATCH 2/4] fix docstring --- haystack/core/pipeline/pipeline.py | 1 - 1 file changed, 1 deletion(-) diff --git a/haystack/core/pipeline/pipeline.py b/haystack/core/pipeline/pipeline.py index 8442bfdd30..5737d30955 100644 --- a/haystack/core/pipeline/pipeline.py +++ b/haystack/core/pipeline/pipeline.py @@ -86,7 +86,6 @@ def __eq__(self, other) -> bool: def __repr__(self) -> str: """ Returns a text representation of the Pipeline. - If this runs in a Jupyter notebook, it will instead display the Pipeline image. """ res = f"{object.__repr__(self)}\n" if self.metadata: From b037ae549ab6fad5701ed002accca0b4a14623ae Mon Sep 17 00:00:00 2001 From: anakin87 Date: Thu, 21 Mar 2024 10:42:38 +0100 Subject: [PATCH 3/4] simplify tests --- test/core/pipeline/test_pipeline.py | 23 ++--------------------- 1 file changed, 2 insertions(+), 21 deletions(-) diff --git a/test/core/pipeline/test_pipeline.py b/test/core/pipeline/test_pipeline.py index 9276ce3270..ef15ccf1a1 100644 --- a/test/core/pipeline/test_pipeline.py +++ b/test/core/pipeline/test_pipeline.py @@ -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()) @@ -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(): From 101dbb143dab94d37042277759c995bbf51d9f0b Mon Sep 17 00:00:00 2001 From: anakin87 Date: Thu, 21 Mar 2024 10:48:13 +0100 Subject: [PATCH 4/4] add release note --- .../notes/pipe-disable-autoshow-dbbafd2bfdcce7a4.yaml | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 releasenotes/notes/pipe-disable-autoshow-dbbafd2bfdcce7a4.yaml diff --git a/releasenotes/notes/pipe-disable-autoshow-dbbafd2bfdcce7a4.yaml b/releasenotes/notes/pipe-disable-autoshow-dbbafd2bfdcce7a4.yaml new file mode 100644 index 0000000000..3acc6c6932 --- /dev/null +++ b/releasenotes/notes/pipe-disable-autoshow-dbbafd2bfdcce7a4.yaml @@ -0,0 +1,7 @@ +--- +enhancements: + - | + In Jupyter notebooks, the image of the Pipeline will no longer be displayed automatically. + The textual representation of the Pipeline will be displayed. + + To display the Pipeline image, use the `show` method of the Pipeline object.