Skip to content

Commit 5e39aa4

Browse files
committed
Merge branch 'feat/topics' of github.com:nvnieuwk/tools into feat/topics
2 parents 4500ae5 + 8ffc35f commit 5e39aa4

File tree

5 files changed

+23
-62
lines changed

5 files changed

+23
-62
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44

55
### General
66

7+
- update multiqc version to fix utils test ([#3853](https://github.com/nf-core/tools/pull/3853))
8+
79
### Template
810

911
### Linting

nf_core/pipeline-template/.github/workflows/release-announcements.yml

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,9 @@ jobs:
1515
echo "topics=$(curl -s https://nf-co.re/pipelines.json | jq -r '.remote_workflows[] | select(.full_name == "${{ github.repository }}") | .topics[]' | awk '{print "#"$0}' | tr '\n' ' ')" | sed 's/-//g' >> $GITHUB_OUTPUT
1616
1717
- name: get description
18-
id: get_topics
18+
id: get_description
1919
run: |
20-
echo "description=$(curl -s https://nf-co.re/pipelines.json | jq -r '.remote_workflows[] | select(.full_name == "${{ github.repository }}") | .description' >> $GITHUB_OUTPUT
21-
20+
echo "description=$(curl -s https://nf-co.re/pipelines.json | jq -r '.remote_workflows[] | select(.full_name == "${{ github.repository }}") | .description')" >> $GITHUB_OUTPUT
2221
- uses: rzr/fediverse-action@master
2322
with:
2423
access-token: ${{ secrets.MASTODON_ACCESS_TOKEN }}
@@ -27,9 +26,7 @@ jobs:
2726
# https://docs.github.com/en/developers/webhooks-and-events/webhooks/webhook-events-and-payloads#release
2827
message: |
2928
Pipeline release! ${{ github.repository }} v${{ github.event.release.tag_name }} - ${{ github.event.release.name }}!
30-
31-
${{ steps.get_topics.outputs.description }}
32-
29+
${{ steps.get_description.outputs.description }}
3330
Please see the changelog: ${{ github.event.release.html_url }}
3431
3532
${{ steps.get_topics.outputs.topics }} #nfcore #openscience #nextflow #bioinformatics

nf_core/pipelines/lint/rocrate_readme_sync.py

Lines changed: 12 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,12 @@
88
def rocrate_readme_sync(self):
99
"""
1010
Check if the RO-Crate description in ro-crate-metadata.json matches the README.md content.
11-
If the --fix is set, the RO-Crate description will be updated to match the README.md content.
11+
If not, the RO-Crate description will be automatically updated to match the README.md content during linting.
1212
"""
1313

1414
passed = []
15-
failed = []
1615
ignored = []
1716
fixed = []
18-
could_fix: bool = False
1917

2018
# Check if the file exists before trying to load it
2119
metadata_file = Path(self.wf_path, "ro-crate-metadata.json")
@@ -27,46 +25,35 @@ def rocrate_readme_sync(self):
2725
ignored.append("`ro-crate-metadata.json` not found")
2826
if not readme_file.exists():
2927
ignored.append("`README.md` not found")
30-
return {"passed": passed, "failed": failed, "ignored": ignored}
28+
return {"passed": passed, "fixed": fixed, "ignored": ignored}
3129

3230
try:
3331
metadata_content = metadata_file.read_text(encoding="utf-8")
3432
metadata_dict = json.loads(metadata_content)
3533
except json.JSONDecodeError as e:
3634
log.error("Failed to decode JSON from `ro-crate-metadata.json`: %s", e)
3735
ignored.append("Invalid JSON in `ro-crate-metadata.json`")
38-
return {"passed": passed, "failed": failed, "ignored": ignored}
36+
return {"passed": passed, "fixed": fixed, "ignored": ignored}
3937
readme_content = readme_file.read_text(encoding="utf-8")
4038
graph = metadata_dict.get("@graph")
39+
4140
if not graph or not isinstance(graph, list) or not graph[0] or not isinstance(graph[0], dict):
4241
ignored.append("Invalid RO-Crate metadata structure.")
4342
else:
4443
# Check if the 'description' key is present
4544
if "description" not in graph[0]:
46-
if "rocrate_readme_sync" in self.fix:
47-
metadata_dict.get("@graph")[0]["description"] = readme_content
48-
fixed.append("Fixed: add the same description from `README.md` to the RO-Crate metadata.")
49-
else:
50-
ignored.append("No description found in `ro-crate-metadata.json`.")
51-
return {"passed": passed, "failed": failed, "ignored": ignored}
45+
metadata_dict.get("@graph")[0]["description"] = readme_content
46+
fixed.append("Fixed: add the same description from `README.md` to the RO-Crate metadata.")
5247

5348
rc_description_graph = metadata_dict.get("@graph", [{}])[0].get("description")
5449

5550
# Compare the two strings and add a linting error if they don't match
5651
if readme_content != rc_description_graph:
57-
# If the --fix flag is set, you could overwrite the RO-Crate description with the README content:
58-
if "rocrate_readme_sync" in self.fix:
59-
metadata_dict.get("@graph")[0]["description"] = readme_content
60-
fixed.append("Fixed: add the same description from `README.md` to the RO-Crate metadata.")
61-
with metadata_file.open("w", encoding="utf-8") as f:
62-
json.dump(metadata_dict, f, indent=4)
63-
passed.append("RO-Crate description matches the `README.md`.")
64-
fixed.append("Mismatch fixed: RO-Crate description updated from `README.md`.")
65-
else:
66-
failed.append(
67-
"The RO-Crate descriptions do not match the README.md content. Use `nf-core pipelines lint --fix rocrate_readme_sync` to update."
68-
)
69-
could_fix = True
52+
metadata_dict.get("@graph")[0]["description"] = readme_content
53+
with metadata_file.open("w", encoding="utf-8") as f:
54+
json.dump(metadata_dict, f, indent=4)
55+
passed.append("RO-Crate description matches the `README.md`.")
56+
fixed.append("Mismatch fixed: RO-Crate description updated from `README.md`.")
7057
else:
7158
passed.append("RO-Crate descriptions are in sync with `README.md`.")
72-
return {"passed": passed, "failed": failed, "ignored": ignored, "fixed": fixed, "could_fix": could_fix}
59+
return {"passed": passed, "fixed": fixed, "ignored": ignored}

tests/pipelines/lint/test_rocrate_readme_sync.py

Lines changed: 1 addition & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -12,25 +12,6 @@ def test_rocrate_readme_sync_pass(self):
1212
assert len(results.get("failed", [])) == 0
1313
assert len(results.get("passed", [])) > 0
1414

15-
def test_rocrate_readme_sync_fail(self):
16-
self.lint_obj._load()
17-
18-
json_path = Path(self.lint_obj.wf_path, "ro-crate-metadata.json")
19-
with open(json_path) as f:
20-
try:
21-
rocrate = json.load(f)
22-
except json.JSONDecodeError as e:
23-
raise UserWarning(f"Unable to load JSON file '{json_path}' due to error {e}")
24-
rocrate["@graph"][0]["description"] = "This is a test script"
25-
with open(json_path, "w") as f:
26-
json.dump(rocrate, f, indent=4)
27-
results = self.lint_obj.rocrate_readme_sync()
28-
assert len(results.get("failed", [])) == 1
29-
assert (
30-
"The RO-Crate descriptions do not match the README.md content. Use `nf-core pipelines lint --fix rocrate_readme_sync` to update."
31-
in results.get("failed", [])
32-
)
33-
3415
def test_rocrate_readme_sync_fixed(self):
3516
self.lint_obj._load()
3617
json_path = Path(self.lint_obj.wf_path, "ro-crate-metadata.json")
@@ -43,12 +24,6 @@ def test_rocrate_readme_sync_fixed(self):
4324
with open(json_path, "w") as f:
4425
json.dump(rocrate, f, indent=4)
4526

46-
results = self.lint_obj.rocrate_readme_sync()
47-
assert len(results.get("failed", [])) == 1
48-
49-
# Fix the issue
50-
assert "rocrate_readme_sync" in self.lint_obj.lint_tests
51-
self.lint_obj.fix = ["rocrate_readme_sync"]
52-
self.lint_obj._load()
5327
results = self.lint_obj.rocrate_readme_sync()
5428
assert len(results.get("failed", [])) == 0
29+
assert len(results.get("fixed", [])) == 1

tests/test_utils.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ def test_request_cant_create_cache(self, mock_exists, mock_mkdir):
107107
nf_core.utils.setup_requests_cachedir()
108108

109109
def test_pip_package_pass(self):
110-
result = nf_core.utils.pip_package("multiqc=1.10")
110+
result = nf_core.utils.pip_package("multiqc=1.32")
111111
assert isinstance(result, dict)
112112

113113
@mock.patch("requests.get")
@@ -118,7 +118,7 @@ def test_pip_package_timeout(self, mock_get):
118118
mock_get.side_effect = requests.exceptions.Timeout()
119119
# Now do the test
120120
with pytest.raises(LookupError):
121-
nf_core.utils.pip_package("multiqc=1.10")
121+
nf_core.utils.pip_package("multiqc=1.32")
122122

123123
@mock.patch("requests.get")
124124
def test_pip_package_connection_error(self, mock_get):
@@ -128,7 +128,7 @@ def test_pip_package_connection_error(self, mock_get):
128128
mock_get.side_effect = requests.exceptions.ConnectionError()
129129
# Now do the test
130130
with pytest.raises(LookupError):
131-
nf_core.utils.pip_package("multiqc=1.10")
131+
nf_core.utils.pip_package("multiqc=1.32")
132132

133133
def test_pip_erroneous_package(self):
134134
"""Tests the PyPi API package information query"""
@@ -151,10 +151,10 @@ def test_get_repo_releases_branches_not_nf_core(self):
151151
wfs.get_remote_workflows()
152152
pipeline, wf_releases, wf_branches = nf_core.utils.get_repo_releases_branches("MultiQC/MultiQC", wfs)
153153
for r in wf_releases:
154-
if r.get("tag_name") == "v1.10":
154+
if r.get("tag_name") == "v1.32":
155155
break
156156
else:
157-
raise AssertionError("MultiQC release v1.10 not found")
157+
raise AssertionError("MultiQC release v1.32 not found")
158158
assert "main" in wf_branches.keys()
159159

160160
def test_get_repo_releases_branches_not_exists(self):

0 commit comments

Comments
 (0)