+
Skip to content

Configure the default module repository, branch, and path from environment variables. #3481

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

Merged
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 @@ -18,6 +18,7 @@
### Modules

- increase meta index for multiple input channels ([#3463](https://github.com/nf-core/tools/pull/3463))
- Configure the default module repository, branch, and path from environment variables. ([#3481](https://github.com/nf-core/tools/pull/3481))

### Subworkflows

Expand Down
7 changes: 4 additions & 3 deletions nf_core/components/components_utils.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import logging
import os
import re
from pathlib import Path
from typing import TYPE_CHECKING, Dict, List, Optional, Tuple, Union
Expand All @@ -15,9 +16,9 @@
log = logging.getLogger(__name__)

# Constants for the nf-core/modules repo used throughout the module files
NF_CORE_MODULES_NAME = "nf-core"
NF_CORE_MODULES_REMOTE = "https://github.com/nf-core/modules.git"
NF_CORE_MODULES_DEFAULT_BRANCH = "master"
NF_CORE_MODULES_NAME = os.environ.get("NF_CORE_MODULES_NAME", "nf-core")
NF_CORE_MODULES_REMOTE = os.environ.get("NF_CORE_MODULES_REMOTE", "https://github.com/nf-core/modules.git")
NF_CORE_MODULES_DEFAULT_BRANCH = os.environ.get("NF_CORE_MODULES_DEFAULT_BRANCH", "master")


def get_repo_info(directory: Path, use_prompt: Optional[bool] = True) -> Tuple[Path, Optional[str], str]:
Expand Down
24 changes: 24 additions & 0 deletions tests/components/test_components_utils.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
import importlib
import os
from unittest import mock

import responses

import nf_core.components.components_utils
Expand Down Expand Up @@ -55,3 +59,23 @@ def test_get_biotools_ch_info_warn(self):
response = nf_core.components.components_utils.get_biotools_response("bpipe")
nf_core.components.components_utils.get_channel_info_from_biotools(response, "test")
assert "Could not find an EDAM ontology term for 'test'" in self.caplog.text

def test_environment_variables_override(self):
"""Test environment variables override default values"""
mock_env = {
"NF_CORE_MODULES_NAME": "custom-name",
"NF_CORE_MODULES_REMOTE": "https://custom-repo.git",
"NF_CORE_MODULES_DEFAULT_BRANCH": "custom-branch",
}

try:
with mock.patch.dict(os.environ, mock_env):
importlib.reload(nf_core.components.components_utils)
assert nf_core.components.components_utils.NF_CORE_MODULES_NAME == mock_env["NF_CORE_MODULES_NAME"]
assert nf_core.components.components_utils.NF_CORE_MODULES_REMOTE == mock_env["NF_CORE_MODULES_REMOTE"]
assert (
nf_core.components.components_utils.NF_CORE_MODULES_DEFAULT_BRANCH
== mock_env["NF_CORE_MODULES_DEFAULT_BRANCH"]
)
finally:
importlib.reload(nf_core.components.components_utils)
Loading
点击 这是indexloc提供的php浏览器服务,不要输入任何密码和下载