Skip to content

Commit 050ed61

Browse files
authored
fix: make doctor fix for workflow ids also update oid and derived_from (#3723)
* fix(cli): fix the doctor fix for plan ids to reassign oid's * allow overriding renku lock path * also fix derived from
1 parent ec72507 commit 050ed61

File tree

2 files changed

+29
-3
lines changed

2 files changed

+29
-3
lines changed

renku/command/checks/workflow.py

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
# See the License for the specific language governing permissions and
1515
# limitations under the License.
1616
"""Checks needed to determine integrity of workflows."""
17+
1718
from datetime import timedelta
1819
from typing import List, Optional, Tuple, cast
1920

@@ -145,14 +146,17 @@ def check_plan_id(fix, plan_gateway: IPlanGateway, **_) -> Tuple[bool, bool, Opt
145146
plans: List[AbstractPlan] = plan_gateway.get_all_plans()
146147

147148
to_be_processed = []
149+
to_be_processed_derived = []
148150
for plan in plans:
149151
if isinstance(plan.id, str) and plan.id.startswith("/plans//plans"):
150152
to_be_processed.append(plan)
153+
if isinstance(plan.derived_from, str) and plan.derived_from.startswith("/plans//plans"):
154+
to_be_processed_derived.append(plan)
151155

152-
if not to_be_processed:
156+
if not to_be_processed and not to_be_processed_derived:
153157
return True, False, None
154158
if not fix:
155-
ids = [plan.id for plan in to_be_processed]
159+
ids = [plan.id for plan in to_be_processed + to_be_processed_derived]
156160
message = (
157161
WARNING
158162
+ "The following workflows have incorrect IDs (use 'renku doctor --fix' to fix them):\n\t"
@@ -163,7 +167,17 @@ def check_plan_id(fix, plan_gateway: IPlanGateway, **_) -> Tuple[bool, bool, Opt
163167
for plan in to_be_processed:
164168
plan.unfreeze()
165169
plan.id = plan.id.replace("//plans/", "/")
170+
plan.reassign_oid()
171+
plan._p_changed = True
166172
plan.freeze()
173+
174+
for plan in to_be_processed_derived:
175+
if plan.derived_from is not None:
176+
plan.unfreeze()
177+
plan.derived_from = plan.derived_from.replace("//plans/", "/")
178+
plan._p_changed = True
179+
plan.freeze()
180+
167181
project_context.database.commit()
168182
communication.info("Workflow IDs were fixed")
169183

renku/core/config.py

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
import configparser
1919
import os
2020
from io import StringIO
21+
from pathlib import Path
2122

2223
from renku.core.constant import DATA_DIR_CONFIG_KEY
2324
from renku.domain_model.enums import ConfigFilter
@@ -28,13 +29,21 @@ def global_config_read_lock():
2829
"""Create a user-level config read lock."""
2930
from renku.core.util.contexts import Lock
3031

32+
lock_path = os.environ.get("RENKU_LOCK_PATH")
33+
if lock_path is not None:
34+
return Lock(Path(lock_path))
35+
3136
return Lock(project_context.global_config_path)
3237

3338

3439
def global_config_write_lock():
3540
"""Create a user-level config write lock."""
3641
from renku.core.util.contexts import Lock
3742

43+
lock_path = os.environ.get("RENKU_LOCK_PATH")
44+
if lock_path is not None:
45+
return Lock(Path(lock_path), mode="exclusive")
46+
3847
return Lock(project_context.global_config_path, mode="exclusive")
3948

4049

@@ -112,7 +121,10 @@ def load_config(config_filter=ConfigFilter.ALL):
112121
elif config_filter == ConfigFilter.GLOBAL_ONLY:
113122
config_files += [project_context.global_config_path]
114123
elif config_filter == ConfigFilter.ALL:
115-
config_files += [project_context.global_config_path, project_context.local_config_path]
124+
config_files += [
125+
project_context.global_config_path,
126+
project_context.local_config_path,
127+
]
116128

117129
if config_filter != ConfigFilter.LOCAL_ONLY:
118130
with global_config_read_lock():

0 commit comments

Comments
 (0)