Skip to content

Commit

Permalink
keep error when no subworkflows installed but allow it when linting a…
Browse files Browse the repository at this point in the history
… pipeline
  • Loading branch information
mirpedrol committed Jan 24, 2024
1 parent b9740ac commit af40445
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 12 deletions.
5 changes: 4 additions & 1 deletion nf_core/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -613,7 +613,10 @@ def lint(
json,
ctx.obj["hide_progress"],
)
if len(lint_obj.failed) + len(module_lint_obj.failed) + len(subworkflow_lint_obj.failed) > 0:
swf_failed = 0
if subworkflow_lint_obj is not None:
swf_failed = len(subworkflow_lint_obj.failed)
if len(lint_obj.failed) + len(module_lint_obj.failed) + swf_failed > 0:
sys.exit(1)
except AssertionError as e:
log.critical(e)
Expand Down
4 changes: 3 additions & 1 deletion nf_core/components/lint/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,9 @@ def __init__(
)
)
if not self.all_remote_components:
log.warning(f"No {self.component_type} from {self.modules_repo.remote_url} installed in pipeline.")
raise LookupError(
f"No {self.component_type} from {self.modules_repo.remote_url} installed in pipeline."
)
local_component_dir = Path(self.dir, self.component_type, "local")
self.all_local_components = []
if local_component_dir.exists():
Expand Down
20 changes: 13 additions & 7 deletions nf_core/lint/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,10 @@ def run_linting(
# Create the modules lint object
module_lint_obj = nf_core.modules.lint.ModuleLint(pipeline_dir, hide_progress=hide_progress)
# Create the subworkflows lint object
subworkflow_lint_obj = nf_core.subworkflows.lint.SubworkflowLint(pipeline_dir, hide_progress=hide_progress)
try:
subworkflow_lint_obj = nf_core.subworkflows.lint.SubworkflowLint(pipeline_dir, hide_progress=hide_progress)
except LookupError:
subworkflow_lint_obj = None

# Verify that the pipeline is correctly configured and has a modules.json file
module_lint_obj.has_valid_directory()
Expand All @@ -114,7 +117,8 @@ def run_linting(
module_lint_tests = ("module_changes", "module_version")
subworkflow_lint_tests = ("subworkflow_changes", "subworkflow_version")
module_lint_obj.filter_tests_by_key(module_lint_tests)
subworkflow_lint_obj.filter_tests_by_key(subworkflow_lint_tests)
if subworkflow_lint_obj is not None:
subworkflow_lint_obj.filter_tests_by_key(subworkflow_lint_tests)

# Set up files for modules linting test
module_lint_obj.set_up_pipeline_files()
Expand All @@ -133,15 +137,17 @@ def run_linting(
if len(module_lint_obj.all_remote_components) > 0:
module_lint_obj.lint_modules(module_lint_obj.all_remote_components, local=False)
# Run the subworkflows lint tests
if len(subworkflow_lint_obj.all_local_components) > 0:
subworkflow_lint_obj.lint_subworkflows(subworkflow_lint_obj.all_local_components, local=True)
if len(subworkflow_lint_obj.all_remote_components) > 0:
subworkflow_lint_obj.lint_subworkflows(subworkflow_lint_obj.all_remote_components, local=False)
if subworkflow_lint_obj is not None:
if len(subworkflow_lint_obj.all_local_components) > 0:
subworkflow_lint_obj.lint_subworkflows(subworkflow_lint_obj.all_local_components, local=True)
if len(subworkflow_lint_obj.all_remote_components) > 0:
subworkflow_lint_obj.lint_subworkflows(subworkflow_lint_obj.all_remote_components, local=False)

# Print the results
lint_obj._print_results(show_passed)
module_lint_obj._print_results(show_passed, sort_by=sort_by)
subworkflow_lint_obj._print_results(show_passed, sort_by=sort_by)
if subworkflow_lint_obj is not None:
subworkflow_lint_obj._print_results(show_passed, sort_by=sort_by)
nf_core.lint_utils.print_joint_summary(lint_obj, module_lint_obj, subworkflow_lint_obj)
nf_core.lint_utils.print_fixes(lint_obj)

Expand Down
13 changes: 10 additions & 3 deletions nf_core/lint_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,18 @@

def print_joint_summary(lint_obj, module_lint_obj, subworkflow_lint_obj):
"""Print a joint summary of the general pipe lint tests and the module and subworkflow lint tests"""
nbr_passed = len(lint_obj.passed) + len(module_lint_obj.passed) + len(subworkflow_lint_obj.passed)
swf_passed = 0
swf_warned = 0
swf_failed = 0
if subworkflow_lint_obj is not None:
swf_passed = len(subworkflow_lint_obj.passed)
swf_warned = len(subworkflow_lint_obj.warned)
swf_failed = len(subworkflow_lint_obj.failed)
nbr_passed = len(lint_obj.passed) + len(module_lint_obj.passed) + swf_passed
nbr_ignored = len(lint_obj.ignored)
nbr_fixed = len(lint_obj.fixed)
nbr_warned = len(lint_obj.warned) + len(module_lint_obj.warned) + len(subworkflow_lint_obj.warned)
nbr_failed = len(lint_obj.failed) + len(module_lint_obj.failed) + len(subworkflow_lint_obj.failed)
nbr_warned = len(lint_obj.warned) + len(module_lint_obj.warned) + swf_warned
nbr_failed = len(lint_obj.failed) + len(module_lint_obj.failed) + swf_failed

summary_colour = "red" if nbr_failed > 0 else "green"
table = Table(box=rich.box.ROUNDED, style=summary_colour)
Expand Down

0 comments on commit af40445

Please sign in to comment.