Skip to content

Commit a100c54

Browse files
author
Ralf Grubenmann
committed
make Run migration ids unique by relative path instead of absolute
1 parent dae968c commit a100c54

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

renku/core/management/migrations/m_0005__2_cwl.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
import os
2222
import uuid
2323
from functools import cmp_to_key
24-
from hashlib import sha256
24+
from hashlib import sha1
2525
from pathlib import Path
2626

2727
from cwlgen import CommandLineTool, parse_cwl
@@ -124,11 +124,12 @@ def _migrate_single_step(client, cmd_line_tool, path, commit=None, parent_commit
124124
outputs = list(cmd_line_tool.outputs)
125125

126126
# NOTE: Make run ids deterministic to prevent duplication.
127+
rel_path = Path(path).relative_to(client.path)
127128
if parent_commit:
128-
label = f"{path}@{parent_commit.hexsha}"
129+
label = f"{rel_path}@{parent_commit.hexsha}"
129130
else:
130-
label = f"{path}@{commit.hexsha}"
131-
identifier = sha256(label.encode("utf-8")).hexdigest()
131+
label = f"{rel_path}@{commit.hexsha}"
132+
identifier = sha1(label.encode("utf-8")).hexdigest()
132133

133134
base_id = Run.generate_id(client, identifier=identifier)
134135
run._id = base_id
@@ -305,9 +306,9 @@ def _migrate_composite_step(client, workflow, path, commit=None):
305306
if not commit:
306307
commit = client.find_previous_commit(path)
307308
run = Run(client=client, path=path, commit=commit)
308-
309-
label = f"{path}@{commit.hexsha}"
310-
identifier = sha256(label.encode("utf-8")).hexdigest()
309+
rel_path = Path(path).relative_to(client.path)
310+
label = f"{rel_path}@{commit.hexsha}"
311+
identifier = sha1(label.encode("utf-8")).hexdigest()
311312
run._id = Run.generate_id(client, identifier=identifier)
312313

313314
name = "{0}_migrated.yaml".format(uuid.uuid4().hex)

0 commit comments

Comments
 (0)