-
Notifications
You must be signed in to change notification settings - Fork 46
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Replace Launcher Script with Justfile & Standalone Scripts + Instruct…
…ions for External (#239) Full support for `just` is slated for the next release. While this PR adds the `justfile`, it also adds stand-alone scripts under `internal/scripts/` that external users can use for the development lifecycle. Instructions for these have been added to the README.md. Documentation for the `justfile` has been moved to `internal/README_justfile.md`. -- Replaces the `launch.sh` script with a new `justfile` with commands that support the development lifecycle. New commands ('recipes' in `just`) allow for building the development or release image, checking the setup (checking installed programs & their versions, creating the `.env` file or reading it, etc.), running interactive programs on either image, or running `pytest` in the release image. These new recipes are: ``` build-dev # Builds the development image. build-release # Builds the release image. run-dev cmd='bash' # Runs an interactive program in the development bionemo image. run-release cmd='bash' # Runs an interactive program in the release bionemo image. setup # Checks for installed programs (docker, git, etc.), their versions, and grabs the latest cache image. test # Executes pytest in the release image. ``` The image building commands are executed as either `just build-dev` or `just build-release` while their corresponding container-running commands are `just run-{dev,release} (cmd)`, where `cmd` is the path to an executable program in the image (it defaults to `bash`, like `launch.sh` did before). The `just test` recipie runs `pytest` on all of the bionemo code & produces an HTML code coverage report, which is written to `htmlcov/` on the host machine (this directory is volume-mounted). This test command also runs the notebook tests. Note that `just setup` is a dependency of all of these commands: meaning the setup will _always_ be performed. To support building a development image, the `Dockerfile` has been modified to have a new `development` target. This builds off of `dev`, but keeps the `3rdparty/` and `sub-packages/` code in `/workspace/bionemo2`. Additionally, it installs all of the local code (`bionemo-*` and `3rdparty/*`) as **editable** installs. This enables development work as the code can be mounted and modified _outside_ of the `dist-packages` folder, which is owned by root. Note that `just build-dev` builds this new `development` target while `just build-release` builds the `release` target, which is equivalent to building the entire image as `release` is the final stage.
- Loading branch information
1 parent
d16c495
commit 1d7602e
Showing
9 changed files
with
475 additions
and
302 deletions.
There are no files selected for viewing
This file contains 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 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 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 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,24 @@ | ||
To get started, first download [`just`](https://github.com/casey/just). You can use [Homebrew](https://brew.sh/) on OS X & Linux: | ||
```bash | ||
brew install just | ||
``` | ||
|
||
**Once you have `just`, you need to run the `just setup` command once _before_ you can run any other command.** | ||
Thus, if it's your first time, you will need to do this first: | ||
```bash | ||
just setup | ||
just <command you want to run> | ||
``` | ||
|
||
You can see all of the commands for the development cycle by running `just`. These commands are executable as | ||
`just X` for each command `X` listed: | ||
``` | ||
build-dev # Builds the development image. | ||
build-release # Builds the release image. | ||
run-dev cmd='bash' # Runs an interactive program in the development bionemo image. | ||
run-release cmd='bash' # Runs an interactive program in the release bionemo image. | ||
setup # Checks for installed programs (docker, git, etc.), their versions, and grabs the latest cache image. | ||
test # Executes pytest in the release image. | ||
``` | ||
|
||
You can combine `just` commands together. For example, run `just build-dev build-release` to build both images. |
This file contains 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,17 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -euo pipefail | ||
|
||
COMMIT=$(git rev-parse HEAD) | ||
DATE=$(date --iso-8601=seconds -u) | ||
|
||
set -x | ||
DOCKER_BUILDKIT=1 docker buildx build \ | ||
-t "nvcr.io/nvidian/cvai_bnmo_trng/bionemo:dev-bionemo2-${COMMIT}" \ | ||
--target="development" \ | ||
--load \ | ||
--cache-to type=inline \ | ||
--label com.nvidia.bionemo.git_sha=${COMMIT} \ | ||
--label com.nvidia.bionemo.created_at=${DATE} \ | ||
-f ./Dockerfile \ | ||
. |
This file contains 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,61 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -euo pipefail | ||
|
||
source .env | ||
|
||
LOCAL_REPO_PATH="$(realpath $(pwd))" | ||
|
||
if [[ "$(basename ${LOCAL_REPO_PATH})" != "bionemo-fw-ea" ]]; then | ||
echo "ERROR: must run this script from the bionemo repository root!" | ||
exit 1 | ||
fi | ||
|
||
COMMIT=$(git rev-parse HEAD) | ||
|
||
DOCKER_REPO_PATH="/workspace/bionemo2" | ||
|
||
DOCKER_VERSION=$(docker version | grep -i version | head -1 | awk '{print $2}') | ||
DOCKER_VERSION_WITH_GPU_SUPPORT='19.03.0' | ||
if [ "$DOCKER_VERSION_WITH_GPU_SUPPORT" == "$(echo -e "$DOCKER_VERSION\n$DOCKER_VERSION_WITH_GPU_SUPPORT" | sort -V | head -1)" ]; then | ||
PARAM_RUNTIME="--gpus all" | ||
else | ||
PARAM_RUNTIME="--runtime=nvidia" | ||
fi | ||
|
||
echo "docker run ... nvcr.io/nvidian/cvai_bnmo_trng/bionemo:dev-bionemo2-${COMMIT} bash" | ||
echo '---------------------------------------------------------------------------------------------' | ||
# DO NOT set -x: we **DO NOT** want to leak credentials to STDOUT! (API_KEY) | ||
docker run \ | ||
--rm \ | ||
-it \ | ||
--network host \ | ||
${PARAM_RUNTIME} \ | ||
-p ${JUPYTER_PORT}:8888 \ | ||
--shm-size=4g \ | ||
-e TMPDIR=/tmp/ \ | ||
-e NUMBA_CACHE_DIR=/tmp/ \ | ||
-e BIONEMO_HOME=$DOCKER_REPO_PATH \ | ||
-e WANDB_API_KEY=$WANDB_API_KEY \ | ||
-e NGC_CLI_API_KEY=$NGC_CLI_API_KEY \ | ||
-e NGC_CLI_ORG=$NGC_CLI_ORG \ | ||
-e NGC_CLI_TEAM=$NGC_CLI_TEAM \ | ||
-e NGC_CLI_FORMAT_TYPE=$NGC_CLI_FORMAT_TYPE \ | ||
-e AWS_ENDPOINT_URL \ | ||
-e AWS_REGION \ | ||
-e AWS_SECRET_ACCESS_KEY \ | ||
-e AWS_ACCESS_KEY_ID \ | ||
-e HOME=${DOCKER_REPO_PATH} \ | ||
-w ${DOCKER_REPO_PATH} \ | ||
-v ${LOCAL_RESULTS_PATH}:${DOCKER_RESULTS_PATH} \ | ||
-v ${LOCAL_DATA_PATH}:${DOCKER_DATA_PATH} \ | ||
-v ${LOCAL_MODELS_PATH}:${DOCKER_MODELS_PATH} \ | ||
-v /etc/passwd:/etc/passwd:ro \ | ||
-v /etc/group:/etc/group:ro \ | ||
-v /etc/shadow:/etc/shadow:ro \ | ||
-v ${HOME}/.ssh:${DOCKER_REPO_PATH}/.ssh:ro \ | ||
-v ${LOCAL_REPO_PATH}/htmlcov:/${DOCKER_REPO_PATH}/htmlcov \ | ||
-u $(id -u):$(id -g) \ | ||
-v ${LOCAL_REPO_PATH}:${DOCKER_REPO_PATH} \ | ||
"nvcr.io/nvidian/cvai_bnmo_trng/bionemo:dev-bionemo2-${COMMIT}" \ | ||
bash |
Oops, something went wrong.