Skip to content
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

retrieve last common build of a module for Docker and Singularity #1702

Merged
merged 6 commits into from
Jul 28, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
- Fix inconsistencies in the `--save-diff` flag `nf-core modules update`. Refactor `nf-core modules update` ([#1536](https://github.com/nf-core/tools/pull/1536))
- Fix bug in `ModulesJson.check_up_to_date` causing it to ask for the remote of local modules
- Make `nf-core modules update --save-diff` work when files were created or removed ([#1694](https://github.com/nf-core/tools/issues/1694))
- Get the latest common build for Docker and Singularity containers of a module ([#1702](https://github.com/nf-core/tools/pull/1702))
- Add short option for `--no-pull` option in `nf-core modules`

## [v2.4.1 - Cobolt Koala Patch](https://github.com/nf-core/tools/releases/tag/2.4) - [2022-05-16]
Expand Down
30 changes: 22 additions & 8 deletions nf_core/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -701,16 +701,30 @@ def get_tag_date(tag_date):
images = response.json()["images"]
singularity_image = None
docker_image = None
all_docker = {}
all_singularity = {}
for img in images:
# Get most recent Docker and Singularity image
# Get all Docker and Singularity images
if img["image_type"] == "Docker":
modification_date = get_tag_date(img["updated"])
if not docker_image or modification_date > get_tag_date(docker_image["updated"]):
docker_image = img
if img["image_type"] == "Singularity":
modification_date = get_tag_date(img["updated"])
if not singularity_image or modification_date > get_tag_date(singularity_image["updated"]):
singularity_image = img
# Obtain version and build
match = re.search(r"(?::)+([A-Za-z\d\-_.]+)", img["image_name"])
if match is not None:
all_docker[match.group(1)] = {"date": get_tag_date(img["updated"]), "image": img}
elif img["image_type"] == "Singularity":
# Obtain version and build
match = re.search(r"(?::)+([A-Za-z\d\-_.]+)", img["image_name"])
if match is not None:
all_singularity[match.group(1)] = {"date": get_tag_date(img["updated"]), "image": img}
# Obtain common builds from Docker and Singularity images
common_keys = list(all_docker.keys() & all_singularity.keys())
current_date = None
for k in common_keys:
# Get the most recent common image
date = max(all_docker[k]["date"], all_docker[k]["date"])
if docker_image is None or current_date < date:
docker_image = all_docker[k]["image"]
singularity_image = all_singularity[k]["image"]
current_date = date
return docker_image["image_name"], singularity_image["image_name"]
except TypeError:
raise LookupError(f"Could not find docker or singularity container for {package}")
Expand Down