-
Notifications
You must be signed in to change notification settings - Fork 9
feat: Allow using custom containers with pre-built dependencies #63
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
Open
mboulton-fathom
wants to merge
10
commits into
snakemake:main
Choose a base branch
from
mboulton-fathom:feat/allow-custom-containers
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
7b8c2ca
refactor: Improve logging and usability with containers
mboulton-fathom 0149255
chore: Clean up for merge (#3)
mboulton-fathom b2a75dc
feat(executor): Add option to skip dependency installation for contai…
mboulton-fathom e8e5dfb
docs(example): Add googlebatch_container_dependencies_installed to RE…
mboulton-fathom 6a2cafe
test: Add workflow test with mocked Google Batch API client (#6)
mboulton-fathom 9f77f4c
refactor(executor): Simplify task runnable assignment and update log …
mboulton-fathom 63a98a5
build: Switch package build and publish to uv (#8)
mboulton-fathom c19fb1e
chore: Apply review suggestions for CI, Dockerfile, and README
mboulton-fathom efcd480
fix(executor): Guard against None for image_family in is_container_job
mboulton-fathom 05d4b71
fix(executor): Pass `job` object to `get_snakefile` when formatting C…
mboulton-fathom File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| uv.lock -diff |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,30 @@ | ||
| repos: | ||
| - repo: https://github.com/charliermarsh/ruff-pre-commit | ||
| rev: v0.12.7 | ||
| hooks: | ||
| - args: [--fix, --exit-non-zero-on-fix] | ||
| id: ruff-check | ||
| - id: ruff-format | ||
| - repo: https://github.com/pre-commit/mirrors-mypy | ||
| rev: v1.17.1 | ||
| hooks: | ||
| - id: mypy | ||
| additional_dependencies: | ||
| - types-requests | ||
| - types-protobuf>=5,<6 | ||
| - types-cachetools | ||
| - numpy | ||
| - repo: https://github.com/rhysd/actionlint | ||
| rev: v1.7.7 | ||
| hooks: | ||
| - id: actionlint | ||
| args: | ||
| - "-shellcheck=" | ||
| - "-ignore" | ||
| - 'input "attestations" is not defined in action' | ||
| - "-ignore" | ||
| - '"github.head_ref" is potentially untrusted' | ||
| - repo: https://github.com/hadialqattan/pycln | ||
| rev: v2.5.0 | ||
| hooks: | ||
| - id: pycln |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,43 @@ | ||
| # syntax=docker/dockerfile:1.4@sha256:9ba7531bd80fb0a858632727cf7a112fbfd19b17e94c4e84ced81e24ef1a0dbc | ||
|
|
||
| FROM mirror.gcr.io/mambaorg/micromamba:2.3-debian13-slim@sha256:3f92db74f6780f60c9a2c6d983c76360a1d4cfdcb597395ab9e64747f067b15b | ||
|
|
||
| ENV DEBIAN_FRONTEND=noninteractive | ||
|
|
||
|
|
||
| # Revert to being root temporarily | ||
| USER 0 | ||
| # Install base dependencies | ||
| RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \ | ||
| --mount=type=cache,target=/var/lib/apt/lists,sharing=locked \ | ||
| rm -f /etc/apt/apt.conf.d/docker-clean \ | ||
| && echo 'Binary::apt::APT::Keep-Downloaded-Packages "true";' | tee /etc/apt/apt.conf.d/keep-cache \ | ||
| && apt-get -qq update -y \ | ||
| && apt-get -qq install --no-install-recommends -y curl git ca-certificates git python3-pip build-essential gnupg | ||
|
|
||
| RUN curl https://packages.cloud.google.com/apt/doc/apt-key.gpg | gpg --dearmor -o /usr/share/keyrings/cloud.google.gpg | ||
| RUN echo "deb [signed-by=/usr/share/keyrings/cloud.google.gpg] https://packages.cloud.google.com/apt cloud-sdk main" | tee -a /etc/apt/sources.list.d/google-cloud-sdk.list | ||
| RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \ | ||
| --mount=type=cache,target=/var/lib/apt/lists,sharing=locked \ | ||
| rm -f /etc/apt/apt.conf.d/docker-clean \ | ||
| && apt-get -qq update -y \ | ||
| && apt-get -qq install --no-install-recommends -y google-cloud-cli | ||
|
|
||
| # Create mount path used by gcsfuse to mount data | ||
| RUN mkdir -p /mnt/ && chown mambauser:mambauser /mnt/ && chmod g+w /mnt/ | ||
|
|
||
| # Create and set permissions for the share directory | ||
| RUN mkdir -p /mnt/share && chown mambauser:mambauser /mnt/share && chmod g+w /mnt/share | ||
| VOLUME /mnt/share | ||
|
|
||
| # Back to non-root to install dependencies | ||
| USER mambauser | ||
|
|
||
|
|
||
| COPY environment.yml . | ||
| RUN micromamba env create --download-only --yes -f ./environment.yml | ||
| RUN micromamba env create --yes -f ./environment.yml | ||
|
|
||
|
|
||
| COPY docker-entrypoint.sh / | ||
| ENTRYPOINT ["/docker-entrypoint.sh"] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,20 +1,58 @@ | ||
| # Hello World COS | ||
|
|
||
| The example is for the container operating system (COS), which basically means running inside a container | ||
| instead of on a native virtual machine. This also means using the default Snakemake image. Here is how to see images in the project: | ||
| instead of on a native virtual machine. This requires building a custom image. Here is how to see images in | ||
| the project: | ||
|
|
||
| ```bash | ||
| gcloud compute images list \ | ||
| --project=batch-custom-image \ | ||
| --no-standard-images | ||
| --project=batch-custom-image \ | ||
| --no-standard-images | ||
| ``` | ||
|
|
||
| An example rule in snakemake: | ||
|
|
||
| ```snakemake | ||
| rule interpolated_flat_fluvial: | ||
| input: | ||
| interpolated_layers="input.path" | ||
| output: | ||
| touch("output.path") | ||
| resources: | ||
| googlebatch_service_account="[email protected]", | ||
| googlebatch_image_family="batch-cos-stable-official", | ||
| googlebatch_image_project="batch-custom-image", | ||
| googlebatch_entrypoint="/docker-entrypoint.sh", | ||
| googlebatch_machine_type="e2-standard-4", | ||
| googlebatch_container="europe-docker.pkg.dev/myproject/my_image_name:latest", | ||
| googlebatch_container_dependencies_installed=True, | ||
| googlebatch_work_tasks=1, | ||
| googlebatch_work_tasks_per_node=2, | ||
| script: | ||
| "relative/path/to/script.py" | ||
| ``` | ||
|
|
||
| Here is an example command: | ||
|
|
||
| ```bash | ||
| GOOGLE_PROJECT=myproject | ||
| snakemake --jobs 1 --executor googlebatch --googlebatch-image-family batch-cos-stable-official --googlebatch-region us-central1 --googlebatch-image-project batch-custom-image --googlebatch-project ${GOOGLE_PROJECT} --default-storage-provider s3 --default-storage-prefix s3://my-snakemake-testing | ||
| snakemake \ | ||
| --jobs 1 \ | ||
| --executor googlebatch \ | ||
| --googlebatch-image-family batch-cos-stable-official \ | ||
| --googlebatch-region us-central1 \ | ||
| --googlebatch-image-project batch-custom-image \ | ||
| --googlebatch-project ${GOOGLE_PROJECT} \ | ||
| --container-image europe-docker.pkg.dev/${GOOGLE_PROJECT}/my_image_name:latest \ | ||
| --preemptible-rules name_of_preemptible_rule \ | ||
| --default-storage-provider gcs \ | ||
| --default-storage-prefix gs://my_bucket_name \ | ||
| --verbose \ | ||
| my_rule_name | ||
| ``` | ||
|
|
||
| See [this link](https://cloud.google.com/batch/docs/vm-os-environment-overview#supported_vm_os_images) for how to find a compatible COS image project and family. | ||
| You can also see information [here](https://cloud.google.com/batch/docs/view-os-images), | ||
| See the [Dockerfile](./Dockerfile) and [entrypoint script](./docker-entrypoint.sh) for an example of using micromamba to | ||
| build an image with all dependencies installed. | ||
|
|
||
| See [this link](https://cloud.google.com/batch/docs/vm-os-environment-overview#supported_vm_os_images) for how to find a | ||
| compatible COS image project and family. You can also see [OS images documentation](https://cloud.google.com/batch/docs/view-os-images), |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| #!/usr/bin/env sh | ||
|
|
||
| set -ex | ||
|
|
||
| micromamba run -n my_environment_name bash -ex -c "$@" | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.