From 5840a9aa11378a028504e09edd91322c53b0b2cb Mon Sep 17 00:00:00 2001 From: Fabian Neumann Date: Mon, 12 Feb 2024 12:17:13 +0100 Subject: [PATCH 1/3] remove inefficient _helper.py file search --- rules/common.smk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rules/common.smk b/rules/common.smk index 5aa7ae53..4c6cc7c2 100644 --- a/rules/common.smk +++ b/rules/common.smk @@ -4,7 +4,7 @@ import os, sys, glob -helper_source_path = [match for match in glob.glob("**/_helpers.py", recursive=True)] +helper_source_path = workflow.source_path("scripts/_helpers.py") for path in helper_source_path: path = os.path.dirname(os.path.abspath(path)) From 1e5163b66bc5cd3d67f3b7b84b7997ebf2d3a5be Mon Sep 17 00:00:00 2001 From: Fabian Neumann Date: Mon, 12 Feb 2024 13:45:42 +0100 Subject: [PATCH 2/3] alternative approach --- rules/common.smk | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/rules/common.smk b/rules/common.smk index 4c6cc7c2..50132f4b 100644 --- a/rules/common.smk +++ b/rules/common.smk @@ -4,11 +4,8 @@ import os, sys, glob -helper_source_path = workflow.source_path("scripts/_helpers.py") - -for path in helper_source_path: - path = os.path.dirname(os.path.abspath(path)) - sys.path.insert(0, os.path.abspath(path)) +for path in ["../scripts", "./scripts"]: + sys.path.insert(0, os.path.abspath(path) from _helpers import validate_checksum From fa931cc2b102ebd8a7241e0e0aba8bd8281e1eb5 Mon Sep 17 00:00:00 2001 From: Fabian Neumann Date: Mon, 12 Feb 2024 13:54:28 +0100 Subject: [PATCH 3/3] alternative approach 2 --- rules/common.smk | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/rules/common.smk b/rules/common.smk index 50132f4b..598d3b98 100644 --- a/rules/common.smk +++ b/rules/common.smk @@ -4,8 +4,8 @@ import os, sys, glob -for path in ["../scripts", "./scripts"]: - sys.path.insert(0, os.path.abspath(path) +path = workflow.source_path("../scripts/_helpers.py") +sys.path.insert(0, os.path.dirname(path)) from _helpers import validate_checksum