posit-dev / positron

Positron, a next-generation data science IDE
Other
2.39k stars 70 forks source link

A Haystack show() function doesn't work in Positron but does in VS Code #4504

Open smach opened 2 weeks ago

smach commented 2 weeks ago

Not urgent, more an FYI

System details:

Positron and OS details:

Windows

Positron Version: 2024.08.0 (system setup) build 48 Code - OSS Version: 1.91.0 Commit: ed616b36655fb24d116108bdd833f1321704315b Date: 2024-08-19T03:30:12.447Z Electron: 29.4.0 Chromium: 122.0.6261.156 Node.js: 20.9.0 V8: 12.2.281.27-electron.0 OS: Windows_NT x64 10.0.22631

Interpreter details:

Python 3.11.8

Describe the issue:

I'm running a Jupyter notebook locally for a DeepLearning AI Haystack course. A Haystack pipeline is supposed to display a graph with a call such as my_pipeline.show() in a Jupyter notebook. It works in VS Code. It does not work in Positron, though, even though it's an .ipynb file. I get the error message

PipelineDrawingError Traceback (most recent call last)

Cell In[10], line 1

----> 1 indexing_pipeline.show() # for Jupyter notebooks only!

File d:\GenAI\DeepLearningAICourses\haystack_class\env\Lib\site-packages\haystack\core\pipeline\base.py:568, in PipelineBase.show(self)

566 else:

567     msg = "This method is only supported in Jupyter notebooks. Use Pipeline.draw() to save an image locally."

--> 568 raise PipelineDrawingError(msg)

PipelineDrawingError: This method is only supported in Jupyter notebooks. Use Pipeline.draw() to save an image locally.

Info on the Haystack show() function here https://docs.haystack.deepset.ai/docs/visualizing-pipelines. We are not supposed to be posting class assignments to GitHub as far as I know so I'm not including the notebook file.

isabelizimm commented 2 weeks ago

Thank you so much for the report! 🙌 I was able to reproduce this locally with:

pip install haystack-ai

In a Jupyter notebook:

from haystack import Document, Pipeline
from haystack.document_stores.in_memory import InMemoryDocumentStore
from haystack.components.embedders import SentenceTransformersTextEmbedder
from haystack.components.retrievers.in_memory import InMemoryEmbeddingRetriever

document_store = InMemoryDocumentStore(embedding_similarity_function="cosine")
text_embedder = SentenceTransformersTextEmbedder()
retriever = InMemoryEmbeddingRetriever(document_store=document_store)

query_pipeline = Pipeline()

query_pipeline.show()

I'm on Python 3.11.4 and haystack-ai==2.4.0.