From 13e6becc60e49809dd369e62083762fc7b81c9aa Mon Sep 17 00:00:00 2001 From: Ralf Grubenmann Date: Fri, 5 Apr 2024 16:07:13 +0200 Subject: [PATCH 1/4] fix(cli): fix the doctor fix for plan ids to reassign oid's --- renku/command/checks/workflow.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/renku/command/checks/workflow.py b/renku/command/checks/workflow.py index 1f3bed770f..2d329eb70e 100644 --- a/renku/command/checks/workflow.py +++ b/renku/command/checks/workflow.py @@ -14,6 +14,7 @@ # See the License for the specific language governing permissions and # limitations under the License. """Checks needed to determine integrity of workflows.""" + from datetime import timedelta from typing import List, Optional, Tuple, cast @@ -163,6 +164,7 @@ def check_plan_id(fix, plan_gateway: IPlanGateway, **_) -> Tuple[bool, bool, Opt for plan in to_be_processed: plan.unfreeze() plan.id = plan.id.replace("//plans/", "/") + plan.reassign_oid() plan.freeze() project_context.database.commit() communication.info("Workflow IDs were fixed") From a87f885a839552ad21cc570d1b01773763489f10 Mon Sep 17 00:00:00 2001 From: Ralf Grubenmann Date: Fri, 5 Apr 2024 19:18:24 +0200 Subject: [PATCH 2/4] allow overriding renku lock path --- renku/core/config.py | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/renku/core/config.py b/renku/core/config.py index 899676113b..1e9d742240 100644 --- a/renku/core/config.py +++ b/renku/core/config.py @@ -18,6 +18,7 @@ import configparser import os from io import StringIO +from pathlib import Path from renku.core.constant import DATA_DIR_CONFIG_KEY from renku.domain_model.enums import ConfigFilter @@ -28,6 +29,10 @@ def global_config_read_lock(): """Create a user-level config read lock.""" from renku.core.util.contexts import Lock + lock_path = os.environ.get("RENKU_LOCK_PATH") + if lock_path is not None: + return Lock(Path(lock_path)) + return Lock(project_context.global_config_path) @@ -35,6 +40,10 @@ def global_config_write_lock(): """Create a user-level config write lock.""" from renku.core.util.contexts import Lock + lock_path = os.environ.get("RENKU_LOCK_PATH") + if lock_path is not None: + return Lock(Path(lock_path), mode="exclusive") + return Lock(project_context.global_config_path, mode="exclusive") @@ -112,7 +121,10 @@ def load_config(config_filter=ConfigFilter.ALL): elif config_filter == ConfigFilter.GLOBAL_ONLY: config_files += [project_context.global_config_path] elif config_filter == ConfigFilter.ALL: - config_files += [project_context.global_config_path, project_context.local_config_path] + config_files += [ + project_context.global_config_path, + project_context.local_config_path, + ] if config_filter != ConfigFilter.LOCAL_ONLY: with global_config_read_lock(): From 1013907390181778892675fe2dd31973715e8868 Mon Sep 17 00:00:00 2001 From: Ralf Grubenmann Date: Fri, 5 Apr 2024 19:25:00 +0200 Subject: [PATCH 3/4] force changed --- renku/command/checks/workflow.py | 1 + 1 file changed, 1 insertion(+) diff --git a/renku/command/checks/workflow.py b/renku/command/checks/workflow.py index 2d329eb70e..322b710261 100644 --- a/renku/command/checks/workflow.py +++ b/renku/command/checks/workflow.py @@ -165,6 +165,7 @@ def check_plan_id(fix, plan_gateway: IPlanGateway, **_) -> Tuple[bool, bool, Opt plan.unfreeze() plan.id = plan.id.replace("//plans/", "/") plan.reassign_oid() + plan._p_changed = True plan.freeze() project_context.database.commit() communication.info("Workflow IDs were fixed") From ff09688c20682655e2eb0e3a1d6ad85193b5ffe8 Mon Sep 17 00:00:00 2001 From: Ralf Grubenmann Date: Mon, 8 Apr 2024 09:22:09 +0200 Subject: [PATCH 4/4] also fix derived from --- renku/command/checks/workflow.py | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/renku/command/checks/workflow.py b/renku/command/checks/workflow.py index 322b710261..10dcbe9d41 100644 --- a/renku/command/checks/workflow.py +++ b/renku/command/checks/workflow.py @@ -146,14 +146,17 @@ def check_plan_id(fix, plan_gateway: IPlanGateway, **_) -> Tuple[bool, bool, Opt plans: List[AbstractPlan] = plan_gateway.get_all_plans() to_be_processed = [] + to_be_processed_derived = [] for plan in plans: if isinstance(plan.id, str) and plan.id.startswith("/plans//plans"): to_be_processed.append(plan) + if isinstance(plan.derived_from, str) and plan.derived_from.startswith("/plans//plans"): + to_be_processed_derived.append(plan) - if not to_be_processed: + if not to_be_processed and not to_be_processed_derived: return True, False, None if not fix: - ids = [plan.id for plan in to_be_processed] + ids = [plan.id for plan in to_be_processed + to_be_processed_derived] message = ( WARNING + "The following workflows have incorrect IDs (use 'renku doctor --fix' to fix them):\n\t" @@ -167,6 +170,14 @@ def check_plan_id(fix, plan_gateway: IPlanGateway, **_) -> Tuple[bool, bool, Opt plan.reassign_oid() plan._p_changed = True plan.freeze() + + for plan in to_be_processed_derived: + if plan.derived_from is not None: + plan.unfreeze() + plan.derived_from = plan.derived_from.replace("//plans/", "/") + plan._p_changed = True + plan.freeze() + project_context.database.commit() communication.info("Workflow IDs were fixed")