-
Notifications
You must be signed in to change notification settings - Fork 2.2k
feat: draw/show SuperComponents in detail, expand it and show it's internal components in the visualisation diagram #9389
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
Conversation
Pull Request Test Coverage Report for Build 15196767034Details
💛 - Coveralls |
Hey @davidsbatista could you also add the mermaid picture of your example? I think that would help with the review |
@sjrl I've also added a version of the same pipeline, but defining each component, no SuperComponents used |
Thanks @davidsbatista it's looking good! Looking back at the original issue do you think it would be possible to add this dotted box around where the super component is in the expanded view? |
@sjrl did you do that yourself or the community member? Just to understand if that was programmatically or "photoshopped" |
Oh interesting, yeah I think any kind of visual difference would be nice! It would be great though if we could easily distinguish between different super components within the same pipeline. So maybe different shades of the same color? Also would it be possible to add a legend to indicate which color goes with which super component? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks nice - would be great to later extract utils related to super components in pipeline and component being a super component!
haystack/core/pipeline/base.py
Outdated
def show( | ||
self, | ||
server_url: str = "https://mermaid.ink", | ||
super_component_expansion: bool = False, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should add super_component_expansion
at the bottom of this function otherwise inserting it in the middle is a breaking change.
haystack/core/pipeline/base.py
Outdated
self, | ||
path: Path, | ||
server_url: str = "https://mermaid.ink", | ||
super_component_expansion: bool = False, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here we should move the new variable to the bottom of the function
Nice the color coding and the legend look great! Just a few other minor comments. |
Co-authored-by: Sebastian Husch Lee <10526848+sjrl@users.noreply.github.com>
@sjrl I opted for forcing keyword arguments for draw() and show() - I think this is a better solution which also avoids problems if we need to add /remove any other parameters |
I agree with you in principle, but enforcing keyword arguments now is also a breaking change right? |
I can try to write a wrapper so that we can ship this in the next release, with a warning. Then, after the 2.14 release remove the warning and the wrapper function. |
haystack/core/pipeline/base.py
Outdated
:raises PipelineDrawingError: | ||
If the function is called outside of a Jupyter notebook or if there is an issue with rendering. | ||
""" | ||
import warnings | ||
|
||
warnings.warn( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Currently, we would show this warning even if there are no positional arguments. Can we show the warning only if there are any positional arguments? For example making use of inspect.getargvalues or with something similar to this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would suggest to show it either way - just calling the function should be a enough to trigger the warning to the user that it will have some breaking changes in the future.
I don't think it's noisy if we show it even if he/she doesn't call it with positional arguments.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think I'm with Julian on this one. I think it makes more sense only to show the warning if the user is using the function in a way that won't work in the future.
Especially since if you follow the example how to fix the warning, the warning message still appears which could be frustrating to the user.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think it's good to shadow this from the user, especially if the user calls the function for whatever use he/she might have.
Anyway, I will code this only to trigger the warning in case the user calls the draw() or show() function using positional arguments.
…ed with positional arguments
…ed with positional arguments
I've added a function decorator to check if the I added tests to calls to draw() and show() with positional arguments, without positional arguments to check if the warning is triggered and not triggered in the correct cases. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me! 👍 Probably we will reuse the args_deprecated
in future when we switch to kwargs only in other places too.
Related Issues
Pipeline.draw
to allow expansion of a SuperComponent #9299Proposed Changes:
Pipeline
_find_super_components(self)
- this will find all the SuperComponents in a Pipeline._merge_super_component_pipelines(self)
: this will expand all the SuperComponents in a pipeline. It will adjust the connections such that the internal components of a SuperComponent connect with the existing components of the Pipeline.How did you test it?
Notes for the reviewer
In case you want to test it, start a local mermaid server
Generate an image for the original pipeline, and the version with the expanded components
SuperComponent
SuperComponent expanded (i.e.: super_component_expansion=True)
Pipeline with each components defined originaly
Checklist
fix:
,feat:
,build:
,chore:
,ci:
,docs:
,style:
,refactor:
,perf:
,test:
and added!
in case the PR includes breaking changes.