Skip to content

Commit c7c615d

Browse files
committed
fix: output sign of pooled slices
Signed-off-by: zjgemi <[email protected]>
1 parent 5b388ab commit c7c615d

File tree

2 files changed

+8
-7
lines changed

2 files changed

+8
-7
lines changed

src/dflow/python/op.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ class OP(ABC):
5353
slices = {}
5454
tmp_root = "/tmp"
5555
create_slice_dir = False
56+
pool_size = None
5657

5758
def __init__(
5859
self,
@@ -417,6 +418,11 @@ def handle_outputs(self, outputs, symlink=False):
417418
sign = output_sign[name]
418419
if isinstance(sign, Artifact):
419420
slices = self.slices.get(name)
421+
if self.pool_size and slices is not None:
422+
if sign.type == str:
423+
sign.type = List[str]
424+
elif sign.type == Path:
425+
sign.type = List[Path]
420426
handle_output_artifact(
421427
name, outputs[name], sign, slices, self.tmp_root,
422428
self.create_slice_dir and slices, symlink=symlink)

src/dflow/python/python_op_template.py

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -604,6 +604,8 @@ def render_script(self):
604604
else:
605605
slices = self.get_slices(output_parameter_slices, name)
606606
script += " op_obj.slices['%s'] = %s\n" % (name, slices)
607+
script += " op_obj.pool_size = %s\n" % getattr(
608+
self.slices, "pool_size", None)
607609

608610
script += " import signal\n"
609611
script += " def sigterm_handler(signum, frame):\n"
@@ -671,13 +673,6 @@ def render_script(self):
671673
for name in sliced_outputs:
672674
script += " output['%s'] = [o.get('%s') if o is not None"\
673675
" else None for o in output_list]\n" % (name, name)
674-
if isinstance(output_sign[name], Artifact):
675-
if output_sign[name].type == str:
676-
script += " output_sign['%s'].type = List[str]"\
677-
"\n" % name
678-
elif output_sign[name].type == Path:
679-
script += " output_sign['%s'].type = List[Path"\
680-
"]\n" % name
681676
else:
682677
script += " try:\n"
683678
script += " try:\n"

0 commit comments

Comments
 (0)