Skip to content

Commit

Permalink
Merge pull request #3161 from ewels/module-lint-no-name
Browse files Browse the repository at this point in the history
Don't test conda `environment.yml` `name` attribute
  • Loading branch information
ewels authored Sep 6, 2024
2 parents d6bd738 + ac88c16 commit 16d66cb
Show file tree
Hide file tree
Showing 4 changed files with 1 addition and 126 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
- Linting will now check the use of the right validation plugin include statements in the workflow scripts ([#3116])(https://github.com/nf-core/tools/pull/3116)
- Full linting for correct use of nf-schema and nf-validation ([#3116](https://github.com/nf-core/tools/pull/3116))
- Handle cases where the directory path contains the name of the component ([#3147](https://github.com/nf-core/tools/pull/3147))
- Don't test conda `environment.yml` `name` attribute (which should no longer be there) ([#3161](https://github.com/nf-core/tools/pull/3161))

### Pipeline create command

Expand Down
1 change: 0 additions & 1 deletion nf_core/module-template/environment.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
---
# yaml-language-server: $schema=https://raw.githubusercontent.com/nf-core/modules/master/modules/environment-schema.json
name: "{{ component_name_underscore }}"
channels:
- conda-forge
- bioconda
Expand Down
39 changes: 0 additions & 39 deletions nf_core/modules/lint/environment_yml.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,42 +90,3 @@ def environment_yml(module_lint_object: ComponentLint, module: NFCoreComponent)
env_yml["dependencies"].sort()
with open(Path(module.component_dir, "environment.yml"), "w") as fh:
yaml.dump(env_yml, fh, Dumper=custom_yaml_dumper())

# Check that the name in the environment.yml file matches the name in the meta.yml file
with open(Path(module.component_dir, "meta.yml")) as fh:
meta_yml = yaml.safe_load(fh)

if env_yml["name"] == meta_yml["name"]:
module.passed.append(
(
"environment_yml_name",
"The module's `environment.yml` name matches module name",
module.environment_yml,
)
)
else:
module.failed.append(
(
"environment_yml_name",
f"Conflicting process name between environment.yml (`{env_yml['name']}`) and meta.yml (`{module.component_name}`)",
module.environment_yml,
)
)

# Check that the name is lowercase
if env_yml["name"] == env_yml["name"].lower():
module.passed.append(
(
"environment_yml_name_lowercase",
"The module's `environment.yml` name is lowercase",
module.environment_yml,
)
)
else:
module.failed.append(
(
"environment_yml_name_lowercase",
"The module's `environment.yml` name is not lowercase",
module.environment_yml,
)
)
86 changes: 0 additions & 86 deletions tests/modules/test_lint.py
Original file line number Diff line number Diff line change
Expand Up @@ -487,54 +487,6 @@ def test_modules_environment_yml_file_not_array(self):
assert len(module_lint.warned) >= 0
assert module_lint.failed[0].lint_test == "environment_yml_valid"

def test_modules_environment_yml_file_name_mismatch(self):
"""Test linting a module with a different name in the environment.yml file"""
with open(
Path(
self.nfcore_modules,
"modules",
"nf-core",
"bpipe",
"test",
"environment.yml",
)
) as fh:
yaml_content = yaml.safe_load(fh)
yaml_content["name"] = "bpipe-test"
with open(
Path(
self.nfcore_modules,
"modules",
"nf-core",
"bpipe",
"test",
"environment.yml",
),
"w",
) as fh:
fh.write(yaml.dump(yaml_content))
module_lint = nf_core.modules.lint.ModuleLint(directory=self.nfcore_modules)
module_lint.lint(print_results=False, module="bpipe/test")
# reset changes
yaml_content["name"] = "bpipe_test"
with open(
Path(
self.nfcore_modules,
"modules",
"nf-core",
"bpipe",
"test",
"environment.yml",
),
"w",
) as fh:
fh.write(yaml.dump(yaml_content))

assert len(module_lint.failed) == 1, f"Linting failed with {[x.__dict__ for x in module_lint.failed]}"
assert len(module_lint.passed) > 0
assert len(module_lint.warned) >= 0
assert module_lint.failed[0].lint_test == "environment_yml_name"

def test_modules_meta_yml_incorrect_licence_field(self):
"""Test linting a module with an incorrect Licence field in meta.yml"""
with open(Path(self.nfcore_modules, "modules", "nf-core", "bpipe", "test", "meta.yml")) as fh:
Expand Down Expand Up @@ -604,36 +556,11 @@ def test_modules_meta_yml_incorrect_name(self):
with open(Path(self.nfcore_modules, "modules", "nf-core", "bpipe", "test", "meta.yml")) as fh:
meta_yml = yaml.safe_load(fh)
meta_yml["name"] = "bpipe/test"
# need to make the same change to the environment.yml file
with open(
Path(
self.nfcore_modules,
"modules",
"nf-core",
"bpipe",
"test",
"environment.yml",
)
) as fh:
environment_yml = yaml.safe_load(fh)
environment_yml["name"] = "bpipe/test"
with open(
Path(self.nfcore_modules, "modules", "nf-core", "bpipe", "test", "meta.yml"),
"w",
) as fh:
fh.write(yaml.dump(meta_yml))
with open(
Path(
self.nfcore_modules,
"modules",
"nf-core",
"bpipe",
"test",
"environment.yml",
),
"w",
) as fh:
fh.write(yaml.dump(environment_yml))
module_lint = nf_core.modules.lint.ModuleLint(directory=self.nfcore_modules)
module_lint.lint(print_results=False, module="bpipe/test")

Expand All @@ -644,19 +571,6 @@ def test_modules_meta_yml_incorrect_name(self):
"w",
) as fh:
fh.write(yaml.dump(meta_yml))
environment_yml["name"] = "bpipe_test"
with open(
Path(
self.nfcore_modules,
"modules",
"nf-core",
"bpipe",
"test",
"environment.yml",
),
"w",
) as fh:
fh.write(yaml.dump(environment_yml))

assert len(module_lint.failed) == 1, f"Linting failed with {[x.__dict__ for x in module_lint.failed]}"
assert len(module_lint.passed) >= 0
Expand Down

0 comments on commit 16d66cb

Please sign in to comment.