From 3f38c11770866f5fa3c07ce88bd473a18546b81d Mon Sep 17 00:00:00 2001 From: Alexander Peltzer Date: Mon, 25 Nov 2019 10:54:06 +0100 Subject: [PATCH 1/6] Drop Singularity --- CHANGELOG.md | 1 + nf_core/lint.py | 7 +++++++ 2 files changed, 8 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0ed969800..5a23a57f2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,7 @@ * Updated Blacklist of synced pipelines * Ignore pre-releases in `nf-core list` +* Lint for `Singularity` file [and remove it](https://github.com/nf-core/tools/issues/458) ### Template diff --git a/nf_core/lint.py b/nf_core/lint.py index 5b65e5688..eb22d0647 100755 --- a/nf_core/lint.py +++ b/nf_core/lint.py @@ -166,6 +166,7 @@ def lint_pipeline(self, release_mode=False): 'check_files_exist', 'check_licence', 'check_docker', + 'check_singularity', 'check_nextflow_config', 'check_ci_config', 'check_readme', @@ -277,6 +278,12 @@ def check_docker(self): self.failed.append((2, "Dockerfile check failed")) + def check_singularity(self): + """Checks whether a Singularity file exists and warns to remove that file then.""" + fn = os.path.join(self.path, "Singularity") + content = "" + self.failed.append((2, "Singularity file exists")) + def check_licence(self): """Checks licence file is MIT. From c41340c5ce475b96b55c54673bb36b9465f8592c Mon Sep 17 00:00:00 2001 From: Alexander Peltzer Date: Mon, 25 Nov 2019 10:55:43 +0100 Subject: [PATCH 2/6] Add Singularity file for failing tests --- tests/lint_examples/failing_example/Singularity | 1 + 1 file changed, 1 insertion(+) create mode 100644 tests/lint_examples/failing_example/Singularity diff --git a/tests/lint_examples/failing_example/Singularity b/tests/lint_examples/failing_example/Singularity new file mode 100644 index 000000000..02e88c804 --- /dev/null +++ b/tests/lint_examples/failing_example/Singularity @@ -0,0 +1 @@ +Nothing to be found here \ No newline at end of file From 31fa51467061f6849984ca4e4594bb11354f5e1e Mon Sep 17 00:00:00 2001 From: Alexander Peltzer Date: Mon, 25 Nov 2019 11:14:28 +0100 Subject: [PATCH 3/6] Fix tests and use an if --- nf_core/lint.py | 4 ++-- tests/test_lint.py | 7 +++++++ 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/nf_core/lint.py b/nf_core/lint.py index eb22d0647..9b0c1e9a5 100755 --- a/nf_core/lint.py +++ b/nf_core/lint.py @@ -281,8 +281,8 @@ def check_docker(self): def check_singularity(self): """Checks whether a Singularity file exists and warns to remove that file then.""" fn = os.path.join(self.path, "Singularity") - content = "" - self.failed.append((2, "Singularity file exists")) + if(path.exists(fn)): + self.failed.append((2, "Singularity file exists")) def check_licence(self): """Checks licence file is MIT. diff --git a/tests/test_lint.py b/tests/test_lint.py index 16366e5f5..2c22852cc 100644 --- a/tests/test_lint.py +++ b/tests/test_lint.py @@ -107,6 +107,13 @@ def test_mit_license_example_with_failed(self): bad_lint_obj.check_licence() expectations = {"failed": 1, "warned": 0, "passed": 0} self.assess_lint_status(bad_lint_obj, **expectations) + + def test_singularity_with_failed(self): + """Tests that Singularity file doesn't exist""" + bad_lint_obj = nf_core.lint.PipelineLint(PATH_FAILING_EXAMPLE) + bad_lint_obj.check_singularity() + expectations = {"failed": 1, "warned": 0, "passed": 33} + self.assess_lint_status(bad_lint_obj, **expectations) def test_config_variable_example_pass(self): """Tests that config variable existence test works with good pipeline example""" From d5d2fd1773b9811aa994029a7a1561a4080c0ff9 Mon Sep 17 00:00:00 2001 From: Alexander Peltzer Date: Mon, 25 Nov 2019 11:16:49 +0100 Subject: [PATCH 4/6] Nice error docs --- docs/lint_errors.md | 4 ++++ nf_core/lint.py | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/docs/lint_errors.md b/docs/lint_errors.md index afd986ae5..84c02e227 100644 --- a/docs/lint_errors.md +++ b/docs/lint_errors.md @@ -227,3 +227,7 @@ The nf-core workflow template contains a number of comment lines with the follow ``` This lint test runs through all files in the pipeline and searches for these lines. + +## Error #11 - Singularity file found ##{#11} + +As we are relying on [Docker Hub](https://https://hub.docker.com/) instead of Singularity and all containers are automatically pulled from there, repositories should not have a `Singularity` file present. diff --git a/nf_core/lint.py b/nf_core/lint.py index 9b0c1e9a5..785c5b683 100755 --- a/nf_core/lint.py +++ b/nf_core/lint.py @@ -282,7 +282,7 @@ def check_singularity(self): """Checks whether a Singularity file exists and warns to remove that file then.""" fn = os.path.join(self.path, "Singularity") if(path.exists(fn)): - self.failed.append((2, "Singularity file exists")) + self.failed.append((11, "Singularity file exists")) def check_licence(self): """Checks licence file is MIT. From 8b4fc063068d16bcce5e7cc7cb82b90357a010cd Mon Sep 17 00:00:00 2001 From: Alexander Peltzer Date: Mon, 25 Nov 2019 11:44:49 +0100 Subject: [PATCH 5/6] Needs to be os --- nf_core/lint.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nf_core/lint.py b/nf_core/lint.py index 785c5b683..526d8be41 100755 --- a/nf_core/lint.py +++ b/nf_core/lint.py @@ -281,7 +281,7 @@ def check_docker(self): def check_singularity(self): """Checks whether a Singularity file exists and warns to remove that file then.""" fn = os.path.join(self.path, "Singularity") - if(path.exists(fn)): + if(os.path.exists(fn)): self.failed.append((11, "Singularity file exists")) def check_licence(self): From fe41b216376a8a4a6999e21d6875476df8f72eb6 Mon Sep 17 00:00:00 2001 From: Alexander Peltzer Date: Mon, 25 Nov 2019 12:58:48 +0100 Subject: [PATCH 6/6] Its just testing the singularity --- tests/test_lint.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_lint.py b/tests/test_lint.py index 2c22852cc..6dd812934 100644 --- a/tests/test_lint.py +++ b/tests/test_lint.py @@ -112,7 +112,7 @@ def test_singularity_with_failed(self): """Tests that Singularity file doesn't exist""" bad_lint_obj = nf_core.lint.PipelineLint(PATH_FAILING_EXAMPLE) bad_lint_obj.check_singularity() - expectations = {"failed": 1, "warned": 0, "passed": 33} + expectations = {"failed": 1, "warned": 0, "passed": 0} self.assess_lint_status(bad_lint_obj, **expectations) def test_config_variable_example_pass(self):