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

enable pytest with conda and singularity #691

Merged
merged 6 commits into from
Jul 26, 2022

Conversation

maxulysse
Copy link
Member

PR checklist

  • This comment contains a description of changes (with reason).
  • If you've fixed a bug or added code that should be tested, add tests!
    • If you've added a new tool - have you followed the pipeline conventions in the contribution docs
    • If necessary, also make a PR on the nf-core/sarek branch on the nf-core/test-datasets repository.
  • Make sure your code lints (nf-core lint).
  • Ensure the test suite passes (nextflow run . -profile test,docker --outdir <OUTDIR>).
  • Usage Documentation in docs/usage.md is updated.
  • Output Documentation in docs/output.md is updated.
  • CHANGELOG.md is updated.
  • README.md is updated (including new tool citations and authors/contributors).

@github-actions
Copy link

github-actions bot commented Jul 26, 2022

nf-core lint overall result: Passed ✅ ⚠️

Posted for pipeline commit 2fb8c01

+| ✅ 145 tests passed       |+
#| ❔   4 tests were ignored |#
!| ❗   1 tests had warnings |!

❗ Test warnings:

  • readme - README did not have a Nextflow minimum version badge.

❔ Tests ignored:

  • files_unchanged - File ignored due to lint config: assets/nf-core-sarek_logo_light.png
  • files_unchanged - File ignored due to lint config: docs/images/nf-core-sarek_logo_light.png
  • files_unchanged - File ignored due to lint config: docs/images/nf-core-sarek_logo_dark.png
  • files_unchanged - File ignored due to lint config: lib/NfcoreTemplate.groovy

✅ Tests passed:

Run details

  • nf-core/tools version 2.4.1
  • Run at 2022-07-26 12:11:41

@asp8200
Copy link
Contributor

asp8200 commented Jul 26, 2022

So I tried running the tests for cnvkit (randomly chosen) on a linux-server on commit 2fb8c01 like this:

$ PROFILE=singularity pytest --tag cnvkit --symlink --kwdof --git-aware --color=yes

but it failed. I guess it is just a problem with my setup, while this PR is probably fine. Here is the error-log from the test:

================================================================================================ test session starts ================================================================================================
platform linux -- Python 3.10.5, pytest-7.1.2, pluggy-1.0.0
rootdir: /home/aspe/dev/maxulysse_sarek
plugins: workflow-1.6.0
collecting ...
collected 69 items

Run variant calling on somatic samples with cnvkit and skip variant calling on matched normal:
	command:   nextflow run main.nf -profile test,tools_somatic --tools cnvkit --only_paired_variant_calling
	directory: /tmp/pytest_workflow_cavfgx0b/Run_variant_calling_on_somatic_samples_with_cnvkit_and_skip_variant_calling_on_matched_normal
	stdout:    /tmp/pytest_workflow_cavfgx0b/Run_variant_calling_on_somatic_samples_with_cnvkit_and_skip_variant_calling_on_matched_normal/log.out
	stderr:    /tmp/pytest_workflow_cavfgx0b/Run_variant_calling_on_somatic_samples_with_cnvkit_and_skip_variant_calling_on_matched_normal/log.err
'Run variant calling on somatic samples with cnvkit and skip variant calling on matched normal' done.

...

Run variant calling on germline sample with cnvkit:
	command:   nextflow run main.nf -profile test,tools_germline --tools cnvkit
	directory: /tmp/pytest_workflow_cavfgx0b/Run_variant_calling_on_germline_sample_with_cnvkit
	stdout:    /tmp/pytest_workflow_cavfgx0b/Run_variant_calling_on_germline_sample_with_cnvkit/log.out
	stderr:    /tmp/pytest_workflow_cavfgx0b/Run_variant_calling_on_germline_sample_with_cnvkit/log.err
'Run variant calling on germline sample with cnvkit' done.

tests/test_only_paired_VC.yml FFFFFFFFFFFFFFF                                                                                                                                                                 [ 21%]
tests/test_tools.yml FFFFFFFFFFFFFFFFFFFFFFFFF.FFFFFFFFFFFF.FFFFFFFFFFFFF.F                                                                                                                                   [100%]One or more tests failed. Keeping temporary directories and logs. Use '--kwd' or '--keep-workflow-wd' to disable this behaviour.


===================================================================================================== FAILURES ======================================================================================================
___________________________________________________________________________________________________ test session ____________________________________________________________________________________________________
'/tmp/pytest_workflow_cavfgx0b/Run_variant_calling_on_somatic_samples_with_cnvkit_and_skip_variant_calling_on_matched_normal/results/multiqc' does not exist while it should
___________________________________________________________________________________________________ test session ____________________________________________________________________________________________________
'/tmp/pytest_workflow_cavfgx0b/Run_variant_calling_on_somatic_samples_with_cnvkit_and_skip_variant_calling_on_matched_normal/results/variant_calling/cnvkit/sample4_vs_sample3/multi_intervals.antitarget.bed' does not exist while it should

...

___________________________________________________________________________________________________ test session ____________________________________________________________________________________________________
'/tmp/pytest_workflow_cavfgx0b/Run_variant_calling_on_germline_sample_with_cnvkit/results/variant_calling/cnvkit/sample1/test.paired_end.recalibrated.sorted.cns' does not exist while it should
___________________________________________________________________________________________________ test session ____________________________________________________________________________________________________
'/tmp/pytest_workflow_cavfgx0b/Run_variant_calling_on_germline_sample_with_cnvkit/results/variant_calling/cnvkit/sample1/test.paired_end.recalibrated.sorted.targetcoverage.cnn' does not exist while it should
___________________________________________________________________________________________________ test session ____________________________________________________________________________________________________
'Run variant calling on germline sample with cnvkit' exited with exit code '1' instead of '0'.
================================================================================================= warnings summary ==================================================================================================
../../anaconda3/envs/nextflow/lib/python3.10/site-packages/pytest_workflow/plugin.py:122: 20 warnings
  /home/aspe/anaconda3/envs/nextflow/lib/python3.10/site-packages/pytest_workflow/plugin.py:122: PytestRemovedIn8Warning: The (fspath: py.path.local) argument to YamlFile is deprecated. Please use the (path: pathlib.Path) argument instead.
  See https://docs.pytest.org/en/latest/deprecations.html#fspath-argument-for-node-constructors-replaced-with-pathlib-path
    return YamlFile.from_parent(parent, fspath=path)

-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html
============================================================================================== short test summary info ==============================================================================================
FAILED tests/test_only_paired_VC.yml::Run variant calling on somatic samples with cnvkit and skip variant calling on matched normal::results/multiqc::should exist
FAILED tests/test_only_paired_VC.yml::Run variant calling on somatic samples with cnvkit and skip variant calling on matched normal::results/variant_calling/cnvkit/sample4_vs_sample3/multi_intervals.antitarget.bed::should exist
FAILED tests/test_only_paired_VC.yml::Run variant calling on somatic samples with cnvkit and skip variant calling on matched normal::results/variant_calling/cnvkit/sample4_vs_sample3/multi_intervals.target.bed::should exist

...
I used
pytest 7.1.2
singularity 3.7.1-1.el7
nextflow 22.04.0
python 3.10.5

I tried running one of the failing tests, "Run variant calling on somatic samples with cnvkit", manually like this:

PROFILE=singularity nextflow run main.nf -profile test,tools_somatic --tools cnvkit --only_paired_variant_calling

and all the expected output-files are generated.

@maxulysse
Copy link
Member Author

Having mount issue with pytest:

  WARNING: Skipping mount /usr/local/var/singularity/mnt/session/etc/resolv.conf [files]: /etc/resolv.conf doesn't exist in container
  FATAL:   container creation failed: mount /tmp/pytest_workflow_fd40z6lq/Run_default_pipeline/work->/tmp/pytest_workflow_fd40z6lq/Run_default_pipeline/work error: while mounting /tmp/pytest_workflow_fd40z6lq/Run_default_pipeline/work: destination /tmp/pytest_workflow_fd40z6lq/Run_default_pipeline/work doesn't exist in container

I'm assuming your issue might be the same.
I'll try to fix that

@maxulysse
Copy link
Member Author

Had to add TMPDIR=~ to my command line to make the singularity pytest tests work:

TMPDIR=~ PROFILE=singularity pytest --tag default --symlink --kwdof --git-aware --color=yes

@maxulysse
Copy link
Member Author

Had to add TMPDIR=~ to my command line to make the singularity pytest tests work:

I'm assuming any other TMPDIR should actually do the trick

@maxulysse
Copy link
Member Author

maxulysse commented Jul 26, 2022

Couldn't get TMP=/tmp on my computer, so used TMP=~/tmp that way easier to clean up

@asp8200
Copy link
Contributor

asp8200 commented Jul 26, 2022

Well done, @maxulysse. I can confirm that I am now able to run the tests locally with the command:

TMPDIR=~ PROFILE=singularity pytest --tag cnvkit --symlink --kwdof --git-aware --color=yes

after first having run

python -m pip install --upgrade pip pytest-workflow

@maxulysse maxulysse requested a review from asp8200 July 26, 2022 15:57
### Changed

- [#679](https://github.com/nf-core/sarek/pull/679) - Back to `dev`
- [#691](https://github.com/nf-core/sarek/pull/691) - To run the same pytest as before locally, use `PROFILE=docker`
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
- [#691](https://github.com/nf-core/sarek/pull/691) - To run the same pytest as before locally, use `PROFILE=docker`
- [#691](https://github.com/nf-core/sarek/pull/691) - To run the same pytest as before locally, use TMPDIR=~/tmp, and `PROFILE=conda`, `PROFILE=docker` or `PROFILE=singularity`.

or something like that.

Copy link
Member Author

Choose a reason for hiding this comment

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

Before we had just docker, all the rest is new, let's not document that too much for now, as we're still figuring it out ;-)

Copy link
Contributor

@asp8200 asp8200 left a comment

Choose a reason for hiding this comment

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

LGTM

@maxulysse maxulysse merged commit a40a304 into nf-core:dev Jul 26, 2022
@maxulysse maxulysse deleted the dev_pytest_singularity branch July 26, 2022 16:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants