Skip to content

Commit 8a2f7e6

Browse files
authored
Merge pull request #902 from ewels/bump-v-1.13
Bump version to 1.13
2 parents 918270b + 1a80f2e commit 8a2f7e6

File tree

12 files changed

+389
-233
lines changed

12 files changed

+389
-233
lines changed

.github/markdownlint.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ no-inline-html:
1010
- kbd
1111
- details
1212
- summary
13+
- kbd
1314
# tools only - the {{ jinja variables }} break URLs and cause this to error
1415
no-bare-urls: false
1516
# tools only - suppresses error messages for usage of $ in main README

CHANGELOG.md

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# nf-core/tools: Changelog
22

3-
## [v1.13 - Copper Crocodile](https://github.com/nf-core/tools/releases/tag/1.13) - [2021-03-16]
3+
## [v1.13 - Copper Crocodile](https://github.com/nf-core/tools/releases/tag/1.13) - [2021-03-18]
44

55
### Template
66

@@ -27,12 +27,16 @@
2727

2828
### Modules
2929

30-
* added `nf-core modules lint` command to enable linting of nf-core and local modules
31-
* added `nf-core modules remove` command to uninstall modules
32-
* added `nf-core modules create-test-yml` command which runs the test for a new module and automatically
33-
creates the `test.yml` for with md5 sums, tags, commands and names added
34-
* added `nf-core modules create` command to generate a new module from the module template
35-
* added questionary autocomplete functionality to `nf-core modules install`
30+
Initial addition of a number of new helper commands for working with DSL2 modules:
31+
32+
* `modules list` - List available modules
33+
* `modules install` - Install a module from nf-core/modules
34+
* `modules remove` - Remove a module from a pipeline
35+
* `modules create` - Create a module from the template
36+
* `modules create-test-yml` - Create the `test.yml` file for a module with md5 sums, tags, commands and names added
37+
* `modules lint` - Check a module against nf-core guidelines
38+
39+
You can read more about each of these commands in the main tools documentation (see `README.md` or <https://nf-co.re/tools>)
3640

3741
### Tools helper code
3842

@@ -47,6 +51,10 @@
4751

4852
### Linting
4953

54+
* Major refactor and rewrite of pipieline linting code
55+
* Much better code organisation and maintainability
56+
* New automatically generated documentation using Sphinx
57+
* Numerous new tests and functions, removal of some unnecessary tests
5058
* Added lint check for merge markers [[#321]](https://github.com/nf-core/tools/issues/321)
5159
* Added new option `--fix` to automatically correct some problems detected by linting
5260
* Added validation of default params to `nf-core schema lint` [[#823](https://github.com/nf-core/tools/issues/823)]

README.md

Lines changed: 321 additions & 200 deletions
Large diffs are not rendered by default.

nf_core/create.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ def render_template(self):
8383
loader=jinja2.PackageLoader("nf_core", "pipeline-template"), keep_trailing_newline=True
8484
)
8585
template_dir = os.path.join(os.path.dirname(__file__), "pipeline-template")
86-
copy_ftypes = ["image", "application/java-archive"]
86+
binary_ftypes = ["image", "application/java-archive"]
8787
object_attrs = vars(self)
8888
object_attrs["nf_core_version"] = nf_core.__version__
8989

@@ -108,7 +108,7 @@ def render_template(self):
108108

109109
# Just copy binary files
110110
(ftype, encoding) = mimetypes.guess_type(template_fn_path)
111-
if encoding is not None or (ftype is not None and any([ftype.startswith(ft) for ft in copy_ftypes])):
111+
if encoding is not None or (ftype is not None and any([ftype.startswith(ft) for ft in binary_ftypes])):
112112
log.debug(f"Copying binary file: '{output_path}'")
113113
shutil.copy(template_fn_path, output_path)
114114
continue

nf_core/lint/__init__.py

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -275,7 +275,7 @@ def format_result(test_results, table):
275275
string for the terminal with appropriate ASCII colours.
276276
"""
277277
for eid, msg in test_results:
278-
table.add_row(Markdown("[{0}](https://nf-co.re/errors#{0}): {1}".format(eid, msg)))
278+
table.add_row(Markdown("[{0}](https://nf-co.re/tools-docs/lint_tests/{0}.html): {1}".format(eid, msg)))
279279
return table
280280

281281
def _s(some_list):
@@ -332,7 +332,7 @@ def _s(some_list):
332332
if len(self.could_fix):
333333
fix_cmd = "nf-core lint {} --fix {}".format(self.wf_path, " --fix ".join(self.could_fix))
334334
console.print(
335-
f"\nTip: Some of these linting errors can automatically resolved with the following command:\n\n[blue] {fix_cmd}\n"
335+
f"\nTip: Some of these linting errors can automatically be resolved with the following command:\n\n[blue] {fix_cmd}\n"
336336
)
337337
if len(self.fix):
338338
console.print(
@@ -359,7 +359,9 @@ def _get_results_md(self):
359359
test_failures = "### :x: Test failures:\n\n{}\n\n".format(
360360
"\n".join(
361361
[
362-
"* [{0}](https://nf-co.re/errors#{0}) - {1}".format(eid, self._strip_ansi_codes(msg, "`"))
362+
"* [{0}](https://nf-co.re/tools-docs/lint_tests/{0}.html) - {1}".format(
363+
eid, self._strip_ansi_codes(msg, "`")
364+
)
363365
for eid, msg in self.failed
364366
]
365367
)
@@ -372,7 +374,9 @@ def _get_results_md(self):
372374
test_ignored = "### :grey_question: Tests ignored:\n\n{}\n\n".format(
373375
"\n".join(
374376
[
375-
"* [{0}](https://nf-co.re/errors#{0}) - {1}".format(eid, self._strip_ansi_codes(msg, "`"))
377+
"* [{0}](https://nf-co.re/tools-docs/lint_tests/{0}.html) - {1}".format(
378+
eid, self._strip_ansi_codes(msg, "`")
379+
)
376380
for eid, msg in self.ignored
377381
]
378382
)
@@ -385,7 +389,9 @@ def _get_results_md(self):
385389
test_fixed = "### :grey_question: Tests fixed:\n\n{}\n\n".format(
386390
"\n".join(
387391
[
388-
"* [{0}](https://nf-co.re/errors#{0}) - {1}".format(eid, self._strip_ansi_codes(msg, "`"))
392+
"* [{0}](https://nf-co.re/tools-docs/lint_tests/{0}.html) - {1}".format(
393+
eid, self._strip_ansi_codes(msg, "`")
394+
)
389395
for eid, msg in self.fixed
390396
]
391397
)
@@ -398,7 +404,9 @@ def _get_results_md(self):
398404
test_warnings = "### :heavy_exclamation_mark: Test warnings:\n\n{}\n\n".format(
399405
"\n".join(
400406
[
401-
"* [{0}](https://nf-co.re/errors#{0}) - {1}".format(eid, self._strip_ansi_codes(msg, "`"))
407+
"* [{0}](https://nf-co.re/tools-docs/lint_tests/{0}.html) - {1}".format(
408+
eid, self._strip_ansi_codes(msg, "`")
409+
)
402410
for eid, msg in self.warned
403411
]
404412
)
@@ -411,7 +419,9 @@ def _get_results_md(self):
411419
test_passes = "### :white_check_mark: Tests passed:\n\n{}\n\n".format(
412420
"\n".join(
413421
[
414-
"* [{0}](https://nf-co.re/errors#{0}) - {1}".format(eid, self._strip_ansi_codes(msg, "`"))
422+
"* [{0}](https://nf-co.re/tools-docs/lint_tests/{0}.html) - {1}".format(
423+
eid, self._strip_ansi_codes(msg, "`")
424+
)
415425
for eid, msg in self.passed
416426
]
417427
)

nf_core/lint/merge_markers.py

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,21 +24,23 @@ def merge_markers(self):
2424
with io.open(os.path.join(self.wf_path, ".gitignore"), "rt", encoding="latin1") as fh:
2525
for l in fh:
2626
ignore.append(os.path.basename(l.strip().rstrip("/")))
27-
for root, dirs, files in os.walk(self.wf_path):
27+
for root, dirs, files in os.walk(self.wf_path, topdown=True):
2828
# Ignore files
29-
for i in ignore:
30-
dirs = [d for d in dirs if not fnmatch.fnmatch(os.path.join(root, d), i)]
31-
files = [f for f in files if not fnmatch.fnmatch(os.path.join(root, f), i)]
29+
for i_base in ignore:
30+
i = os.path.join(root, i_base)
31+
dirs[:] = [d for d in dirs if not fnmatch.fnmatch(os.path.join(root, d), i)]
32+
files[:] = [f for f in files if not fnmatch.fnmatch(os.path.join(root, f), i)]
3233
for fname in files:
3334
try:
3435
with io.open(os.path.join(root, fname), "rt", encoding="latin1") as fh:
3536
for l in fh:
3637
if ">>>>>>>" in l:
37-
failed.append(f"Merge marker in `{fname}`: {l}")
38+
failed.append(f"Merge marker '>>>>>>>' in `{os.path.join(root, fname)}`: {l}")
3839
if "<<<<<<<" in l:
39-
failed.append(f"Merge marker in `{fname}`: {l}")
40+
failed.append(f"Merge marker '<<<<<<<' in `{os.path.join(root, fname)}`: {l}")
41+
print(root)
4042
except FileNotFoundError:
41-
log.debug(f"Could not open file {fname} in merge_markers lint test")
43+
log.debug(f"Could not open file {os.path.join(root, fname)} in merge_markers lint test")
4244
if len(failed) == 0:
4345
passed.append("No merge markers found in pipeline files")
4446
return {"passed": passed, "failed": failed}

nf_core/lint/pipeline_todos.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,11 +42,12 @@ def pipeline_todos(self):
4242
with io.open(os.path.join(self.wf_path, ".gitignore"), "rt", encoding="latin1") as fh:
4343
for l in fh:
4444
ignore.append(os.path.basename(l.strip().rstrip("/")))
45-
for root, dirs, files in os.walk(self.wf_path):
45+
for root, dirs, files in os.walk(self.wf_path, topdown=True):
4646
# Ignore files
47-
for i in ignore:
48-
dirs = [d for d in dirs if not fnmatch.fnmatch(os.path.join(root, d), i)]
49-
files = [f for f in files if not fnmatch.fnmatch(os.path.join(root, f), i)]
47+
for i_base in ignore:
48+
i = os.path.join(root, i_base)
49+
dirs[:] = [d for d in dirs if not fnmatch.fnmatch(os.path.join(root, d), i)]
50+
files[:] = [f for f in files if not fnmatch.fnmatch(os.path.join(root, f), i)]
5051
for fname in files:
5152
try:
5253
with io.open(os.path.join(root, fname), "rt", encoding="latin1") as fh:

nf_core/lint/template_strings.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/usr/bin/env python
22

33
import io
4-
import os
4+
import mimetypes
55
import re
66

77

@@ -26,11 +26,18 @@ def template_strings(self):
2626
# Loop through files, searching for string
2727
num_matches = 0
2828
for fn in self.files:
29+
30+
# Skip binary files
31+
binary_ftypes = ["image", "application/java-archive"]
32+
(ftype, encoding) = mimetypes.guess_type(fn)
33+
if encoding is not None or (ftype is not None and any([ftype.startswith(ft) for ft in binary_ftypes])):
34+
continue
35+
2936
with io.open(fn, "r", encoding="latin1") as fh:
3037
lnum = 0
3138
for l in fh:
3239
lnum += 1
33-
cc_matches = re.findall(r"[^$]{{[^}]*}}", l)
40+
cc_matches = re.findall(r"[^$]{{[^:}]*}}", l)
3441
if len(cc_matches) > 0:
3542
for cc_match in cc_matches:
3643
failed.append("Found a Jinja template string in `{}` L{}: {}".format(fn, lnum, cc_match))

nf_core/modules/lint.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,10 @@ def lint(self, module=None, all_modules=False, print_results=True, show_passed=F
9898
if len(nfcore_modules) == 0:
9999
raise ModuleLintException(f"Could not find the specified module: '{module}'")
100100

101-
log.info(f"Linting pipeline: [magenta]{self.dir}")
101+
if self.repo_type == "modules":
102+
log.info(f"Linting modules repo: [magenta]{self.dir}")
103+
else:
104+
log.info(f"Linting pipeline: [magenta]{self.dir}")
102105
if module:
103106
log.info(f"Linting module: [magenta]{module}")
104107

nf_core/modules/pipeline_modules.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,8 @@ def list_modules(self, print_json=False):
161161

162162
# No pipeline given - show all remote
163163
if self.pipeline_dir is None:
164+
log.info(f"Modules available from {self.modules_repo.name} ({self.modules_repo.branch}):\n")
165+
164166
# Get the list of available modules
165167
self.modules_repo.get_modules_file_tree()
166168
modules = self.modules_repo.modules_avail_module_names
@@ -171,6 +173,8 @@ def list_modules(self, print_json=False):
171173

172174
# We have a pipeline - list what's installed
173175
else:
176+
log.info(f"Modules installed in '{self.pipeline_dir}':\n")
177+
174178
# Check whether pipelines is valid
175179
try:
176180
self.has_valid_pipeline()
@@ -185,7 +189,6 @@ def list_modules(self, print_json=False):
185189
log.info(f"No nf-core modules found in '{self.pipeline_dir}'")
186190
return ""
187191

188-
log.info("Modules available from {} ({}):\n".format(self.modules_repo.name, self.modules_repo.branch))
189192
for mod in sorted(modules):
190193
table.add_row(mod)
191194
if print_json:

0 commit comments

Comments
 (0)