Skip to content

Commit

Permalink
Change which part of the hash value we make use of
Browse files Browse the repository at this point in the history
Signed-off-by: Ilias Katsakioris <elikatsis@arrikto.com>
  • Loading branch information
elikatsis committed Dec 17, 2019
1 parent 54c68aa commit f9bf52a
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 9 deletions.
9 changes: 2 additions & 7 deletions sdk/python/kfp/dsl/_pipeline_volume.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,13 +75,8 @@ def __init__(self,
hash_value = hashlib.sha256(bytes(json.dumps(self.to_dict(),
sort_keys=True),
"utf-8")).hexdigest()
name_prefix = "pvolume-"
# Name must be no more than 63 characters, so we will keep the last
# chars of the hash value
hash_len = 63 - len(name_prefix)
self.name = (name_prefix + hash_value[len(hash_value)-hash_len:]
if len(hash_value) > hash_len
else name_prefix + hash_value)
name = f"pvolume-{hash_value}"
self.name = name[0:63] if len(name) > 63 else name
self.dependent_names = []

def after(self, *ops):
Expand Down
4 changes: 2 additions & 2 deletions sdk/python/tests/dsl/pipeline_volume_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,8 @@ def test_omitting_name(self):
def my_pipeline(param='foo'):
vol1 = PipelineVolume(pvc="foo")
vol2 = PipelineVolume(name="provided", pvc="foo")
name1 = ("pvolume-2013e9b95c192eb6a2c7d5a023ebeb51f6a114486e31216e"
"083a563")
name1 = ("pvolume-127ac63cf2013e9b95c192eb6a2c7d5a023ebeb51f6a1144"
"86e3121")
name2 = "provided"
self.assertEqual(vol1.name, name1)
self.assertEqual(vol2.name, name2)
Expand Down

0 comments on commit f9bf52a

Please sign in to comment.