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

feat: Enhance Pipeline.__repr__() #6963

Merged
merged 8 commits into from
Feb 9, 2024
Merged

feat: Enhance Pipeline.__repr__() #6963

merged 8 commits into from
Feb 9, 2024

Conversation

silvanocerza
Copy link
Contributor

Related Issues

Proposed Changes:

Adds a custom __repr__ method in Pipeline that returns a nice text representation of a Pipeline.
If ran in a Jupyter notebook, like when it's the last statement of a cell, it will instead display the image created with Pipeline.draw().

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")

Would generate this output:

<haystack.core.pipeline.pipeline.Pipeline object at 0x1490c81f0>
🧱 Metadata
  - test: test
🚅 Components
  - add_two: AddFixedValue
  - add_default: AddFixedValue
  - double: Double
🛤️ Connections
  - add_two.result -> double.value (int)
  - double.value -> add_default.value (int)

How did you test it?

I added new unit tests.

Notes for the reviewer

Depends on #6961.

Checklist

@silvanocerza silvanocerza self-assigned this Feb 8, 2024
@silvanocerza silvanocerza requested review from a team as code owners February 8, 2024 17:34
@silvanocerza silvanocerza requested review from dfokina and shadeMe and removed request for a team February 8, 2024 17:34
haystack/core/pipeline/pipeline.py Outdated Show resolved Hide resolved
@silvanocerza silvanocerza requested a review from shadeMe February 9, 2024 11:51
Copy link
Contributor

@shadeMe shadeMe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! You might want to remove the generated PNG files from the PR before merging, though.

Base automatically changed from enhance-pipeline-draw to main February 9, 2024 13:44
@silvanocerza silvanocerza merged commit d2d01f9 into main Feb 9, 2024
22 checks passed
@silvanocerza silvanocerza deleted the enhance-repr branch February 9, 2024 13:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Pipeline.__repr__ should display an easy to understand representation of the Pipeline
2 participants