-
Notifications
You must be signed in to change notification settings - Fork 201
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
base: dev
Are you sure you want to change the base?
Conversation
There was a problem hiding this 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!
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]>
@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("{}") |
There was a problem hiding this comment.
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.
There was a problem hiding this 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
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? |
There was a problem hiding this 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 |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can be removed
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. |
There was a problem hiding this 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.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
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 😄
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.
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.
Co-authored-by: Júlia Mir Pedrol <[email protected]>
Changes:
RO-crate-metadata.json
is ignored in lintingnf_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
CHANGELOG.md
is updateddocs
is updated