From ba7eaf21f6d8e3af51f81ad29ec3e1ef66403dea Mon Sep 17 00:00:00 2001 From: Phil Ewels Date: Fri, 23 Feb 2024 09:42:47 +0100 Subject: [PATCH] 10 minute hack to try to parse proper input structure from module processes, for meta.yml --- nf_core/components/nfcore_component.py | 30 ++++++++++++++++++-------- nf_core/modules/lint/meta_yml.py | 2 ++ 2 files changed, 23 insertions(+), 9 deletions(-) diff --git a/nf_core/components/nfcore_component.py b/nf_core/components/nfcore_component.py index 2f73afe9d3..f8c277a7a4 100644 --- a/nf_core/components/nfcore_component.py +++ b/nf_core/components/nfcore_component.py @@ -166,15 +166,27 @@ def get_inputs_from_main_nf(self): log.info(f"Could not find any inputs in {self.main_nf}") return inputs input_data = data.split("input:")[1].split("output:")[0] - regex = r"(val|path)\s*(\(([^)]+)\)|\s*([^)\s,]+))" - matches = re.finditer(regex, input_data, re.MULTILINE) - for _, match in enumerate(matches, start=1): - if match.group(3): - input_val = match.group(3).split(",")[0] # handle `files, stageAs: "inputs/*"` cases - inputs.append(input_val) - elif match.group(4): - input_val = match.group(4).split(",")[0] # handle `files, stageAs: "inputs/*"` cases - inputs.append(input_val) + for line in input_data.split("\n"): + theseinputs = [] + regex = r"(val|path)\s*(\(([^)]+)\)|\s*([^)\s,]+))" + matches = re.finditer(regex, line) + for _, match in enumerate(matches, start=1): + input_type = None + input_val = None + if match.group(1): + input_type = match.group(1) + if match.group(3): + input_val = match.group(3).split(",")[0] # handle `files, stageAs: "inputs/*"` cases + elif match.group(4): + input_val = match.group(4).split(",")[0] # handle `files, stageAs: "inputs/*"` cases + if input_type and input_val: + theseinputs.append({ + input_val: { + "type": input_type + } + }) + if len(theseinputs) > 0: + inputs.append(theseinputs) log.info(f"Found {len(inputs)} inputs in {self.main_nf}") self.inputs = inputs diff --git a/nf_core/modules/lint/meta_yml.py b/nf_core/modules/lint/meta_yml.py index 481d50b3ef..6718ed5c21 100644 --- a/nf_core/modules/lint/meta_yml.py +++ b/nf_core/modules/lint/meta_yml.py @@ -40,6 +40,8 @@ def meta_yml(module_lint_object: ComponentLint, module: NFCoreComponent) -> None """ module.get_inputs_from_main_nf() + print(yaml.dump({"input": module.inputs})) + exit() module.get_outputs_from_main_nf() # Check if we have a patch file, get original file in that case meta_yaml = None