RO-crate content appear in the nf-core lint warning if there is a TODO#3493
RO-crate content appear in the nf-core lint warning if there is a TODO#3493ningyuxin1999 merged 59 commits intonf-core:devfrom
Conversation
mirpedrol
left a comment
There was a problem hiding this comment.
leaving a couple of comments, otherwise is looking good!
Co-authored-by: Júlia Mir Pedrol <[email protected]>
Co-authored-by: Júlia Mir Pedrol <[email protected]>
Co-authored-by: Júlia Mir Pedrol <[email protected]>
Co-authored-by: Júlia Mir Pedrol <[email protected]>
Codecov ReportAttention: Patch coverage is
☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
can we also add a test for the fix functionality? |
| - 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 |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
| - 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 |
Co-authored-by: Júlia Mir Pedrol <[email protected]>
Co-authored-by: Júlia Mir Pedrol <[email protected]>
Co-authored-by: Júlia Mir Pedrol <[email protected]>
Co-authored-by: Júlia Mir Pedrol <[email protected]>
Co-authored-by: Júlia Mir Pedrol <[email protected]>
Yes, I added a new test into the test script. |
mirpedrol
left a comment
There was a problem hiding this comment.
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.
| 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." | ||
| ) |
There was a problem hiding this comment.
| 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 |
There was a problem hiding this comment.
| 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 |
| with open(json_path, "w") as f: | ||
| f.write('{ "@graph": [{"description": "This is a test script"}] }') |
There was a problem hiding this comment.
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 😄
| 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) |
There was a problem hiding this comment.
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.
Co-authored-by: Júlia Mir Pedrol <[email protected]>
|
okay, I found why the CI is failing. When we remove the todo statements in https://github.com/nf-core/tools/blob/main/.github/actions/create-lint-wf/action.yml#L52 we remove the whole line. which also removed the description part. I changed it to only remove the specific words concerning fefac22: the ro-crates are genereated during the |
Changes:
RO-crate-metadata.jsonis ignored in lintingnf_core/pipelines/lint/rocrate_readme_sync.pyfor 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
--fixflag so that the use can decide whether they want to synchronize the metadata with the readme file.PR checklist
CHANGELOG.mdis updateddocsis updated