Skip to content

Commit

Permalink
re-adding one image per workflow structure
Browse files Browse the repository at this point in the history
  • Loading branch information
haimasree committed Apr 5, 2022
1 parent 9620426 commit 9ebd05a
Show file tree
Hide file tree
Showing 3 changed files with 58 additions and 38 deletions.
9 changes: 8 additions & 1 deletion .github/workflows/release-workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,13 @@ jobs:
buildtestandpushsingularity:
needs: [buildandpushkipoibaseenvandsharedpy3keras2, buildandtestsharedpy3keras2,
buildtestandpush]
strategy:
fail-fast: false
matrix:
image: ["sharedpy3keras1.2", "sharedpy3keras2", "mpra-dragonn", "extended_coda", "mmsplice",
"mmsplice-mtsplice", "deepmel", "framepool", "kipoisplice", "deeptarget",
"attentivechrome", "bpnet-oskn", "seqvec", "deepflybrain", "aparent-site_probabilities",
"aparent-veff", "deepstarr"]
runs-on: ubuntu-latest
env:
SINGULARITY_PULL_FOLDER: "/home/runner/singularity/"
Expand Down Expand Up @@ -191,4 +198,4 @@ jobs:
shell: bash -l {0}
if: ${{ success() }}
run: |
update_all_singularity
update_all_singularity kipoi/kipoi-docker:${{ matrix.image }}
72 changes: 37 additions & 35 deletions kipoi_containers/update_all_singularity_images.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,20 @@


@click.command()
def run_update() -> None:
"""Update all singularity images. By default, it will push the image to
zenodo by creating a new version of an existing deposition and updating
the metadata and file after deleting the existing file. Obviously, this
will update content of model_group_to_singularity_dict. The image specific
entry in model_group_to_singularity_dict will be updated with url and md5
values of the new deposition and kipoi_containers/container-info/
model-group-to-singularity.json will be updated.
@click.argument("docker_image", required=True, type=str)
def run_update(docker_image: str) -> None:
"""Update the singularity image corresponding to the docker image.
By default, it does not push the image to zenodo but creates a new
version of an existing deposition and updates the metadata and file
after deleting the existing file. Obviously, this does not update
content of model_group_to_singularity_dict. However, if push is
enabled in SingularityHandler.udpate, the draft entry will be
pushed to zenodo, the image specific entry in model_group_to_singularity_dict
will be updated with url and md5 values of the new deposition and
kipoi_containers/container-info/model-group-to-singularity.json will be
updated.
"""
click.echo("Updating all singularity containers")
click.echo(f"Updating the singularity container for {docker_image}")
github_obj = Github(os.environ["GITHUB_TOKEN"])
kipoi_model_repo = github_obj.get_organization("kipoi").get_repo("models")
model_group_to_singularity_dict = populate_json_from_kipoi(
Expand All @@ -47,34 +51,32 @@ def run_update() -> None:
else:
docker_to_model_group_dict_ci[kipoi_docker_image] = [model_group]

for docker_image in docker_to_model_group_dict_ci.keys():
model_or_model_group_list = docker_to_model_group_dict_ci[docker_image]
singularity_pull_folder = os.environ.get(
"SINGULARITY_PULL_FOLDER", Path(__file__).parent.resolve()
)
docker_to_model_dict = populate_json(DOCKER_TO_MODEL_JSON)
# for docker_image in docker_to_model_group_dict_ci.keys():
model_or_model_group_list = docker_to_model_group_dict_ci[docker_image]
singularity_pull_folder = os.environ.get(
"SINGULARITY_PULL_FOLDER", Path(__file__).parent.resolve()
)
docker_to_model_dict = populate_json(DOCKER_TO_MODEL_JSON)

singularity_handler = singularityhandler.SingularityHandler(
model_group=model_or_model_group_list[0],
docker_image_name=docker_image,
singularity_image_folder=singularity_pull_folder,
model_group_to_singularity_dict=model_group_to_singularity_dict,
singularity_handler = singularityhandler.SingularityHandler(
model_group=model_or_model_group_list[0],
docker_image_name=docker_image,
singularity_image_folder=singularity_pull_folder,
model_group_to_singularity_dict=model_group_to_singularity_dict,
)
if "shared" in docker_image:
models_to_test = one_model_per_modelgroup(
docker_to_model_dict[docker_image]
)
if "shared" in docker_image:
models_to_test = one_model_per_modelgroup(
docker_to_model_dict[docker_image]
)
# Otherwise it will take more than 6 hours - available time on actions ci
else:
models_to_test = docker_to_model_dict[docker_image]
singularity_handler.update(models_to_test)
if len(model_or_model_group_list) > 1:
for model_or_model_group in model_or_model_group_list[1:]:
model_group_to_singularity_dict[
model_or_model_group
] = model_group_to_singularity_dict[
model_or_model_group_list[0]
]
# Otherwise it will take more than 6 hours - available time on actions ci
else:
models_to_test = docker_to_model_dict[docker_image]
singularity_handler.update(models_to_test)
if len(model_or_model_group_list) > 1:
for model_or_model_group in model_or_model_group_list[1:]:
model_group_to_singularity_dict[
model_or_model_group
] = model_group_to_singularity_dict[model_or_model_group_list[0]]

write_json_to_kipoi(
model_group_to_singularity_dict,
Expand Down
15 changes: 13 additions & 2 deletions test-containers/test_update_all_singularity_images.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,15 @@ def runner():
yield runner


def test_cli_incorrect_use(runner):
result = runner.invoke(
update_all_singularity_images.run_update,
[],
)
assert "Error: Missing argument 'DOCKER_IMAGE'" in result.output
assert result.exit_code == 2


def test_cli_correct_use(runner, monkeypatch):
def mock_populate_singularity_json(*args, **kwargs):
if args[0] == "model-to-docker.json":
Expand Down Expand Up @@ -88,6 +97,8 @@ def mock_cleanup(*args, **kwargs):
"kipoi_containers.update_all_singularity_images.write_json_to_kipoi",
mock_write_singularity_json,
)
result = runner.invoke(update_all_singularity_images.run_update)
print(result.output)
result = runner.invoke(
update_all_singularity_images.run_update,
["kipoi/kipoi-docker:mmsplice-mtsplice"],
)
assert result.exit_code == 0

0 comments on commit 9ebd05a

Please sign in to comment.