Skip to content

Commit

Permalink
10 minute hack to try to parse proper input structure from module pro…
Browse files Browse the repository at this point in the history
…cesses, for meta.yml
  • Loading branch information
ewels committed Feb 23, 2024
1 parent ec13bfd commit ba7eaf2
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 9 deletions.
30 changes: 21 additions & 9 deletions nf_core/components/nfcore_component.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 2 additions & 0 deletions nf_core/modules/lint/meta_yml.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit ba7eaf2

Please sign in to comment.