-
Notifications
You must be signed in to change notification settings - Fork 192
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
Give better suggestion when modules.json file is out-of-date. #1741
Conversation
…x-suggestion # Conflicts: # nf_core/modules/modules_json.py
Codecov Report
@@ Coverage Diff @@
## dev #1741 +/- ##
==========================================
+ Coverage 69.14% 69.22% +0.08%
==========================================
Files 59 59
Lines 7133 7142 +9
==========================================
+ Hits 4932 4944 +12
+ Misses 2201 2198 -3
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. |
@nf-core-bot fix linting |
I think that a better solution would be to call the |
…json file run also `check_up_to_date`, which now rebuilds outdates files
nf_core/modules/modules_json.py
Outdated
self.load() | ||
if not self.has_git_url_and_base_path(): | ||
raise UserWarning( | ||
"The 'modules.json' file is not up to date. " "You can fix it by running 'nf-core modules update'." | ||
) | ||
log.info("The 'modules.json' file is not up to date. Recreating the 'module.json' file.") | ||
self.create() | ||
self.load() |
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'd say it would be better with a try catch block around the call to self.load
that catches the LookupError
that it will throw if the file does not exist. You could also assign the modules_json
variable to self.modules_json
in create
and skip the second call to load
since there should be no need to go via the file.
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.
Good idea, changed it accordingly.
Now I am actually wondering, if we need all of the
if self.modules_json is None:
self.load()
in the different submethods, when they are (as far as I saw) all called after a check_up_to_date()
call. Or is that just to be extra sure for future methods?
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.
Sounds good. Just grep for the creation of ModulesJson
objects and make sure that they are not created without check_up_to_date
being called. This will atleast be true for some tests.
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 think I will actually leave it for now. Too many possible downstream effects, I might not be aware of now. But I added a test for .check_up_to_date()
, so this PR should be good to go. 🙂
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 starting to look good!
raise UserWarning(f"Could not find a 'main.nf' or 'nextflow.config' file in '{self.dir}'") | ||
self.has_modules_file() | ||
return True |
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'm not sure I'm following why you removed this line, and added it as standalone calls (:
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.
we discussed this on slack: all commands that used this function use check_up_to_date
anyway, except for linting. So I kept it there.
…e check for missing `git_sha` and `branch` fields in it
…path) and return booleans instead of warnings
Co-authored-by: Fabian Egli <fabianegli@users.noreply.github.com>
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.
After #1754 is merged, there are some conflicts to resolve. Apart from that, if the comments from other reviewers are solved, it looks good to me :)
tests/modules/modules_json.py
Outdated
def test_mod_json_with_missing_base_path_entry(self): | ||
# Load module.json and remove the base_path entry | ||
mod_json_obj = ModulesJson(self.pipeline_dir) | ||
mod_json_orig = mod_json_obj.get_modules_json() | ||
mod_json = copy.deepcopy(mod_json_orig) | ||
mod_json["repos"]["nf-core/modules"].pop("base_path") | ||
# save the altered module.json and load it again to check if it will fix itself | ||
mod_json_obj.modules_json = mod_json | ||
mod_json_obj.dump() | ||
mod_json_obj_new = ModulesJson(self.pipeline_dir) | ||
mod_json_obj_new.check_up_to_date() | ||
mod_json_new = mod_json_obj_new.get_modules_json() | ||
assert mod_json_orig == mod_json_new |
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 think this test can also be removed after removing base_path
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.
will update them to test with another entry. They should just make sure to be able to fix a broken modules.json
…x-suggestion # Conflicts: # CHANGELOG.md # nf_core/modules/modules_json.py
…x-suggestion # Conflicts: # .github/workflows/tools-api-docs-dev.yml # .github/workflows/tools-api-docs-release.yml
Running
nf-core modules info
never recreates the modules.json. So, if it is out-of-date, the suggested help message is not useful. I think explicitly stating a command is more useful here.