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

Migrate component create to nf test #2490

Merged
merged 119 commits into from
Nov 21, 2023
Merged
Show file tree
Hide file tree
Changes from 95 commits
Commits
Show all changes
119 commits
Select commit Hold shift + click to select a range
5283677
generalize nextflow_cmd to run_cmd to use the same structure for nf-test
mashehu Oct 24, 2023
0081766
initial changes for nf-test
mashehu Oct 24, 2023
d9126e5
move tags.yml to correct position
mashehu Oct 24, 2023
ecda687
Update nf_core/utils.py
mashehu Oct 24, 2023
955321b
convert all cmds
mashehu Oct 24, 2023
0a4afac
first running version
mashehu Oct 24, 2023
ca233d1
Merge branch 'migrate-component-create-to-nf_test' of github.com:mash…
mashehu Oct 24, 2023
86613b6
replace params
mashehu Oct 24, 2023
e0c30cd
fix typing errors
mashehu Oct 24, 2023
a9f55ba
add TODO comments to main.nf.test and fix tags.yml template rendering
mirpedrol Oct 25, 2023
865d613
add todo comment for chained modules
mirpedrol Oct 25, 2023
d767c78
add real example to main.nf.test
mirpedrol Oct 26, 2023
876eab3
add tags.yml to prettierignore
mirpedrol Oct 26, 2023
3b9f031
add main.nf.test to template instead of using nf-test
mirpedrol Oct 26, 2023
79215fb
generalize nextflow_cmd to run_cmd to use the same structure for nf-test
mashehu Oct 24, 2023
7cab286
initial changes for nf-test
mashehu Oct 24, 2023
f41d410
move tags.yml to correct position
mashehu Oct 24, 2023
cbc398a
convert all cmds
mashehu Oct 24, 2023
8d7794a
first running version
mashehu Oct 24, 2023
1a58690
replace params
mashehu Oct 24, 2023
86db72b
fix typing errors
mashehu Oct 24, 2023
7a7fd93
add TODO comments to main.nf.test and fix tags.yml template rendering
mirpedrol Oct 25, 2023
11773ef
add todo comment for chained modules
mirpedrol Oct 25, 2023
eafb3b5
add real example to main.nf.test
mirpedrol Oct 26, 2023
56086c6
add tags.yml to prettierignore
mirpedrol Oct 26, 2023
63c3188
add main.nf.test to template instead of using nf-test
mirpedrol Oct 26, 2023
4038131
modules create tests check for main.nf.test
mirpedrol Oct 31, 2023
43bf218
remove outputDir from the modules template
mirpedrol Oct 31, 2023
4ffc3cf
add nf-test to subworkflows
mirpedrol Oct 31, 2023
db10253
subworkflows create tests check for main.nf.test
mirpedrol Oct 31, 2023
a3eae4d
Merge branch 'migrate-component-create-to-nf_test' of https://github.…
mirpedrol Oct 31, 2023
80ddddb
fix tags for subtools, add version assertion to template
mashehu Nov 1, 2023
617010e
fix quotes in templates
mashehu Nov 1, 2023
04efb40
add first version of the `create-snapshot` command
mashehu Nov 1, 2023
71c441c
install all type specific dependencies in CI step
mashehu Nov 1, 2023
a7cfdd5
add new command 🙃
mashehu Nov 2, 2023
d6b9f6c
remove tests for modules create_test_yml
mashehu Nov 2, 2023
6b0ff49
remove more mentions of test_yml_builder
mashehu Nov 2, 2023
0045d4d
add types to create-snapshot and use component_type
mirpedrol Nov 2, 2023
61459f5
add subworkflows create-snapshot
mirpedrol Nov 2, 2023
6b63566
add linting for snapshot file
mashehu Nov 6, 2023
73487dd
add correct tags to subworkflow template
mashehu Nov 6, 2023
cdf5f63
fix smaller things according to mypy
mashehu Nov 6, 2023
a1743cd
Merge branch 'migrate-component-create-to-nf_test' of github.com:mash…
mashehu Nov 6, 2023
bff7e89
add pytests for components snapshot generator
mirpedrol Nov 7, 2023
2f5312a
add more typing
mashehu Nov 7, 2023
ef52c75
Merge branch 'migrate-component-create-to-nf_test' of github.com:mash…
mashehu Nov 7, 2023
f42fe20
run create-snapshot tests from modules root directory
mirpedrol Nov 7, 2023
6ef6268
Merge branch 'migrate-component-create-to-nf_test' of github.com:mash…
mashehu Nov 7, 2023
e79d4d3
fix checking if PROFILE exists
mirpedrol Nov 7, 2023
c7bc5b7
add new environment.yml setup to template according to #2495
mashehu Nov 8, 2023
3f46c16
Merge branch 'migrate-component-create-to-nf_test' of github.com:mash…
mashehu Nov 8, 2023
53b23b7
use set_wd for tests
mirpedrol Nov 8, 2023
c4683f0
check md5sums and add snapshot test for a subworkflow
mirpedrol Nov 8, 2023
2a640cc
append error messages to self.errors
mashehu Nov 8, 2023
fa0c6f3
add --dir option to create-snapshot command
mirpedrol Nov 8, 2023
f5ddc64
add no test found error and test for this
mirpedrol Nov 9, 2023
163019d
add test for unstable snapshot
mirpedrol Nov 9, 2023
8ebf36a
don't assert run() function from snapshot generator
mirpedrol Nov 9, 2023
749ba53
Update tests/components/create_snapshot.py
mirpedrol Nov 9, 2023
b1b57d3
add linting code for environemnt.yml
mashehu Nov 13, 2023
5aad9c4
add hint for language server, update to new new for schema file
mashehu Nov 13, 2023
aaa5945
add types
mashehu Nov 13, 2023
9fe1c3e
add schema based validation to environment yaml linting, add tests
mashehu Nov 13, 2023
92fd677
Merge branch 'dev' into migrate-component-create-to-nf_test
mashehu Nov 13, 2023
2d51ff8
fix mypy
mashehu Nov 13, 2023
74139bd
Merge branch 'migrate-component-create-to-nf_test' of github.com:mash…
mashehu Nov 13, 2023
54bb5b6
fix type error
mashehu Nov 13, 2023
28c1c76
add nf-test dependency
mashehu Nov 13, 2023
dc7a330
install nf-test for ci
mashehu Nov 13, 2023
1ce81c0
switch bump_version to use environemt.yml
mashehu Nov 14, 2023
32ef61b
update modules in pipeline template
mashehu Nov 14, 2023
ab113c7
fix test for updated snapshot
mashehu Nov 14, 2023
bec4bb3
test for name mismatch in environment.yml
mashehu Nov 14, 2023
0622fbc
make nicer diff for nf-test error
mashehu Nov 14, 2023
4c30da3
fix error in download test
mashehu Nov 14, 2023
2ca1764
don't convert arrays to strings in licence field
mashehu Nov 14, 2023
6e2dc70
add nf-test to CI
mashehu Nov 14, 2023
cb175e7
fix environment.yml linting
mashehu Nov 14, 2023
38d9db7
rely on environment.yml for bioconda versions
mashehu Nov 14, 2023
91c24e6
fix tests
mashehu Nov 14, 2023
dc6d033
fix types
mashehu Nov 14, 2023
d82bf66
remove subworkflows test_yml_builder and fix subworkflow tests
mirpedrol Nov 15, 2023
24ff636
fix nf-test setup in CI
mashehu Nov 15, 2023
20ae7b1
Merge branch 'migrate-component-create-to-nf_test' of github.com:mash…
mashehu Nov 15, 2023
72a78c0
fix assertion value
mashehu Nov 15, 2023
d687430
handle local modules without nf-test
mashehu Nov 15, 2023
f673a89
add linting for nf-test and remove linting for pytests
mirpedrol Nov 15, 2023
bb070c6
fix linting components errors
mirpedrol Nov 15, 2023
e19a4a2
remove tmp dir manually if we find a PermissionError
mirpedrol Nov 16, 2023
5e02619
fix launch tests, move tmp pipeline creation to utils to share betwee…
mashehu Nov 16, 2023
316055f
Merge branch 'migrate-component-create-to-nf_test' of github.com:mash…
mashehu Nov 16, 2023
7b0683e
fix tests by correcting raised error type
mashehu Nov 16, 2023
22a9071
fix tests, switch to pdiff instead of icdiff, because it handles widt…
mashehu Nov 16, 2023
a8f6332
revert e19a4a250bf7a8a4ebd484f94cc39b324642081f
mirpedrol Nov 16, 2023
5347b56
Apply suggestions from code review
mashehu Nov 16, 2023
fc0a3fc
remove debugging raise introduced by mistake
mirpedrol Nov 16, 2023
d12560d
move create-snapshot command to test command
mirpedrol Nov 20, 2023
300289e
move modules and subworkflows test tests to components
mirpedrol Nov 20, 2023
c254699
add test for generate snapshot once
mirpedrol Nov 20, 2023
bb640bb
update README
mashehu Nov 20, 2023
c550823
Apply suggestions from code review
mashehu Nov 20, 2023
2b15177
fix typing errors
mashehu Nov 20, 2023
8d5550e
Merge branch 'migrate-component-create-to-nf_test' of github.com:mash…
mashehu Nov 20, 2023
f4a48b5
remove last traces of create-snapshot or create-test-yml
mashehu Nov 20, 2023
9f2f905
fix parameters
mashehu Nov 20, 2023
f288520
update changelog
mashehu Nov 20, 2023
7722d52
rename create_snapshot functions and files
mashehu Nov 20, 2023
71c0b08
simplify obsolete check
mashehu Nov 21, 2023
d29643e
add back option to handle pytest based modules in bump_version
mashehu Nov 21, 2023
4d08f6d
rename generator to test to make it hopefully less confusing
mashehu Nov 21, 2023
0c120ab
automatically sort dependencies in environment.yml while linting
mashehu Nov 21, 2023
dc5c7cb
fix types
mashehu Nov 21, 2023
bcf22a1
Merge branch 'migrate-component-create-to-nf_test' of github.com:mash…
mashehu Nov 21, 2023
a5a3fd4
fix typo
mashehu Nov 21, 2023
41b61c1
fix import statement
mashehu Nov 21, 2023
d2df78a
Update nf_core/components/components_test.py
mashehu Nov 21, 2023
75a07c4
remove self.run_tests
mashehu Nov 21, 2023
b4ff558
Merge branch 'migrate-component-create-to-nf_test' of github.com:mash…
mashehu Nov 21, 2023
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
25 changes: 23 additions & 2 deletions .github/workflows/lint-code.yml
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,29 @@ jobs:
- uses: actions/checkout@v2
- uses: actions/setup-python@v3
with:
python-version: "3.11"
- run: pip install mypy types-PyYAML
python-version: 3.11
cache: "pip"

- name: Install dependencies
run: |
python -m pip install --upgrade pip -r requirements-dev.txt
pip install -e .

- name: Cache nf-test installation
id: cache-software
uses: actions/cache@v3
with:
path: |
/usr/local/bin/nf-test
/home/runner/.nf-test/nf-test.jar
key: ${{ runner.os }}-${{ env.NFTEST_VER }}-nftest

- name: Install nf-test
if: steps.cache-software.outputs.cache-hit != 'true'
run: |
wget -qO- https://code.askimed.com/install/nf-test | bash
sudo mv nf-test /usr/local/bin/

- name: Get Python changed files
id: changed-py-files
uses: tj-actions/changed-files@v23
Expand Down
15 changes: 15 additions & 0 deletions .github/workflows/pytest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,21 @@ jobs:
with:
version: "latest-everything"

- name: Cache nf-test installation
id: cache-software
uses: actions/cache@v3
with:
path: |
/usr/local/bin/nf-test
/home/runner/.nf-test/nf-test.jar
key: ${{ runner.os }}-${{ env.NFTEST_VER }}-nftest

- name: Install nf-test
if: steps.cache-software.outputs.cache-hit != 'true'
run: |
wget -qO- https://code.askimed.com/install/nf-test | bash
sudo mv nf-test /usr/local/bin/

- name: Test with pytest
run: python3 -m pytest tests/ --color=yes --cov-report=xml --cov-config=.github/.coveragerc --cov=nf_core

Expand Down
3 changes: 2 additions & 1 deletion .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@ slackreport.json
docs/api/_build
testing
nf_core/module-template/modules/meta.yml
nf_core/module-template/tests/test.yml
nf_core/module-template/modules/tests/tags.yml
mashehu marked this conversation as resolved.
Show resolved Hide resolved
nf_core/subworkflow-template/subworkflows/tests/tags.yml
5 changes: 5 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,11 @@ ENV NXF_VER ${NXF_VER}
RUN curl -s https://get.nextflow.io | bash \
&& mv nextflow /usr/local/bin \
&& chmod a+rx /usr/local/bin/nextflow
# Install nf-test
RUN curl -fsSL https://code.askimed.com/install/nf-test | bash \
&& mv nf-test /usr/local/bin \
&& chmod a+rx /usr/local/bin/nf-test

# Add the nf-core source files to the image
COPY . /usr/src/nf_core
WORKDIR /usr/src/nf_core
Expand Down
73 changes: 40 additions & 33 deletions nf_core/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -652,7 +652,7 @@ def install(ctx, tool, dir, prompt, force, sha):
ctx.obj["modules_repo_no_pull"],
)
exit_status = module_install.install(tool)
if not exit_status and all:
if not exit_status:
sys.exit(1)
except (UserWarning, LookupError) as e:
log.error(e)
Expand All @@ -673,7 +673,9 @@ def install(ctx, tool, dir, prompt, force, sha):
@click.option("-f", "--force", is_flag=True, default=False, help="Force update of module")
@click.option("-p", "--prompt", is_flag=True, default=False, help="Prompt for the version of the module")
@click.option("-s", "--sha", type=str, metavar="<commit sha>", help="Install module at commit SHA")
@click.option("-a", "--all", is_flag=True, default=False, help="Update all modules installed in pipeline")
@click.option(
"-a", "--all", "install_all", is_flag=True, default=False, help="Update all modules installed in pipeline"
)
@click.option(
"-x/-y",
"--preview/--no-preview",
Expand All @@ -696,7 +698,7 @@ def install(ctx, tool, dir, prompt, force, sha):
default=False,
help="Automatically update all linked modules and subworkflows without asking for confirmation",
)
def update(ctx, tool, dir, force, prompt, sha, all, preview, save_diff, update_deps):
def update(ctx, tool, dir, force, prompt, sha, install_all, preview, save_diff, update_deps):
"""
Update DSL2 modules within a pipeline.

Expand All @@ -719,7 +721,7 @@ def update(ctx, tool, dir, force, prompt, sha, all, preview, save_diff, update_d
ctx.obj["modules_repo_no_pull"],
)
exit_status = module_install.update(tool)
if not exit_status and all:
if not exit_status and install_all:
sys.exit(1)
except (UserWarning, LookupError) as e:
log.error(e)
Expand Down Expand Up @@ -849,34 +851,35 @@ def create_module(
sys.exit(1)


# nf-core modules create-test-yml
@modules.command("create-test-yml")
# nf-core modules create-snapshot
@modules.command("create-snapshot")
@click.pass_context
@click.argument("tool", type=str, required=False, metavar="<tool> or <tool/subtool>")
@click.option("-d", "--dir", type=click.Path(exists=True), default=".", metavar="<nf-core/modules directory>")
@click.option("-t", "--run-tests", is_flag=True, default=False, help="Run the test workflows")
@click.option("-o", "--output", type=str, help="Path for output YAML file")
@click.option("-f", "--force", is_flag=True, default=False, help="Overwrite output YAML file if it already exists")
@click.option("-p", "--no-prompts", is_flag=True, default=False, help="Use defaults without prompting")
def create_test_yml(ctx, tool, run_tests, output, force, no_prompts):
@click.option("-u", "--update", is_flag=True, default=False, help="Update existing snapshots")
def create_snapshot(ctx, tool, dir, run_tests, no_prompts, update):
"""
Auto-generate a test.yml file for a new module.
Generate nf-test snapshots for a module.

Given the name of a module, runs the Nextflow test command and automatically generate
the required `test.yml` file based on the output files.
Given the name of a module, runs the nf-test command to generate snapshots.
"""
from nf_core.modules import ModulesTestYmlBuilder
from nf_core.components.snapshot_generator import ComponentTestSnapshotGenerator

try:
meta_builder = ModulesTestYmlBuilder(
module_name=tool,
snap_generator = ComponentTestSnapshotGenerator(
component_type="modules",
component_name=tool,
directory=dir,
run_tests=run_tests,
test_yml_output_path=output,
force_overwrite=force,
no_prompts=no_prompts,
update=update,
remote_url=ctx.obj["modules_repo_url"],
branch=ctx.obj["modules_repo_branch"],
verbose=ctx.obj["verbose"],
)
meta_builder.run()
snap_generator.run()
except (UserWarning, LookupError) as e:
log.critical(e)
sys.exit(1)
Expand Down Expand Up @@ -1077,34 +1080,36 @@ def create_subworkflow(ctx, subworkflow, dir, author, force):
sys.exit(1)


# nf-core subworkflows create-test-yml
@subworkflows.command("create-test-yml")
# nf-core subworkflows create-snapshot
@subworkflows.command("create-snapshot")
@click.pass_context
@click.argument("subworkflow", type=str, required=False, metavar="subworkflow name")
@click.option("-d", "--dir", type=click.Path(exists=True), default=".", metavar="<nf-core/modules directory>")
@click.option("-t", "--run-tests", is_flag=True, default=False, help="Run the test workflows")
@click.option("-o", "--output", type=str, help="Path for output YAML file")
@click.option("-f", "--force", is_flag=True, default=False, help="Overwrite output YAML file if it already exists")
@click.option("-p", "--no-prompts", is_flag=True, default=False, help="Use defaults without prompting")
def create_test_yml(ctx, subworkflow, run_tests, output, force, no_prompts):
@click.option("-u", "--update", is_flag=True, default=False, help="Update existing snapshots")
def create_snapshot(ctx, subworkflow, dir, run_tests, no_prompts, update):
"""
Auto-generate a test.yml file for a new subworkflow.

Given the name of a module, runs the Nextflow test command and automatically generate
the required `test.yml` file based on the output files.
mashehu marked this conversation as resolved.
Show resolved Hide resolved
"""
from nf_core.subworkflows import SubworkflowTestYmlBuilder
from nf_core.components.snapshot_generator import ComponentTestSnapshotGenerator

try:
meta_builder = SubworkflowTestYmlBuilder(
subworkflow=subworkflow,
snap_generator = ComponentTestSnapshotGenerator(
component_type="subworkflows",
component_name=subworkflow,
directory=dir,
run_tests=run_tests,
test_yml_output_path=output,
force_overwrite=force,
no_prompts=no_prompts,
update=update,
remote_url=ctx.obj["modules_repo_url"],
branch=ctx.obj["modules_repo_branch"],
verbose=ctx.obj["verbose"],
)
meta_builder.run()
snap_generator.run()
except (UserWarning, LookupError) as e:
log.critical(e)
sys.exit(1)
Expand Down Expand Up @@ -1344,7 +1349,7 @@ def install(ctx, subworkflow, dir, prompt, force, sha):
ctx.obj["modules_repo_no_pull"],
)
exit_status = subworkflow_install.install(subworkflow)
if not exit_status and all:
if not exit_status and install_all:
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we have install_all available in this command? Don't see it in the params list

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we don't :)

Suggested change
if not exit_status and install_all:
if not exit_status:

sys.exit(1)
except (UserWarning, LookupError) as e:
log.error(e)
Expand Down Expand Up @@ -1396,7 +1401,9 @@ def remove(ctx, dir, subworkflow):
@click.option("-f", "--force", is_flag=True, default=False, help="Force update of subworkflow")
@click.option("-p", "--prompt", is_flag=True, default=False, help="Prompt for the version of the subworkflow")
@click.option("-s", "--sha", type=str, metavar="<commit sha>", help="Install subworkflow at commit SHA")
@click.option("-a", "--all", is_flag=True, default=False, help="Update all subworkflow installed in pipeline")
@click.option(
"-a", "--all", "install_all", is_flag=True, default=False, help="Update all subworkflow installed in pipeline"
)
@click.option(
"-x/-y",
"--preview/--no-preview",
Expand All @@ -1419,7 +1426,7 @@ def remove(ctx, dir, subworkflow):
default=False,
help="Automatically update all linked modules and subworkflows without asking for confirmation",
)
def update(ctx, subworkflow, dir, force, prompt, sha, all, preview, save_diff, update_deps):
def update(ctx, subworkflow, dir, force, prompt, sha, install_all, preview, save_diff, update_deps):
"""
Update DSL2 subworkflow within a pipeline.

Expand All @@ -1442,7 +1449,7 @@ def update(ctx, subworkflow, dir, force, prompt, sha, all, preview, save_diff, u
ctx.obj["modules_repo_no_pull"],
)
exit_status = subworkflow_install.update(subworkflow)
if not exit_status and all:
if not exit_status and install_all:
sys.exit(1)
except (UserWarning, LookupError) as e:
log.error(e)
Expand Down
Loading
Loading