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

Pass the same key object to task with multiple process arguments #286

Merged
merged 1 commit into from
Dec 20, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 26 additions & 21 deletions caput/pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -1527,33 +1527,38 @@ def _pipeline_queue_product(self, key, product):

# First, check requires keys
if key in self._requires_keys:
ii = self._requires_keys.index(key)
logger.debug(
f"{self!s} stowing data product with key {key} for `requires`."
)
if self._requires is None:
raise PipelineRuntimeError(
"Tried to set 'requires' data product, but `setup()` already run."
)
if self._requires[ii] is not None:
raise PipelineRuntimeError(
"'requires' data product set more than once."
# It's possible that the same key could be passed multiple times
indices = (ii for ii, k in enumerate(self._requires_keys) if k == key)

for ii in indices:
logger.debug(
f"{self!s} stowing data product with key {key} for `requires`."
)
self._requires[ii] = product
if self._requires is None:
raise PipelineRuntimeError(
"Tried to set 'requires' data product, but `setup()` already run."
)
if self._requires[ii] is not None:
raise PipelineRuntimeError(
"'requires' data product set more than once."
)
self._requires[ii] = product

result = True
result = True

if key in self._in_keys:
ii = self._in_keys.index(key)
logger.debug(f"{self!s} stowing data product with key {key} for `in`.")
if self._in is None:
raise PipelineRuntimeError(
"Tried to queue 'in' data product, but `next()` already run."
)
indices = (ii for ii, k in enumerate(self._in_keys) if k == key)

for ii in indices:
logger.debug(f"{self!s} stowing data product with key {key} for `in`.")
if self._in is None:
raise PipelineRuntimeError(
"Tried to queue 'in' data product, but `next()` already run."
)

self._in[ii].put(product)
self._in[ii].put(product)

result = True
result = True

return result

Expand Down
Loading