Open dithyrambe opened 2 years ago
I think the initial design and implementation of parallelism on dsl.ParallelFor
didn't match everyone's expectation on how it should work. Thus, there was a subsequent work: https://github.com/kubeflow/pipelines/pull/4199
also affected by this.
was this fixed?
Here is hack:
def fix_parallelism(source_pipeline_path, parallelism = 10, target_pipeline_path = None):
"""
limits the number of parallel tasks
Args:
source_pipeline_file(str) - path to the source pipeline yaml to be edited.
parallelism(int) - parallelisim to use
target_pipeline_path (str) - target path, default same as source.
Returns:
None - edits the source file.
"""
# see https://github.com/kubeflow/pipelines/issues/6588
with open(source_pipeline_path,'rt') as f:
data = yaml.load(f, Loader=SafeLoader)
pipeline_name = json.loads(data['metadata']['annotations']['pipelines.kubeflow.org/pipeline_spec'])['name']
pipeline_index = [i for i, t in enumerate(data['spec']['templates']) if t['name']==pipeline_name][0]
data['spec']['templates'][pipeline_index]['parallelism']=parallelism
target_pipeline_path = target_pipeline_path or source_pipeline_path
with open(target_pipeline_path,'wt') as f:
yaml.dump(data, f)
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
Environment
1.8.2
Steps to reproduce
Expected result
The pipelines runs but compiling this pipeline with
dsl-compile --py pipeline.py --output ./pipeline.yaml
puts theparallelism: 2
on a supposedly wrong template. Thus, when running this pipeline with 4 items inargs
, all 4 task are scheduled at once instead of keeping a maximum parallelism at 2. In the compiled YAML I was expecting to seeparallelism: 2
within theentrypoint
template (the one with thewithParam
section). Actually, when manually movingparallelism: 2
to the entrypoint template, it works as intended.See below Actual output:
Applying this diff fixes the issue:
Materials and Reference
Am I somehow using
ParallelFor
in a wrong way ?Impacted by this bug? Give it a 👍. We prioritise the issues with the most 👍.