diff --git a/Dockerfile b/Dockerfile index b98c01ea..dca0e192 100644 --- a/Dockerfile +++ b/Dockerfile @@ -2,12 +2,16 @@ FROM python:3.8.13-bullseye@sha256:2a01d88a1684e6d7f08030cf5ae73b536926c64076cab RUN apt-get update && apt-get install -y make \ software-properties-common \ + libgeos-dev \ libopenmpi3 \ libopenmpi-dev \ libboost-all-dev \ libhdf5-serial-dev \ netcdf-bin \ libnetcdf-dev \ + libproj-dev \ + proj-bin \ + proj-data \ python3 \ python3-pip @@ -22,5 +26,26 @@ COPY . /pace RUN cd /pace && \ pip3 install -r /pace/requirements_dev.txt -c /pace/constraints.txt +RUN cd / && \ + git clone https://github.com/ai2cm/fv3net + +ENV CFLAGS="-I/usr/include -DACCEPT_USE_OF_DEPRECATED_PROJ_API_H=1" + +RUN python3 -m pip install \ + numpy==1.21.2 \ + netCDF4==1.5.7 \ + mpi4py==3.1.1 \ + matplotlib==3.5.2 \ + ipyparallel==8.4.1 \ + jupyterlab==3.4.4 \ + shapely==1.8.5 \ + cartopy==0.18.0 \ + jupyterlab_code_formatter==1.5.2 \ + isort==5.10.1 \ + black==22.3.0 \ + /fv3net/external/vcm + +ENV PYTHONPATH=/fv3net/external/fv3viz:/pace/external/gt4py/src + ENV OMPI_ALLOW_RUN_AS_ROOT=1 ENV OMPI_ALLOW_RUN_AS_ROOT_CONFIRM=1 diff --git a/Makefile b/Makefile index 92771a95..e7779a4b 100644 --- a/Makefile +++ b/Makefile @@ -20,12 +20,16 @@ BROWSER := python -c "$$BROWSER_PYSCRIPT" DOCKER_BUILDKIT=1 SHELL=/bin/bash CWD=$(shell pwd) +CMD ?=bash PULL ?=True DEV ?=y CHECK_CHANGED_SCRIPT=$(CWD)/changed_from_main.py CONTAINER_CMD?=docker SAVEPOINT_SETUP=pip3 list +PORT ?=8888 +APP_NAME ?=Pace_dev + VOLUMES ?= BUILD_FLAGS ?= @@ -91,13 +95,19 @@ _force_build: enter: docker run --rm -it \ - --network host \ $(VOLUMES) \ - $(PACE_IMAGE) bash + -p=$(PORT):$(PORT) \ + --name="$(APP_NAME)" \ + $(PACE_IMAGE) $(CMD) dev: DEV=y $(MAKE) enter +notebook: + CMD="jupyter notebook --ip 0.0.0.0 --no-browser --allow-root --notebook-dir=/pace/examples/notebooks" \ + DEV=y \ + $(MAKE) enter + test_util: if [ $(shell $(CHECK_CHANGED_SCRIPT) util) != false ]; then \ $(MAKE) -C util test; \ diff --git a/examples/Dockerfile b/examples/Dockerfile deleted file mode 100644 index 7b030f20..00000000 --- a/examples/Dockerfile +++ /dev/null @@ -1,75 +0,0 @@ -FROM ubuntu:20.04@sha256:450e066588f42ebe1551f3b1a535034b6aa46cd936fe7f2c6b0d72997ec61dbd - -ARG DEBIAN_FRONTEND=noninteractive -ENV TZ=Etc/UTC - -RUN apt-get update -y && \ - apt-get install -y \ - tzdata \ - software-properties-common - -RUN add-apt-repository ppa:git-core/ppa -y && \ - apt-get update -y && \ - apt-get install -y \ - git - -RUN apt-get update -y && \ - apt-get install -y \ - g++ \ - libgeos-dev \ - libopenmpi-dev \ - libboost-all-dev \ - libhdf5-serial-dev \ - netcdf-bin \ - libnetcdf-dev \ - libproj-dev \ - proj-bin \ - proj-data \ - python3.8 \ - python3.8-dev \ - python3-pip && \ - rm -rf /var/lib/apt/lists/* && \ - apt-get clean - -RUN python3 -m pip install --upgrade pip wheel - -COPY . /pace - -# 2022.12.22 Added non-editable installs as a workaround for pace module not found, when gt4py was updated to v1.0. -# See https://github.com/ai2cm/pace/issues/419 for more details. -RUN cd /pace && \ - pip3 install -r /pace/requirements_dev.txt -c /pace/constraints.txt && \ - pip install ./driver ./ndsl ./fv3core ./physics -c /pace/constraints.txt - -RUN cd / && \ - git clone https://github.com/ai2cm/fv3net - -ENV CFLAGS="-I/usr/include -DACCEPT_USE_OF_DEPRECATED_PROJ_API_H=1" - -RUN python3 -m pip install \ - numpy==1.21.2 \ - netCDF4==1.5.7 \ - mpi4py==3.1.1 \ - matplotlib==3.5.2 \ - ipyparallel==8.4.1 \ - jupyterlab==3.4.4 \ - shapely==1.8.5 \ - cartopy==0.18.0 \ - jupyterlab_code_formatter==1.5.2 \ - isort==5.10.1 \ - black==22.3.0 \ - /fv3net/external/vcm - -ENV PYTHONPATH=/fv3net/external/fv3viz:/pace/external/gt4py/src - -ENV OMPI_ALLOW_RUN_AS_ROOT=1 - -ENV OMPI_ALLOW_RUN_AS_ROOT_CONFIRM=1 - -ENV OMPI_MCA_rmaps_base_oversubscribe=1 - -COPY ./examples/notebooks /notebooks - -WORKDIR /notebooks - -CMD ["jupyter-lab", "--port=8888", "--no-browser", "--ip=0.0.0.0", "--allow-root"] diff --git a/examples/Makefile b/examples/Makefile deleted file mode 100644 index dc1f5058..00000000 --- a/examples/Makefile +++ /dev/null @@ -1,35 +0,0 @@ -IMAGE_NAME ?=gcr.io/vcm-ml/pace_notebook_examples -APP_NAME ?=pace_notebook_examples -PORT ?=8888 -BUILD_OPTIONS ?= -RUN_OPTIONS ?= -CMD?= -CWD =$(shell pwd) - -.PHONY: help build build-nc run dev up stop - -help: - @awk 'BEGIN {FS = ":.*?## "} /^[a-zA-Z_-]+:.*?## / {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}' $(MAKEFILE_LIST) - -.DEFAULT_GOAL := help - -build: ## Build the image - docker build $(BUILD_OPTIONS) -t $(IMAGE_NAME) -f Dockerfile .. - -build-nc: ## Build the image without caching - $(MAKE) BUILD_OPTIONS="--no-cache" build - -run: ## Run container - docker run -i -t --rm $(RUN_OPTIONS) -p=$(PORT):$(PORT) --name="$(APP_NAME)" $(IMAGE_NAME) $(CMD) - -dev: ## Run container and mount local directory for development - RUN_OPTIONS="-v $(CWD)/notebooks:/notebooks" $(MAKE) run - -enter: - CMD="/bin/bash" $(MAKE) run - -up: build run ## Build image and run container - -stop: ## Stop and remove running container - docker stop $(APP_NAME) - docker rm $(APP_NAME) diff --git a/examples/README.md b/examples/README.md index 487badc9..db9f897c 100644 --- a/examples/README.md +++ b/examples/README.md @@ -4,11 +4,11 @@ This directory serves as a demo of how you can develop and run individual compon ## Getting started -The easiest way of running these demos is using a Docker container. If you do not already have Docker installed, it can be downloaded directly from [Docker](https://www.docker.com/). Once Docker is set up, you can build and run the container: +The easiest way of running these demos is using a Docker container. If you do not already have Docker installed, it can be downloaded directly from [Docker](https://www.docker.com/). Once Docker is set up, you can build and run the container from the root Pace directory: ``` make build -make run +make notebook ``` Once the docker container is running, you can connect to the Jupyter notebook server by copying and pasting the URLs into any browser on your machine. An example output is shown below: