Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Pull request overview
This PR makes modules.json formatting consistent by defaulting ModulesJson.dump() to run Prettier, so that nf-core commands stop rewriting the file in a non-prettified layout (notably around installed_by).
Changes:
- Change
ModulesJson.dump()default torun_prettier=True. - Update call sites to rely on the new default (
dump()instead ofdump(run_prettier=True)). - Add a changelog entry documenting the behavior change.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| nf_core/modules/modules_json.py | Switch default dump behavior to run Prettier and update internal usage. |
| nf_core/components/install.py | Use the new ModulesJson.dump() default during component install. |
| CHANGELOG.md | Document “Always prettify modules.json”. |
Comments suppressed due to low confidence (1)
nf_core/modules/modules_json.py:1136
- Changing
ModulesJson.dump()default to run Prettier will now invokepre-commit run prettieron every internal call site that previously relied on the default (eg.ModulesJson.update(),remove_entry(),check_up_to_date()and others callself.dump()potentially many times in loops / recursive installs). This can significantly slow down installs/updates and make repeated writes much more expensive. Consider keeping the defaultFalseand only running Prettier once at the end of a user-facing command, or refactoring so callers that do multiple updates can disable intermediate writes / formatting and do a single prettified dump at the end.
def dump(self, run_prettier: bool = True) -> None:
"""
Sort the modules.json, and write it to file
"""
# Sort the modules.json
if self.modules_json is None:
self.load()
if self.modules_json is not None:
self.modules_json["repos"] = nf_core.utils.sort_dictionary(self.modules_json["repos"])
if run_prettier:
dump_json_with_prettier(self.modules_json_path, self.modules_json)
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
mashehu
left a comment
There was a problem hiding this comment.
will make some commands slower, but can optimize for that in another PR.
|
Let me take a look and try to optimise it now. |
90d9e49 to
fdeddee
Compare
|
New version. I'm adding |
|
Added support for one scenario: manual install of a module that was already installed via a sub-workflow. |
|
Thank you ! |
I got a bit tired of having to re-run prettier after nf-core commands because they change the layout of
modules.json(especially aroundinstalled_by).This is a patch to make prettier the default write mode for modules.json
PR checklist
CHANGELOG.mdis updateddocsis updated