-
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
Updated nf-core modules remove
to remove entry in modules.json
#1132
Changes from 2 commits
2d93e8f
2f68087
d878a26
bb17413
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
import os | ||
import sys | ||
import json | ||
import questionary | ||
import logging | ||
|
||
|
@@ -43,7 +44,6 @@ def remove(self, module): | |
|
||
# Set the install folder based on the repository name | ||
install_folder = ["nf-core", "software"] | ||
print(self.modules_repo.name) | ||
if not self.modules_repo.name == "nf-core/modules": | ||
install_folder = ["external"] | ||
|
||
|
@@ -58,5 +58,27 @@ def remove(self, module): | |
|
||
log.info("Removing {}".format(module)) | ||
|
||
# Remove entry from modules.json | ||
if not self.remove_modules_json_entry(module): | ||
return False | ||
|
||
# Remove the module | ||
return self.clear_module_dir(module_name=module, module_dir=module_dir) | ||
|
||
def remove_modules_json_entry(self, module): | ||
# Load 'modules.json' | ||
modules_json_path = os.path.join(self.dir, "modules.json") | ||
with open(modules_json_path, "r") as fh: | ||
modules_json = json.load(fh) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We should probably verify that the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I thought about it, but didn't add it in the end since we check for the file in |
||
if module in modules_json.get("modules", {}): | ||
modules_json["modules"].pop(module) | ||
else: | ||
# If the module is missing from modules.json we can still clear the directory | ||
# in which the untracked module resides | ||
log.error(f"Module '{module}' is missing from 'modules.json' file.") | ||
return questionary.confirm( | ||
f"Do you wish to continue removing module '{module}'?", default=False | ||
).unsafe_ask() | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I would say we don't need a prompt here, maybe just say that a There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah, I guess we can rely on the user knowing |
||
with open(modules_json_path, "w") as fh: | ||
json.dump(modules_json, fh, indent=4) | ||
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.
Similar to the other command, I would rather print that the module entry couldn't be found in the
modules.json
and not prompt for it.