Skip to content

RO-crate content appear in the nf-core lint warning if there is a TODO #3493

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 55 commits into
base: dev
Choose a base branch
from

Conversation

ningyuxin1999
Copy link

@ningyuxin1999 ningyuxin1999 commented Mar 17, 2025

Changes:

  1. The RO-crate-metadata.json is ignored in linting
  2. Added a test script nf_core/pipelines/lint/rocrate_readme_sync.py for synchronizing the content of ROcrate metadata and the repo README.

The warning message mentioned here disappears when you create a new pipeline without deleting the TODO commands. But I still wonder where I should add the --fix flag so that the use can decide whether they want to synchronize the metadata with the readme file.

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

Copy link
Member

@mirpedrol mirpedrol left a comment

Choose a reason for hiding this comment

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

leaving a couple of comments, otherwise is looking good!

@ningyuxin1999
Copy link
Author

@mirpedrol Hey Julia, could you maybe please quickly have a look at the changes again and this would be ready to merge? And I'm also not sure why the pending checks are not running ...

^^Thank you very much in advance!


json_path = Path(self.lint_obj.wf_path, "ro-crate-metadata.json")
with open(json_path, "w") as f:
f.write("{}")
Copy link
Contributor

Choose a reason for hiding this comment

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

I would parse it as as JSON and just change the description with some random text, to avoid off targets.

Copy link
Contributor

@mashehu mashehu left a comment

Choose a reason for hiding this comment

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

There is some problem with the self-hosted runners atm, so that they don't pick up any jobs. fix is on the way
Fixed

Copy link

codecov bot commented Apr 15, 2025

Codecov Report

Attention: Patch coverage is 69.38776% with 15 lines in your changes missing coverage. Please review.

Project coverage is 76.53%. Comparing base (619df2e) to head (5d8045a).

Files with missing lines Patch % Lines
nf_core/pipelines/lint/rocrate_readme_sync.py 68.75% 15 Missing ⚠️

☔ View full report in Codecov by Sentry.
📢 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.

@mashehu
Copy link
Contributor

mashehu commented Apr 15, 2025

can we also add a test for the fix functionality?

Copy link
Member

@mirpedrol mirpedrol left a comment

Choose a reason for hiding this comment

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

some last suggestions 🙂

working-directory: create-lint-wf

# Run nf-core pipelines linting
- name: nf-core pipelines lint
shell: bash
run: nf-core --verbose --log-file log.txt --hide-progress pipelines lint --dir nf-core-testpipeline --fail-ignored --fail-warned
run: nf-core --verbose --log-file log.txt --hide-progress pipelines lint --fix rocrate_readme_sync --dir nf-core-testpipeline --fail-ignored --fail-warned
Copy link
Member

Choose a reason for hiding this comment

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

Was this failing with adding the --fix argument? 🤔 I think we shouldn't add it here, since we want the fresh template to be a valid pipeline

Copy link
Author

Choose a reason for hiding this comment

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

I changed the script so the rocreate_readme_sync function would directly copy the description from the README.md if there's no description key found, therefore there won't be an ignored case added in such situation.

@@ -83,7 +83,7 @@ runs:

- name: nf-core pipelines lint in release mode
shell: bash
run: nf-core --log-file log.txt --hide-progress pipelines lint --dir nf-core-testpipeline --fail-ignored --fail-warned --release
run: nf-core --log-file log.txt --hide-progress pipelines lint --dir nf-core-testpipeline --fix rocrate_readme_sync --fail-ignored --fail-warned --release
Copy link
Member

Choose a reason for hiding this comment

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

same as I mentioned before

log.txt Outdated
Copy link
Member

Choose a reason for hiding this comment

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

can be removed

@ningyuxin1999
Copy link
Author

can we also add a test for the fix functionality?

Yes, I added a new test into the test script.

Copy link
Member

@mirpedrol mirpedrol left a comment

Choose a reason for hiding this comment

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

This is what I would do with the description, it adds it when we use the flag --fix, and the test is ignored if we don't have a description. The CI test should pass, but showt if it doesn't and I will have another look.

Comment on lines 45 to 49
if "description" not in graph[0]:
graph[0]["description"] = readme_content
passed.append(
"No description found in `ro-crate-metadata.json`, add the same description from `README.md` to the RO-Crate metadata."
)
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
if "description" not in graph[0]:
graph[0]["description"] = readme_content
passed.append(
"No description found in `ro-crate-metadata.json`, add the same description from `README.md` to the RO-Crate metadata."
)
if "description" not in graph[0]:
ignored.append(
"No description found in `ro-crate-metadata.json`."
)

if readme_content != rc_description_graph:
# If the --fix flag is set, you could overwrite the RO-Crate description with the README content:
if "rocrate_readme_sync" in self.fix:
metadata_dict.get("@graph")[0]["description"] = readme_content
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
metadata_dict.get("@graph")[0]["description"] = readme_content
if "description" not in graph[0]:
graph[0]["description"] = readme_content
fixed.append(
"Fixed: add the same description from `README.md` to the RO-Crate metadata."
)
return {"passed": passed, "failed": failed, "ignored": ignored, "fixed": fixed, "could_fix": could_fix}
metadata_dict.get("@graph")[0]["description"] = readme_content

Comment on lines 18 to 19
with open(json_path, "w") as f:
f.write('{ "@graph": [{"description": "This is a test script"}] }')
Copy link
Member

Choose a reason for hiding this comment

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

To parse the file as a JSON you can use the library json as you did in nf_core/pipelines/lint/rocrate_readme_sync.py. This code is untested so make sure that I didn't make any mistake before accepting the suggestion 😄

Suggested change
with open(json_path, "w") as f:
f.write('{ "@graph": [{"description": "This is a test script"}] }')
with open(json_path, "rw") as f:
try:
rocrate = json.load(fh)
except json.JSONDecodeError as e:
raise UserWarning(f"Unable to load JSON file '{json_path}' due to error {e}")
rocrate["@graph"][0]["description"] = "This is a test script"
json.dump(rocrate, fh, indent=4)

Copy link
Author

Choose a reason for hiding this comment

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

Thanks Julia!
The tests are still failing. it seems like in the git actions, the rocrate created a metadata file without the description key.In this case, when the --fix is not provided, the tests will anyway fail all the ignored tests.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: In progress
Development

Successfully merging this pull request may close these issues.

3 participants