Skip to content

Commit

Permalink
fix old nf-core sync command and use the info from .nf-core.yml to sy…
Browse files Browse the repository at this point in the history
…nc a pipeline
  • Loading branch information
mirpedrol committed Oct 1, 2024
1 parent 2a35da1 commit b75ba51
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 2 deletions.
5 changes: 3 additions & 2 deletions nf_core/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -1815,6 +1815,7 @@ def command_create_logo(logo_text, directory, name, theme, width, format, force)

# nf-core sync (deprecated)
@nf_core_cli.command("sync", hidden=True, deprecated=True)
@click.pass_context
@click.option(
"-d",
"--dir",
Expand Down Expand Up @@ -1845,14 +1846,14 @@ def command_create_logo(logo_text, directory, name, theme, width, format, force)
@click.option("-g", "--github-repository", type=str, help="GitHub PR: target repository.")
@click.option("-u", "--username", type=str, help="GitHub PR: auth username.")
@click.option("-t", "--template-yaml", help="Pass a YAML file to customize the template")
def command_sync(directory, from_branch, pull_request, github_repository, username, template_yaml, force_pr):
def command_sync(ctx, directory, from_branch, pull_request, github_repository, username, template_yaml, force_pr):
"""
Use `nf-core pipelines sync` instead.
"""
log.warning(
"The `[magenta]nf-core sync[/]` command is deprecated. Use `[magenta]nf-core pipelines sync[/]` instead."
)
pipelines_sync(directory, from_branch, pull_request, github_repository, username, template_yaml, force_pr)
pipelines_sync(ctx, directory, from_branch, pull_request, github_repository, username, template_yaml, force_pr)


# nf-core bump-version (deprecated)
Expand Down
39 changes: 39 additions & 0 deletions nf_core/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -1136,6 +1136,45 @@ def load_tools_config(directory: Union[str, Path] = ".") -> Tuple[Optional[Path]
error_message += f"\n{error['loc'][0]}: {error['msg']}"
raise AssertionError(error_message)

# Retrieve information if template from config file is empty
wf_config = fetch_wf_config(Path(directory))
config_template_keys = tools_config["template"].keys() if "template" in tools_config else []
if nf_core_yaml_config.template is None:
# The .nf-core.yml file did not contain template information
nf_core_yaml_config.template = NFCoreTemplateConfig(
org="nf-core",
name=wf_config["manifest.name"].strip('"').strip("'").split("/")[-1],
description=wf_config["manifest.description"].strip('"').strip("'"),
author=wf_config["manifest.author"].strip('"').strip("'"),
version=wf_config["manifest.version"].strip('"').strip("'"),
outdir=str(directory),
)
elif "prefix" in config_template_keys or "skip" in config_template_keys:
# The .nf-core.yml file contained the old prefix or skip keys
nf_core_yaml_config.template = NFCoreTemplateConfig(
org=tools_config["template"]["prefix"]
if "prefix" in config_template_keys
else tools_config["template"]["org"] or "nf-core",
name=tools_config["template"]["name"]
if "name" in config_template_keys
else wf_config["manifest.name"].strip('"').strip("'").split("/")[-1],
description=tools_config["template"]["description"]
if "description" in config_template_keys
else wf_config["manifest.description"].strip('"').strip("'"),
author=tools_config["template"]["author"]
if "author" in config_template_keys
else wf_config["manifest.author"].strip('"').strip("'"),
version=tools_config["template"]["version"]
if "version" in config_template_keys
else wf_config["manifest.version"].strip('"').strip("'"),
outdir=tools_config["template"]["outdir"] if "outdir" in config_template_keys else str(directory),
skip_features=tools_config["template"]["skip"]
if "skip" in config_template_keys
else tools_config["template"]["skip_features"]
if "skip_features" in config_template_keys
else None,
)

log.debug("Using config file: %s", config_fn)
return config_fn, nf_core_yaml_config

Expand Down

0 comments on commit b75ba51

Please sign in to comment.