Skip to content

Commit

Permalink
Merge pull request #2037 from mirpedrol/update-config
Browse files Browse the repository at this point in the history
Check structure of update entry in .nf-core.yml
  • Loading branch information
mirpedrol authored Nov 25, 2022
2 parents 4bf70e1 + 1ee11b0 commit bbb5415
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 5 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@

### Linting

- Don't lint pipeline name if `manifest.name` in `.nf-core.yml` ([#2035](https://github.com/nf-core/tools/pull/2035))

### General

- Refactor CLI flag `--hide-progress` to be at the top-level group, like `--verbose` ([#2016](https://github.com/nf-core/tools/pull/2016))
Expand Down
23 changes: 20 additions & 3 deletions nf_core/components/update.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,9 @@ def update(self, component=None, silent=False, updated=None, check_diff_exist=Tr
exit_value = True
all_patches_successful = True
for modules_repo, component, sha, patch_relpath in components_info:
if component is None:
# The entry from .nf-core.yml is set to false, skip update of this component
continue
component_fullname = str(Path(self.component_type, modules_repo.repo_path, component))
# Are we updating the files in place or not?
dry_run = self.show_diff or self.save_diff_fn
Expand Down Expand Up @@ -378,6 +381,19 @@ def get_single_component_info(self, component):

sha = self.sha
config_entry = None
if any(
[
entry.count("/") == 1
and (entry.endswith("modules") or entry.endswith("subworkflows"))
and not (entry.endswith(".git") or entry.endswith(".git/"))
for entry in self.update_config.keys()
]
):
raise UserWarning(
"Your '.nf-core.yml' file format is outdated. "
"The format should be of the form:\n"
"update:\n <repo_url>:\n <component_install_directory>:\n <component_name>:"
)
if isinstance(self.update_config.get(self.modules_repo.remote_url, {}), str):
# If the repo entry is a string, it's the sha to update to
config_entry = self.update_config.get(self.modules_repo.remote_url, {})
Expand All @@ -386,12 +402,13 @@ def get_single_component_info(self, component):
config_entry = self.update_config[self.modules_repo.remote_url][install_dir].get(component)
if config_entry is not None and config_entry is not True:
if config_entry is False:
raise UserWarning(
f"{self.component_type[:-1].title()}'s update entry in '.nf-core.yml' is set to False"
log.warn(
f"{self.component_type[:-1].title()}'s update entry in '.nf-core.yml' for '{component}' is set to False"
)
return (self.modules_repo, None, None, None)
if not isinstance(config_entry, str):
raise UserWarning(
f"{self.component_type[:-1].title()}'s update entry in '.nf-core.yml' is of wrong type"
f"{self.component_type[:-1].title()}'s update entry in '.nf-core.yml' for '{component}' is of wrong type"
)

sha = config_entry
Expand Down
10 changes: 8 additions & 2 deletions nf_core/create.py
Original file line number Diff line number Diff line change
Expand Up @@ -166,10 +166,16 @@ def create_param_dict(self, name, description, author, version, template_yaml_pa
param_dict["logo_dark"] = f"{param_dict['name_noslash']}_logo_dark.png"
param_dict["version"] = version

config_yml = nf_core.utils.load_tools_config()
if (
"lint" in config_yml
and "nextflow_config" in config_yml["lint"]
and "manifest.name" in config_yml["lint"]["nextflow_config"]
):
return param_dict, skip_paths
# Check that the pipeline name matches the requirements
if not re.match(r"^[a-z]+$", param_dict["short_name"]):
log.error("[red]Invalid workflow name: must be lowercase without punctuation.")
sys.exit(1)
raise UserWarning("[red]Invalid workflow name: must be lowercase without punctuation.")

return param_dict, skip_paths

Expand Down

0 comments on commit bbb5415

Please sign in to comment.