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

Allow specifying conda package version in nf-core modules create #1242

Merged
merged 3 commits into from
Mar 11, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
* Added `nf-core schema docs` command to output pipline parameter documentation in Markdown format for inclusion in GitHub and other documentation systems ([#741](https://github.com/nf-core/tools/issues/741))
* Allow conditional process execution from the configuration file ([#1393](https://github.com/nf-core/tools/pull/1393))
* Add linting for when condition([#1397](https://github.com/nf-core/tools/pull/1397))
* Added `--conda-package-version` flag for specifying version of conda package in `nf-core modules create`. ([#1238](https://github.com/nf-core/tools/issues/1238))

## [v2.2 - Lead Liger](https://github.com/nf-core/tools/releases/tag/2.2) - [2021-12-14]

Expand Down
7 changes: 5 additions & 2 deletions nf_core/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -520,8 +520,9 @@ def remove(ctx, dir, tool):
@click.option("-n", "--no-meta", is_flag=True, default=False, help="Don't use meta map for sample information")
@click.option("-f", "--force", is_flag=True, default=False, help="Overwrite any files if they already exist")
@click.option("-c", "--conda-name", type=str, default=None, help="Name of the conda package to use")
@click.option("-p", "--conda-package-version", type=str, default=None, help="Version of conda package to use")
@click.option("-r", "--repo-type", type=click.Choice(["pipeline", "modules"]), default=None, help="Type of repository")
def create_module(ctx, tool, dir, author, label, meta, no_meta, force, conda_name, repo_type):
def create_module(ctx, tool, dir, author, label, meta, no_meta, force, conda_name, conda_package_version, repo_type):
"""
Create a new DSL2 module from the nf-core template.

Expand All @@ -542,7 +543,9 @@ def create_module(ctx, tool, dir, author, label, meta, no_meta, force, conda_nam

# Run function
try:
module_create = nf_core.modules.ModuleCreate(dir, tool, author, label, has_meta, force, conda_name, repo_type)
module_create = nf_core.modules.ModuleCreate(
dir, tool, author, label, has_meta, force, conda_name, conda_package_version, repo_type
)
module_create.create()
except UserWarning as e:
log.critical(e)
Expand Down
13 changes: 10 additions & 3 deletions nf_core/modules/create.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ def __init__(
has_meta=None,
force=False,
conda_name=None,
conda_version=None,
repo_type=None,
):
self.directory = directory
Expand All @@ -44,6 +45,7 @@ def __init__(
self.force_overwrite = force
self.subtool = None
self.tool_conda_name = conda_name
self.tool_conda_version = conda_version
self.tool_licence = None
self.repo_type = repo_type
self.tool_licence = ""
Expand Down Expand Up @@ -143,9 +145,14 @@ def create(self):
anaconda_response = nf_core.utils.anaconda_package(self.tool_conda_name, ["bioconda"])
else:
anaconda_response = nf_core.utils.anaconda_package(self.tool, ["bioconda"])
version = anaconda_response.get("latest_version")
if not version:
version = str(max([parse_version(v) for v in anaconda_response["versions"]]))

if not self.tool_conda_version:
version = anaconda_response.get("latest_version")
if not version:
version = str(max([parse_version(v) for v in anaconda_response["versions"]]))
else:
version = self.tool_conda_version

self.tool_licence = nf_core.utils.parse_anaconda_licence(anaconda_response, version)
self.tool_description = anaconda_response.get("summary", "")
self.tool_doc_url = anaconda_response.get("doc_url", "")
Expand Down