Skip to content

Commit 85338c9

Browse files
authored
Merge branch 'dev' into LouisLeNezet-config
2 parents 0d33739 + ba332b6 commit 85338c9

File tree

22 files changed

+596
-161
lines changed

22 files changed

+596
-161
lines changed

.pre-commit-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
repos:
22
- repo: https://github.com/astral-sh/ruff-pre-commit
3-
rev: v0.7.4
3+
rev: v0.8.0
44
hooks:
55
- id: ruff # linter
66
args: [--fix, --exit-non-zero-on-fix] # sort imports and fix

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
- fix workflow_dispatch trigger and parse more review comments in awsfulltest ([#3235](https://github.com/nf-core/tools/pull/3235))
1111
- Add resource limits to Gitpod profile([#3255](https://github.com/nf-core/tools/pull/3255))
1212
- Fix a typo ([#3268](https://github.com/nf-core/tools/pull/3268))
13+
- Remove `def` from `nextflow.config` and add `trace_report_suffix` param ([#3296](https://github.com/nf-core/tools/pull/3296))
1314

1415
### Download
1516

@@ -25,6 +26,8 @@
2526

2627
### Subworkflows
2728

29+
- Add `nf-core subworkflows patch` command ([#2861](https://github.com/nf-core/tools/pull/2861))
30+
2831
### General
2932

3033
- Include .nf-core.yml in `nf-core pipelines bump-version` ([#3220](https://github.com/nf-core/tools/pull/3220))
@@ -44,6 +47,7 @@
4447
- Update pre-commit hook astral-sh/ruff-pre-commit to v0.7.4 ([#3282](https://github.com/nf-core/tools/pull/3282))
4548
- Update codecov/codecov-action action to v5 ([#3283](https://github.com/nf-core/tools/pull/3283))
4649
- Update python:3.12-slim Docker digest to 2a6386a ([#3284](https://github.com/nf-core/tools/pull/3284))
50+
- Update pre-commit hook astral-sh/ruff-pre-commit to v0.8.0 ([#3299](https://github.com/nf-core/tools/pull/3299))
4751

4852
## [v3.0.2 - Titanium Tapir Patch](https://github.com/nf-core/tools/releases/tag/3.0.2) - [2024-10-11]
4953

nf_core/__main__.py

Lines changed: 38 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1024,7 +1024,7 @@ def command_modules_update(
10241024
default=".",
10251025
help=r"Pipeline directory. [dim]\[default: current working directory][/]",
10261026
)
1027-
@click.option("-r", "--remove", is_flag=True, default=False)
1027+
@click.option("-r", "--remove", is_flag=True, default=False, help="Remove an existent patch file and regenerate it.")
10281028
def command_modules_patch(ctx, tool, directory, remove):
10291029
"""
10301030
Create a patch file for minor changes in a module
@@ -1567,6 +1567,43 @@ def command_subworkflows_install(ctx, subworkflow, directory, prompt, force, sha
15671567
subworkflows_install(ctx, subworkflow, directory, prompt, force, sha)
15681568

15691569

1570+
# nf-core subworkflows patch
1571+
@subworkflows.command("patch")
1572+
@click.pass_context
1573+
@click.argument("tool", type=str, required=False, metavar="<tool> or <tool/subtool>")
1574+
@click.option(
1575+
"-d",
1576+
"--dir",
1577+
type=click.Path(exists=True),
1578+
default=".",
1579+
help=r"Pipeline directory. [dim]\[default: current working directory][/]",
1580+
)
1581+
@click.option("-r", "--remove", is_flag=True, default=False, help="Remove an existent patch file and regenerate it.")
1582+
def subworkflows_patch(ctx, tool, dir, remove):
1583+
"""
1584+
Create a patch file for minor changes in a subworkflow
1585+
1586+
Checks if a subworkflow has been modified locally and creates a patch file
1587+
describing how the module has changed from the remote version
1588+
"""
1589+
from nf_core.subworkflows import SubworkflowPatch
1590+
1591+
try:
1592+
subworkflow_patch = SubworkflowPatch(
1593+
dir,
1594+
ctx.obj["modules_repo_url"],
1595+
ctx.obj["modules_repo_branch"],
1596+
ctx.obj["modules_repo_no_pull"],
1597+
)
1598+
if remove:
1599+
subworkflow_patch.remove(tool)
1600+
else:
1601+
subworkflow_patch.patch(tool)
1602+
except (UserWarning, LookupError) as e:
1603+
log.error(e)
1604+
sys.exit(1)
1605+
1606+
15701607
# nf-core subworkflows remove
15711608
@subworkflows.command("remove")
15721609
@click.pass_context

nf_core/modules/modules_differ.py renamed to nf_core/components/components_differ.py

Lines changed: 69 additions & 63 deletions
Large diffs are not rendered by default.

nf_core/components/patch.py

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
import nf_core.utils
1010
from nf_core.components.components_command import ComponentCommand
11-
from nf_core.modules.modules_differ import ModulesDiffer
11+
from nf_core.components.components_differ import ComponentsDiffer
1212
from nf_core.modules.modules_json import ModulesJson
1313

1414
log = logging.getLogger(__name__)
@@ -65,7 +65,9 @@ def patch(self, component=None):
6565
component_fullname = str(Path(self.component_type, self.modules_repo.repo_path, component))
6666

6767
# Verify that the component has an entry in the modules.json file
68-
if not self.modules_json.module_present(component, self.modules_repo.remote_url, component_dir):
68+
if not self.modules_json.component_present(
69+
component, self.modules_repo.remote_url, component_dir, self.component_type
70+
):
6971
raise UserWarning(
7072
f"The '{component_fullname}' {self.component_type[:-1]} does not have an entry in the 'modules.json' file. Cannot compute patch"
7173
)
@@ -112,7 +114,7 @@ def patch(self, component=None):
112114
# Write the patch to a temporary location (otherwise it is printed to the screen later)
113115
patch_temp_path = tempfile.mktemp()
114116
try:
115-
ModulesDiffer.write_diff_file(
117+
ComponentsDiffer.write_diff_file(
116118
patch_temp_path,
117119
component,
118120
self.modules_repo.repo_path,
@@ -127,11 +129,13 @@ def patch(self, component=None):
127129
raise UserWarning(f"{self.component_type[:-1]} '{component_fullname}' is unchanged. No patch to compute")
128130

129131
# Write changes to modules.json
130-
self.modules_json.add_patch_entry(component, self.modules_repo.remote_url, component_dir, patch_relpath)
132+
self.modules_json.add_patch_entry(
133+
self.component_type, component, self.modules_repo.remote_url, component_dir, patch_relpath
134+
)
131135
log.debug(f"Wrote patch path for {self.component_type[:-1]} {component} to modules.json")
132136

133137
# Show the changes made to the module
134-
ModulesDiffer.print_diff(
138+
ComponentsDiffer.print_diff(
135139
component,
136140
self.modules_repo.repo_path,
137141
component_install_dir,
@@ -166,7 +170,9 @@ def remove(self, component):
166170
component_fullname = str(Path(self.component_type, component_dir, component))
167171

168172
# Verify that the component has an entry in the modules.json file
169-
if not self.modules_json.module_present(component, self.modules_repo.remote_url, component_dir):
173+
if not self.modules_json.component_present(
174+
component, self.modules_repo.remote_url, component_dir, self.component_type
175+
):
170176
raise UserWarning(
171177
f"The '{component_fullname}' {self.component_type[:-1]} does not have an entry in the 'modules.json' file. Cannot compute patch"
172178
)
@@ -202,7 +208,7 @@ def remove(self, component):
202208

203209
# Try to apply the patch in reverse and move resulting files to module dir
204210
temp_component_dir = self.modules_json.try_apply_patch_reverse(
205-
component, self.modules_repo.repo_path, patch_relpath, component_path
211+
self.component_type, component, self.modules_repo.repo_path, patch_relpath, component_path
206212
)
207213
try:
208214
for file in Path(temp_component_dir).glob("*"):

nf_core/components/remove.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ def remove(self, component, removed_by=None, removed_components=None, force=Fals
6868
if not component_dir.exists():
6969
log.error(f"Installation directory '{component_dir}' does not exist.")
7070

71-
if modules_json.module_present(component, self.modules_repo.remote_url, repo_path):
71+
if modules_json.component_present(component, self.modules_repo.remote_url, repo_path, self.component_type):
7272
log.error(f"Found entry for '{component}' in 'modules.json'. Removing...")
7373
modules_json.remove_entry(self.component_type, component, self.modules_repo.remote_url, repo_path)
7474
return False

nf_core/components/update.py

Lines changed: 23 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,13 @@
99
import nf_core.modules.modules_utils
1010
import nf_core.utils
1111
from nf_core.components.components_command import ComponentCommand
12+
from nf_core.components.components_differ import ComponentsDiffer
1213
from nf_core.components.components_utils import (
1314
get_components_to_install,
1415
prompt_component_version_sha,
1516
)
1617
from nf_core.components.install import ComponentInstall
1718
from nf_core.components.remove import ComponentRemove
18-
from nf_core.modules.modules_differ import ModulesDiffer
1919
from nf_core.modules.modules_json import ModulesJson
2020
from nf_core.modules.modules_repo import ModulesRepo
2121
from nf_core.utils import plural_es, plural_s, plural_y
@@ -223,7 +223,7 @@ def update(self, component=None, silent=False, updated=None, check_diff_exist=Tr
223223
f"Writing diff file for {self.component_type[:-1]} '{component_fullname}' to '{self.save_diff_fn}'"
224224
)
225225
try:
226-
ModulesDiffer.write_diff_file(
226+
ComponentsDiffer.write_diff_file(
227227
self.save_diff_fn,
228228
component,
229229
modules_repo.repo_path,
@@ -265,7 +265,7 @@ def update(self, component=None, silent=False, updated=None, check_diff_exist=Tr
265265
self.manage_changes_in_linked_components(component, modules_to_update, subworkflows_to_update)
266266

267267
elif self.show_diff:
268-
ModulesDiffer.print_diff(
268+
ComponentsDiffer.print_diff(
269269
component,
270270
modules_repo.repo_path,
271271
component_dir,
@@ -313,7 +313,7 @@ def update(self, component=None, silent=False, updated=None, check_diff_exist=Tr
313313

314314
if self.save_diff_fn:
315315
# Write the modules.json diff to the file
316-
ModulesDiffer.append_modules_json_diff(
316+
ComponentsDiffer.append_modules_json_diff(
317317
self.save_diff_fn,
318318
old_modules_json,
319319
self.modules_json.get_modules_json(),
@@ -449,7 +449,9 @@ def get_single_component_info(self, component):
449449
self.modules_repo.setup_branch(current_branch)
450450

451451
# If there is a patch file, get its filename
452-
patch_fn = self.modules_json.get_patch_fn(component, self.modules_repo.remote_url, install_dir)
452+
patch_fn = self.modules_json.get_patch_fn(
453+
self.component_type, component, self.modules_repo.remote_url, install_dir
454+
)
453455

454456
return (self.modules_repo, component, sha, patch_fn)
455457

@@ -695,7 +697,12 @@ def get_all_components_info(self, branch=None):
695697

696698
# Add patch filenames to the components that have them
697699
components_info = [
698-
(repo, comp, sha, self.modules_json.get_patch_fn(comp, repo.remote_url, repo.repo_path))
700+
(
701+
repo,
702+
comp,
703+
sha,
704+
self.modules_json.get_patch_fn(self.component_type, comp, repo.remote_url, repo.repo_path),
705+
)
699706
for repo, comp, sha in components_info
700707
]
701708

@@ -810,7 +817,9 @@ def try_apply_patch(
810817
shutil.copytree(component_install_dir, temp_component_dir)
811818

812819
try:
813-
new_files = ModulesDiffer.try_apply_patch(component, repo_path, patch_path, temp_component_dir)
820+
new_files = ComponentsDiffer.try_apply_patch(
821+
self.component_type, component, repo_path, patch_path, temp_component_dir
822+
)
814823
except LookupError:
815824
# Patch failed. Save the patch file by moving to the install dir
816825
shutil.move(patch_path, Path(component_install_dir, patch_path.relative_to(component_dir)))
@@ -828,7 +837,7 @@ def try_apply_patch(
828837

829838
# Create the new patch file
830839
log.debug("Regenerating patch file")
831-
ModulesDiffer.write_diff_file(
840+
ComponentsDiffer.write_diff_file(
832841
Path(temp_component_dir, patch_path.relative_to(component_dir)),
833842
component,
834843
repo_path,
@@ -848,7 +857,12 @@ def try_apply_patch(
848857

849858
# Add the patch file to the modules.json file
850859
self.modules_json.add_patch_entry(
851-
component, self.modules_repo.remote_url, repo_path, patch_relpath, write_file=write_file
860+
self.component_type,
861+
component,
862+
self.modules_repo.remote_url,
863+
repo_path,
864+
patch_relpath,
865+
write_file=write_file,
852866
)
853867

854868
return True

nf_core/modules/lint/main_nf.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@
1515

1616
import nf_core
1717
import nf_core.modules.modules_utils
18+
from nf_core.components.components_differ import ComponentsDiffer
1819
from nf_core.components.nfcore_component import NFCoreComponent
19-
from nf_core.modules.modules_differ import ModulesDiffer
2020

2121
log = logging.getLogger(__name__)
2222

@@ -50,7 +50,8 @@ def main_nf(
5050
# otherwise read the lines directly from the module
5151
lines: List[str] = []
5252
if module.is_patched:
53-
lines = ModulesDiffer.try_apply_patch(
53+
lines = ComponentsDiffer.try_apply_patch(
54+
module.component_type,
5455
module.component_name,
5556
module_lint_object.modules_repo.repo_path,
5657
module.patch_path,

nf_core/modules/lint/meta_yml.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@
66
import ruamel.yaml
77
from jsonschema import exceptions, validators
88

9+
from nf_core.components.components_differ import ComponentsDiffer
910
from nf_core.components.lint import ComponentLint, LintExceptionError
1011
from nf_core.components.nfcore_component import NFCoreComponent
11-
from nf_core.modules.modules_differ import ModulesDiffer
1212

1313
log = logging.getLogger(__name__)
1414

@@ -46,7 +46,8 @@ def meta_yml(module_lint_object: ComponentLint, module: NFCoreComponent) -> None
4646
# Check if we have a patch file, get original file in that case
4747
meta_yaml = read_meta_yml(module_lint_object, module)
4848
if module.is_patched and module_lint_object.modules_repo.repo_path is not None:
49-
lines = ModulesDiffer.try_apply_patch(
49+
lines = ComponentsDiffer.try_apply_patch(
50+
module.component_type,
5051
module.component_name,
5152
module_lint_object.modules_repo.repo_path,
5253
module.patch_path,
@@ -207,7 +208,8 @@ def read_meta_yml(module_lint_object: ComponentLint, module: NFCoreComponent) ->
207208
yaml.preserve_quotes = True
208209
# Check if we have a patch file, get original file in that case
209210
if module.is_patched:
210-
lines = ModulesDiffer.try_apply_patch(
211+
lines = ComponentsDiffer.try_apply_patch(
212+
module.component_type,
211213
module.component_name,
212214
module_lint_object.modules_repo.repo_path,
213215
module.patch_path,

nf_core/modules/lint/module_changes.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
from pathlib import Path
88

99
import nf_core.modules.modules_repo
10-
from nf_core.modules.modules_differ import ModulesDiffer
10+
from nf_core.components.components_differ import ComponentsDiffer
1111

1212

1313
def module_changes(module_lint_object, module):
@@ -30,7 +30,8 @@ def module_changes(module_lint_object, module):
3030
tempdir = tempdir_parent / "tmp_module_dir"
3131
shutil.copytree(module.component_dir, tempdir)
3232
try:
33-
new_lines = ModulesDiffer.try_apply_patch(
33+
new_lines = ComponentsDiffer.try_apply_patch(
34+
module.component_type,
3435
module.component_name,
3536
module.org,
3637
module.patch_path,

0 commit comments

Comments
 (0)