Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
4765d9a
Added support for modules.json for modules install commandq
ErikDanielsson Jun 16, 2021
916911c
Merge branch 'dev' of github.com:ErikDanielsson/tools into update-mod…
ErikDanielsson Jun 16, 2021
bb62ddb
Remove redundant code
ErikDanielsson Jun 16, 2021
8af92af
Implement suggestions from code review
ErikDanielsson Jun 16, 2021
db39da3
Implement suggestions from code review
ErikDanielsson Jun 16, 2021
3351841
Apply changes from code review
ErikDanielsson Jun 16, 2021
199216f
Added API call for full git log
ErikDanielsson Jun 18, 2021
ca5cb84
Rewrote code for module.json creation
ErikDanielsson Jun 18, 2021
2c9a39e
Moved ModulesRepo to separate file
ErikDanielsson Jun 18, 2021
770b595
Resolve merge conflict
ErikDanielsson Jun 18, 2021
278fe86
Apply suggestions from code review
ErikDanielsson Jun 18, 2021
a353a43
Bug fixes after testing with rnaseq pipeline
ErikDanielsson Jun 19, 2021
a9a8d17
Added support for pagination of commits
ErikDanielsson Jun 20, 2021
e04cf4e
Update function descriptions
ErikDanielsson Jun 20, 2021
0dbe865
Implemented installation of different pipeline versions
ErikDanielsson Jun 21, 2021
ef73868
Added new flag '--latest' to install the latest version of module wit…
ErikDanielsson Jun 21, 2021
1ee746d
Update module test to handle versioning
ErikDanielsson Jun 21, 2021
116f65b
Update nf_core/modules/module_utils.py
ErikDanielsson Jun 21, 2021
bfa93e4
Update test with new flag for install command
ErikDanielsson Jun 21, 2021
db8b81c
Merge branch 'update-modules-install' of github.com:ErikDanielsson/to…
ErikDanielsson Jun 21, 2021
38b314d
Only display 'older commits' if there are any
ErikDanielsson Jun 21, 2021
cfad229
Remove redundant code
ErikDanielsson Jun 21, 2021
1a5c215
Restriced commit log to only be shown from given date
ErikDanielsson Jun 21, 2021
bc6366e
Minor fixes
ErikDanielsson Jun 22, 2021
ad7482d
Fix index of out range error
ErikDanielsson Jun 22, 2021
2a07d52
Updated CHANGELOG.md
ErikDanielsson Jun 22, 2021
ee5bbea
Fix CHANGELOG.md
ErikDanielsson Jun 22, 2021
1ea9be8
Add '--force' option
ErikDanielsson Jun 22, 2021
286724d
Remove duplicated code
ErikDanielsson Jun 22, 2021
d033d3d
Added commit SHA to message, and bug fix of '--force'
ErikDanielsson Jun 22, 2021
dabdc64
Bug fixes for '--force'
ErikDanielsson Jun 22, 2021
a9a769e
Added '--sha' flag to specify tool version
ErikDanielsson Jun 22, 2021
0c4cda5
Refactor modules install
ErikDanielsson Jun 22, 2021
89339e1
Update tests with new flags
ErikDanielsson Jun 22, 2021
5087619
Make questionary select show installed version
ErikDanielsson Jun 22, 2021
e39ff09
Apply suggestions from code review
ErikDanielsson Jun 23, 2021
2586097
Apply changes from code review
ErikDanielsson Jun 23, 2021
4dce523
Merge branch 'update-modules-install' of github.com:ErikDanielsson/to…
ErikDanielsson Jun 23, 2021
5b7c79b
Black
ErikDanielsson Jun 23, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Bug fixes for '--force'
  • Loading branch information
ErikDanielsson committed Jun 22, 2021
commit dabdc642dd58421f72844e4c1c7e0409c3b3d7a0
10 changes: 4 additions & 6 deletions nf_core/modules/module_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ def local_module_equal_to_commit(local_files, module_name, modules_repo, commit_
return all(files_are_equal)


def prompt_module_version_sha(module, old_sha=None):
def prompt_module_version_sha(module, installed_sha=None):
older_commits_choice = questionary.Choice(
title=[("fg:ansiyellow", "older commits"), ("class:choice-default", "")], value=""
)
Expand All @@ -171,12 +171,10 @@ def prompt_module_version_sha(module, old_sha=None):
choices = []
for title, sha in map(lambda commit: (commit["trunc_message"], commit["git_sha"]), commits):

display_color = "fg:ansiblue" if sha != old_sha else "fg:ansired"
display_color = "fg:ansiblue" if sha != installed_sha else "fg:ansired"
message = f"{title} {sha}"
if old_sha == sha:
message += " (old version)"
print(message)
print(sha, old_sha)
if installed_sha == sha:
message += " (installed version)"
commit_display = [(display_color, message), ("class:choice-default", "")]
choices.append(questionary.Choice(title=commit_display, value=sha))
if len(next_page_commits) > 0:
Expand Down
41 changes: 26 additions & 15 deletions nf_core/modules/pipeline_modules.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,33 +125,44 @@ def install(self, module=None, latest=False, force=False):
modules_json = json.load(fh)

current_version = modules_json["modules"].get(module)
print(current_version)

if current_version is not None:
# Fetch the latest commit for the module
git_log = get_module_git_log(module, per_page=1, page_nbr=1)
if len(git_log) == 0:
log.error(f"Was unable to fetch version of module '{module}'")
return False
version = git_log[0]["git_sha"]
if current_version == version:
latest_version = git_log[0]["git_sha"]
if current_version == latest_version:
log.info("Already up to date")
return True
elif not force:
log.error("Found newer version of module. To install use '--force'")
return False
if latest:
# Fetch the latest commit for the module
git_log = get_module_git_log(module, per_page=1, page_nbr=1)
if len(git_log) == 0:
log.error(f"Was unable to fetch version of module '{module}'")
return False
version = git_log[0]["git_sha"]

# Check for flag '--latest'
if latest:
version = latest_version
else:
try:
version = prompt_module_version_sha(module, installed_sha=current_version["git_sha"])
except SystemError as e:
log.error(e)
else:
try:
version = prompt_module_version_sha(module, old_sha=current_version["git_sha"])
except SystemError as e:
log.error(e)
sys.exit(1)
# Check for flag '--latest'
if latest:
# Fetch the latest commit for the module
git_log = get_module_git_log(module, per_page=1, page_nbr=1)
if len(git_log) == 0:
log.error(f"Was unable to fetch version of module '{module}'")
return False
version = git_log[0]["git_sha"]
else:
try:
version = prompt_module_version_sha(module)
except SystemError as e:
log.error(e)
sys.exit(1)

# Check that we don't already have a folder for this module
module_dir = os.path.join(self.pipeline_dir, "modules", *install_folder, module)
Expand Down