Skip to content

Commit

Permalink
Fixed small bug in DSL code that generates unique names for ops (kube…
Browse files Browse the repository at this point in the history
…flow#923)

Before the fix it would generate names as follows:
name
name-2
name-2-3

After the fix:
name
name-2
name-3
  • Loading branch information
Ark-kun authored Mar 6, 2019
1 parent 4330fcf commit 1727195
Showing 1 changed file with 2 additions and 6 deletions.
8 changes: 2 additions & 6 deletions sdk/python/kfp/dsl/_pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
from . import _container_op
from ._metadata import PipelineMeta, ParameterMeta, TypeMeta, _annotation_to_typemeta
from . import _ops_group
from ..components._naming import _make_name_unique_by_adding_index
import sys


Expand Down Expand Up @@ -157,13 +158,8 @@ def add_op(self, op: _container_op.ContainerOp, define_only: bool):
op_name: a unique op name.
"""

op_name = op.human_name
#If there is an existing op with this name then generate a new name.
if op_name in self.ops:
for i in range(2, sys.maxsize**10):
op_name = op_name + '-' + str(i)
if op_name not in self.ops:
break
op_name = _make_name_unique_by_adding_index(op.human_name, list(self.ops.keys()), ' ')

self.ops[op_name] = op
if not define_only:
Expand Down

0 comments on commit 1727195

Please sign in to comment.