Skip to content

Commit

Permalink
Merge pull request #3384 from mirpedrol/modules-bump-versions
Browse files Browse the repository at this point in the history
Modules: fix bump-versions: only append module name if it is a dir and contains main.nf
  • Loading branch information
mirpedrol authored Jan 7, 2025
2 parents 340523c + 069fce2 commit 53703f4
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 8 deletions.
4 changes: 2 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@

### Modules

- Fix bump-versions: only append module name if it is a dir and contains main.nf ([#3384](https://github.com/nf-core/tools/pull/3384))

### Subworkflows

### General

- bump to 3.2.0dev ([#3370](https://github.com/nf-core/tools/pull/3370))

### Version updates

## [v3.1.1 - Brass Boxfish Patch](https://github.com/nf-core/tools/releases/tag/3.1.1) - [2024-12-20]
Expand Down
13 changes: 7 additions & 6 deletions nf_core/modules/modules_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,19 +65,20 @@ def get_installed_modules(directory: Path, repo_type="modules") -> Tuple[List[st
local_modules = sorted([x for x in local_modules if x.endswith(".nf")])

# Get nf-core modules
if os.path.exists(nfcore_modules_dir):
for m in sorted([m for m in os.listdir(nfcore_modules_dir) if not m == "lib"]):
if not os.path.isdir(os.path.join(nfcore_modules_dir, m)):
if nfcore_modules_dir.exists():
for m in sorted([m for m in nfcore_modules_dir.iterdir() if not m == "lib"]):
if not m.is_dir():
raise ModuleExceptionError(
f"File found in '{nfcore_modules_dir}': '{m}'! This directory should only contain module directories."
)
m_content = os.listdir(os.path.join(nfcore_modules_dir, m))
m_content = [d.name for d in m.iterdir()]
# Not a module, but contains sub-modules
if "main.nf" not in m_content:
for tool in m_content:
nfcore_modules_names.append(os.path.join(m, tool))
if (m / tool).is_dir() and "main.nf" in [d.name for d in (m / tool).iterdir()]:
nfcore_modules_names.append(str(Path(m.name, tool)))
else:
nfcore_modules_names.append(m)
nfcore_modules_names.append(m.name)

# Make full (relative) file paths and create NFCoreComponent objects
if local_modules_dir:
Expand Down
20 changes: 20 additions & 0 deletions tests/modules/test_modules_utils.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import nf_core.modules.modules_utils

from ..test_modules import TestModules


class TestModulesUtils(TestModules):
def test_get_installed_modules(self):
"""Test getting installed modules"""
_, nfcore_modules = nf_core.modules.modules_utils.get_installed_modules(self.nfcore_modules)
assert len(nfcore_modules) == 1
assert nfcore_modules[0].component_name == "bpipe/test"

def test_get_installed_modules_with_files(self):
"""Test getting installed modules. When a module contains a file in its directory, it shouldn't be picked up as a tool/subtool"""
# Create a file in the module directory
with open(self.nfcore_modules / "modules" / "nf-core" / "bpipe" / "test_file.txt", "w") as fh:
fh.write("test")

_, nfcore_modules = nf_core.modules.modules_utils.get_installed_modules(self.nfcore_modules)
assert len(nfcore_modules) == 1

0 comments on commit 53703f4

Please sign in to comment.