Skip to content

Commit

Permalink
Add nallo workflow run (#4106)
Browse files Browse the repository at this point in the history
### Added

- cg workflow run nallo
  • Loading branch information
peterpru authored Jan 17, 2025
1 parent 7a7799b commit b36cd1e
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 19 deletions.
3 changes: 2 additions & 1 deletion cg/cli/workflow/nallo/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

from cg.cli.utils import CLICK_CONTEXT_SETTINGS

from cg.cli.workflow.nf_analysis import config_case
from cg.cli.workflow.nf_analysis import config_case, run

from cg.constants.constants import MetaApis
from cg.meta.workflow.analysis import AnalysisAPI
Expand All @@ -24,3 +24,4 @@ def nallo(context: click.Context) -> None:


nallo.add_command(config_case)
nallo.add_command(run)
28 changes: 14 additions & 14 deletions tests/cli/workflow/nf_analysis/test_cli_run.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

@pytest.mark.parametrize(
"workflow",
NEXTFLOW_WORKFLOWS,
NEXTFLOW_WORKFLOWS + [Workflow.NALLO],
)
def test_run_without_options(cli_runner: CliRunner, workflow: Workflow, request: FixtureRequest):
"""Test run command for workflow without options."""
Expand All @@ -35,7 +35,7 @@ def test_run_without_options(cli_runner: CliRunner, workflow: Workflow, request:

@pytest.mark.parametrize(
"workflow",
NEXTFLOW_WORKFLOWS,
NEXTFLOW_WORKFLOWS + [Workflow.NALLO],
)
def test_run_with_missing_case(
cli_runner: CliRunner,
Expand Down Expand Up @@ -64,7 +64,7 @@ def test_run_with_missing_case(

@pytest.mark.parametrize(
"workflow",
NEXTFLOW_WORKFLOWS,
NEXTFLOW_WORKFLOWS + [Workflow.NALLO],
)
def test_run_case_without_samples(
cli_runner: CliRunner,
Expand Down Expand Up @@ -94,7 +94,7 @@ def test_run_case_without_samples(

@pytest.mark.parametrize(
"workflow",
NEXTFLOW_WORKFLOWS,
NEXTFLOW_WORKFLOWS + [Workflow.NALLO],
)
def test_run_case_without_config_files(
cli_runner: CliRunner,
Expand All @@ -121,7 +121,7 @@ def test_run_case_without_config_files(

@pytest.mark.parametrize(
"workflow",
NEXTFLOW_WORKFLOWS,
NEXTFLOW_WORKFLOWS + [Workflow.NALLO],
)
def test_run_case_from_start_dry_run(
cli_runner: CliRunner,
Expand All @@ -137,7 +137,7 @@ def test_run_case_from_start_dry_run(
case_id: str = request.getfixturevalue(f"{workflow}_case_id")

# GIVEN mocked config files
request.getfixturevalue(f"{workflow}_mock_config")
request.getfixturevalue(f"{workflow}_config")

# WHEN invoking a command with dry-run specified
result = cli_runner.invoke(
Expand All @@ -155,7 +155,7 @@ def test_run_case_from_start_dry_run(

@pytest.mark.parametrize(
"workflow",
NEXTFLOW_WORKFLOWS,
NEXTFLOW_WORKFLOWS + [Workflow.NALLO],
)
def test_run_case_with_revision_dry_run(
cli_runner: CliRunner,
Expand All @@ -171,7 +171,7 @@ def test_run_case_with_revision_dry_run(
case_id: str = request.getfixturevalue(f"{workflow}_case_id")

# GIVEN a mocked config
request.getfixturevalue(f"{workflow}_mock_config")
request.getfixturevalue(f"{workflow}_config")

# WHEN invoking a command with dry-run and revision specified
result = cli_runner.invoke(
Expand All @@ -189,7 +189,7 @@ def test_run_case_with_revision_dry_run(

@pytest.mark.parametrize(
"workflow",
NEXTFLOW_WORKFLOWS,
NEXTFLOW_WORKFLOWS + [Workflow.NALLO],
)
def test_resume_case_dry_run(
cli_runner: CliRunner,
Expand All @@ -206,7 +206,7 @@ def test_resume_case_dry_run(
case_id: str = request.getfixturevalue(f"{workflow}_case_id")

# GIVEN a mocked config
# request.getfixturevalue(f"{workflow}_mock_config")
# request.getfixturevalue(f"{workflow}_config")

# WHEN invoking a command with dry-run and nf-tower-id specified
result = cli_runner.invoke(
Expand All @@ -225,13 +225,13 @@ def test_resume_case_dry_run(

@pytest.mark.parametrize(
"workflow",
NEXTFLOW_WORKFLOWS,
NEXTFLOW_WORKFLOWS + [Workflow.NALLO],
)
def test_resume_case_with_missing_tower_id(
cli_runner: CliRunner,
workflow: Workflow,
caplog: LogCaptureFixture,
raredisease_mock_config,
raredisease_config,
request: FixtureRequest,
):
"""Test resume command without providing NF-Tower ID and without existing Trailblazer config file."""
Expand All @@ -253,13 +253,13 @@ def test_resume_case_with_missing_tower_id(

@pytest.mark.parametrize(
"workflow",
NEXTFLOW_WORKFLOWS,
NEXTFLOW_WORKFLOWS + [Workflow.NALLO],
)
def test_resume_using_nextflow_dry_run(
cli_runner: CliRunner,
workflow: Workflow,
caplog: LogCaptureFixture,
raredisease_mock_config,
raredisease_config,
request: FixtureRequest,
):
"""Test command with case_id and config file using nextflow."""
Expand Down
17 changes: 13 additions & 4 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -2603,6 +2603,15 @@ def nallo_dir(tmpdir_factory, apps_dir: Path) -> str:
return Path(nallo_dir).absolute().as_posix()


@pytest.fixture(scope="function")
def nallo_config(nallo_dir: Path, nallo_case_id: str) -> None:
"""Create Nallo samplesheet.csv file for testing"""
Path.mkdir(Path(nallo_dir, nallo_case_id), parents=True, exist_ok=True)
Path(nallo_dir, nallo_case_id, f"{nallo_case_id}_samplesheet").with_suffix(
FileExtensions.CSV
).touch(exist_ok=True)


@pytest.fixture(scope="function")
def nallo_nexflow_config_file_path(nallo_dir, nallo_case_id) -> Path:
"""Path to config file."""
Expand Down Expand Up @@ -2912,7 +2921,7 @@ def mock_deliverable(


@pytest.fixture(scope="function")
def raredisease_mock_config(raredisease_dir: Path, raredisease_case_id: str) -> None:
def raredisease_config(raredisease_dir: Path, raredisease_case_id: str) -> None:
"""Create samplesheet.csv file for testing"""
Path.mkdir(Path(raredisease_dir, raredisease_case_id), parents=True, exist_ok=True)
Path(raredisease_dir, raredisease_case_id, f"{raredisease_case_id}_samplesheet").with_suffix(
Expand Down Expand Up @@ -3434,7 +3443,7 @@ def rnafusion_mock_analysis_finish(


@pytest.fixture(scope="function")
def rnafusion_mock_config(rnafusion_dir: Path, rnafusion_case_id: str) -> None:
def rnafusion_config(rnafusion_dir: Path, rnafusion_case_id: str) -> None:
"""Create samplesheet.csv file for testing"""
Path.mkdir(Path(rnafusion_dir, rnafusion_case_id), parents=True, exist_ok=True)
Path(rnafusion_dir, rnafusion_case_id, f"{rnafusion_case_id}_samplesheet.csv").with_suffix(
Expand Down Expand Up @@ -3487,7 +3496,7 @@ def tomte_gene_panel_path(tomte_dir, tomte_case_id) -> Path:


@pytest.fixture(scope="function")
def tomte_mock_config(tomte_dir: Path, tomte_case_id: str) -> None:
def tomte_config(tomte_dir: Path, tomte_case_id: str) -> None:
"""Create Tomte samplesheet.csv file for testing."""
Path.mkdir(Path(tomte_dir, tomte_case_id), parents=True, exist_ok=True)
Path(tomte_dir, tomte_case_id, f"{tomte_case_id}_samplesheet").with_suffix(
Expand Down Expand Up @@ -4093,7 +4102,7 @@ def taxprofiler_mock_analysis_finish(


@pytest.fixture(scope="function")
def taxprofiler_mock_config(taxprofiler_dir: Path, taxprofiler_case_id: str) -> None:
def taxprofiler_config(taxprofiler_dir: Path, taxprofiler_case_id: str) -> None:
"""Create CSV sample sheet file for testing."""
Path.mkdir(Path(taxprofiler_dir, taxprofiler_case_id), parents=True, exist_ok=True)
Path(taxprofiler_dir, taxprofiler_case_id, f"{taxprofiler_case_id}_samplesheet").with_suffix(
Expand Down

0 comments on commit b36cd1e

Please sign in to comment.