Skip to content

Include org details from the manifest into the RO-Crate - #4628

Open
muffato wants to merge 16 commits into
devfrom
manifest_org_details
Open

muffato wants to merge 16 commits into
devfrom
manifest_org_details

Conversation

@muffato

@muffato muffato commented Nov 20, 2026 •

Copy link
Copy Markdown
Member

Alternative to #4146

My goal here is to make the RO-Crates more accurate by using actual correct org details (URL and name) for 3rd-party orgs that use the nf-core tooling. RO-Crates are indeed automatically updated by nf-core at every template update and version bump. Fixing them every time is quite time consuming.

This time, rather than introducing template parameters, I hijack existing manifest values:

  • organization is used as the full name of the org. In other places, e.g. topics, the bit before / in the pipeline name (nf-core/testpipeline → nf-core) is used as the short name of the org.
  • docsUrl is used as:
    1. the URL of the org itself
    2. the base for pipeline/version-specific documentation URLs: <docsUrl>/$pipeline_name/$version. The code tests those URLs with a http HEAD request and only includes it in the RO-Crate if valid.

And simply use them instead of https://nf-co.re and nf-core, while still defaulting to these values when the keys are not present in the manifest. This way, in usual nf-core pipelines, since these are not used, nothing changes. And external orgs now have the possibility to define them as they wish.

This makes the change much shorter, with far less maintenance burden than my previous attempt.

PR checklist

  • This comment contains a description of changes (with reason)
  • CHANGELOG.md is updated
  • If you've fixed a bug or added code that should be tested, add tests!
  • Documentation in docs is updated

@codecov

codecov Bot commented Nov 20, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 85.71429% with 4 lines in your changes missing coverage. Please review.
✅ Project coverage is 78.91%. Comparing base (1f41ed7) to head (ce6e6b5).
⚠️ Report is 1 commits behind head on dev.

Files with missing lines Patch % Lines
nf_core/pipelines/rocrate.py 85.71% 4 Missing ⚠️

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@codspeed

codspeed Bot commented Nov 20, 2026 •

Copy link
Copy Markdown
Contributor

Merging this PR will not alter performance

1 warning

⚠️ Walltime results may be unreliable

Some benchmarks used the Walltime instrument outside CodSpeed Macro Runners, which can make the results inconsistent.

Learn more about Macro Runners

See affected benchmarks

✅ 12 untouched benchmarks
⏩ 4 skipped benchmarks1


Comparing manifest_org_details (ce6e6b5) with dev (fbb403c)

Open in CodSpeed

Footnotes

  1. 4 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports. ↩

@muffato muffato self-assigned this Nov 20, 2026
@muffato
muffato force-pushed the manifest_org_details branch from 98ad5ea to 4317734 Compare November 20, 2026 15:06
@muffato
muffato marked this pull request as ready for review November 20, 2026 15:06
@prototaxites

Copy link
Copy Markdown
Contributor

docsUrl

Is this something where we should actually request an organizationUrl in the manifest? I would rather expect this manifest parameter to point directly at the docs.

Comment thread nf_core/pipelines/rocrate.py Outdated
self.crate.mainEntity.append_to(
"url", f"https://nf-co.re/{self.crate.name.replace('nf-core/', '')}/{url}/", compact=True
)
self.crate.mainEntity.append_to("url", f"{org_website}/{pipeline_short_name}/{url}/", compact=True)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are we happy to assume that non-nf-core pipeline webistes use this structure and have a pipelines.json file?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Converting back to draft because I've got an idea to tackle this

@muffato

muffato commented Nov 20, 2026

Copy link
Copy Markdown
Member Author

Are we happy to assume that non-nf-core pipeline webistes use this structure and have a pipelines.json file?

By the way there's a fallback in the code.

Is this something where we should actually request an organizationUrl in the manifest? I would rather expect this manifest parameter to point directly at the docs.

Those are the main questions indeed. There are two URL fields in the manifest: homePage is already set to the GitHub URL, so docsUrl is the only one I had left.
I'd argue that https://nf-co.re is where all the docs are, so it can work as docsUrl 😅

@eduard-watchmaker eduard-watchmaker left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One regression and a few small things:

  1. rocrate.py:194 and :218: the template doesn't set docsUrl, so nf-core pipelines use the default. .rstrip("/") turns it into https://nf-co.re, so the Organization @id/url and sdPublisher change from https://nf-co.re/. Every pipeline's ro-crate-metadata.json would change at the next sync. Could the default stay as is, and the slash only be stripped when building paths?
  2. manifest.get(key, default) only falls back when the key is missing. docsUrl = '' or organization = '' gives an empty @id. Using manifest.get("docsUrl") or "https://nf-co.re/" and computing it once would cover both.
  3. rocrate.py:239: topics = ["nf-core", "nextflow"] still tags every crate with nf-core. org_name would fit the goal of the PR.
  4. The new test checks only the Organization name and url. Assertions on sdPublisher, mainEntity.url, the topics fetched from the mocked pipelines.json, and the default case would catch point 1.

This was generated assisted by Claude code and checked by me.

@muffato
muffato force-pushed the manifest_org_details branch from 9bbca77 to f5005aa Compare November 20, 2026 22:49
@muffato
muffato force-pushed the manifest_org_details branch from 165fba8 to d35a60b Compare November 20, 2026 23:06
@muffato

muffato commented Nov 20, 2026

Copy link
Copy Markdown
Member Author

Thanks @eduard-watchmaker !

  1. Not important because the ro-crates aren't stable in the first place. They contain timestamps and UUIDs that change all the time
  2. Fixed
  3. I had missed that. Fixed
  4. Tests updated

@eduard-watchmaker eduard-watchmaker left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, all points are addressed. Fair point on the trailing slash, as the crates change on every sync anyway.

This was generated assisted by Claude code and checked by me.

@muffato
muffato marked this pull request as draft November 21, 2026 13:36
@muffato
muffato marked this pull request as ready for review November 22, 2026 11:28
@muffato

muffato commented Nov 22, 2026

Copy link
Copy Markdown
Member Author

Hi. Requesting a new review as I've reworked the use of those two keys.
Especially, I now don't require /pipelines.json any more as keywords (topics) are pulled from GitHub directly. And <docsUrl>/$pipeline_name/$version URLs are only included if valid (http HEAD request).

@eduard-watchmaker eduard-watchmaker left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks Matthieu, pulling topics from GitHub is a nice simplification. The URL check doesn't filter anything yet, and the tests make real network calls. Details inline.

This was generated assisted by Claude code and checked by me.

url = "/".join((org_website, pipeline_short_name, "dev" if self.version.endswith("dev") else self.version))
try:
# Check that the URL is valid
response = requests.head(url, allow_redirects=True, timeout=10)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

requests.head only raises on a connection error, not on a 404, so the URL is always added when the host is reachable. Something like if requests.head(url, allow_redirects=True, timeout=10).ok: would do what the PR says.

The tests don't mock requests.head, so test_rocrate_creation_uses_manifest_org_details makes a real HEAD to https://www.example.com/testpipeline/dev. That page is a 404, so the test only passes because of the missing status check. It would also fail offline. Could requests.head be mocked next to requests.get?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added if response.ok and updated the tests to mock HEAD too

Comment thread nf_core/pipelines/rocrate.py Outdated
topics.append(org_short_name)
try:
response = requests.get("https://nf-co.re/pipelines.json", timeout=10)
response = requests.get(f"https://api.github.com/repos/{self.crate.name}/topics")

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This has no timeout, unlike the other calls, and it's unauthenticated, so it's limited to 60 requests an hour. That limit is easy to hit on a sync across many pipelines. gh_api.safe_get from nf_core.github_api uses the token when one is set. If you switch to it, the test mock needs to follow.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've switched over to gh_api.safe_get here and in the name lookups !

Comment thread nf_core/pipelines/rocrate.py Outdated
response = requests.get(f"https://api.github.com/repos/{self.crate.name}/topics")
response.raise_for_status()
remote_workflows = response.json()["remote_workflows"]
for topic in response.json().get("names"):

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the response has no names key, .get("names") returns None and the loop raises a TypeError. The except doesn't catch that. response.json()["names"] would go to the existing KeyError fallback.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed to ["names"]

@muffato
muffato force-pushed the manifest_org_details branch from 048e6d7 to 8b40cd7 Compare November 23, 2026 13:18
@muffato

muffato commented Nov 23, 2026

Copy link
Copy Markdown
Member Author

Thank you for the review. I have addressed all the comments

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants