feat: Support multiple RayPipelines
#4078
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Related Issues
RayPipelines
from the same app #4077Proposed Changes:
Currently you can only run one
RayPipeline
within one app, because theRayPipeline
always tries to initialize a new Ray connection - if one is already initialized then it will simply fail.See the Ray initialization at /~https://github.com/deepset-ai/haystack/blob/main/haystack/pipelines/ray.py#L80
Due to that, the app will fail when it starts to initialize the second
RayPipeline
, as the first one has already initialized the Ray connection and an error will be thrown:Having two
RayPipelines
are now being made possible by this PR by checking if Ray has already been initialized and if yes, then we skip initialization (which would fail) (alternatively we could catch the error, but I believe it is nicer to do it this way).Obviously this also means that the second RayPipeline's parameters will NOT be applied to the Ray connection, as the first
RayPipeline
has already opened that connection, so throwing a warning log is warranted when Ray is initialized, so the user is aware not the Ray connection is not initialized again.How did you test it?
I have an app with two
RayPipelines
which now do run with this change and they were not before.Notes for the reviewer
I guess this is pretty simple, the only twist is that the second
RayPipelines
'sray_args
are ignored, as a Ray connection is already initialized and Ray doesn't allow you to have two of those - hence the warning I have included.Checklist
fix:
,feat:
,build:
,chore:
,ci:
,docs:
,style:
,refactor:
,perf:
,test:
.