Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Modules: Add --profile parameter to nf-test command #2767

Merged
merged 7 commits into from
Feb 19, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
add profile parameter to nf-test command
fixes #2753
mashehu committed Feb 16, 2024
commit d9f8443eac2421042144d3a7d1fe7d953a7cd284
20 changes: 18 additions & 2 deletions nf_core/__main__.py
Original file line number Diff line number Diff line change
@@ -1134,7 +1134,14 @@ def create_module(
default=False,
help="Run tests only once. Don't check snapshot stability",
)
def test_module(ctx, tool, dir, no_prompts, update, once):
@click.option(
"--profile",
type=str,
default=None,
help="Run tests with a specific profile",
options=["docker", "singularity", "conda"],
)
def test_module(ctx, tool, dir, no_prompts, update, once, profile):
"""
Run nf-test for a module.

@@ -1153,6 +1160,7 @@ def test_module(ctx, tool, dir, no_prompts, update, once):
remote_url=ctx.obj["modules_repo_url"],
branch=ctx.obj["modules_repo_branch"],
verbose=ctx.obj["verbose"],
profile=profile,
)
module_tester.run()
except (UserWarning, LookupError) as e:
@@ -1398,7 +1406,14 @@ def create_subworkflow(ctx, subworkflow, dir, author, force, migrate_pytest):
default=False,
help="Run tests only once. Don't check snapshot stability",
)
def test_subworkflow(ctx, subworkflow, dir, no_prompts, update, once):
@click.option(
"--profile",
type=str,
default=None,
help="Run tests with a specific profile",
options=["docker", "singularity", "conda"],
)
def test_subworkflow(ctx, subworkflow, dir, no_prompts, update, once, profile):
"""
Run nf-test for a subworkflow.

@@ -1417,6 +1432,7 @@ def test_subworkflow(ctx, subworkflow, dir, no_prompts, update, once):
remote_url=ctx.obj["modules_repo_url"],
branch=ctx.obj["modules_repo_branch"],
verbose=ctx.obj["verbose"],
profile=profile,
)
sw_tester.run()
except (UserWarning, LookupError) as e:
7 changes: 6 additions & 1 deletion nf_core/components/components_test.py
Original file line number Diff line number Diff line change
@@ -48,6 +48,8 @@ class ComponentsTest(ComponentCommand): # type: ignore[misc]
flag indicating if the existing snapshot should be updated
once : bool
flag indicating if the test should be run only once
profile : str
container software to use (docker, singularity or conda)

Methods
-------
@@ -72,6 +74,7 @@ def __init__(
verbose: bool = False,
update: bool = False,
once: bool = False,
profile: Optional[str] = None,
):
super().__init__(component_type, directory, remote_url, branch, no_prompts=no_prompts)
self.component_name = component_name
@@ -82,6 +85,7 @@ def __init__(
self.obsolete_snapshots: bool = False
self.update = update
self.once = once
self.profile = profile

def run(self) -> None:
"""Run build steps"""
@@ -190,10 +194,11 @@ def generate_snapshot(self) -> bool:
update = "--update-snapshot" if self.update else ""
self.update = False # reset self.update to False to test if the new snapshot is stable
tag = f"subworkflows/{self.component_name}" if self.component_type == "subworkflows" else self.component_name
profile = self.profile if self.profile else os.environ["PROFILE"]

result = nf_core.utils.run_cmd(
"nf-test",
f"test --tag {tag} --profile {os.environ['PROFILE']} {verbose} {update}",
f"test --tag {tag} --profile {profile} {verbose} {update}",
)
if result is not None:
nftest_out, nftest_err = result