Skip to content

Commit

Permalink
Hotfix/docker notebooks (#80)
Browse files Browse the repository at this point in the history
* Fix to get notebooks working in docker
---------

Co-authored-by: Frank Malatino <[email protected]>
  • Loading branch information
oelbert and fmalatino authored Apr 18, 2024
1 parent 7e435fa commit b8c8c53
Show file tree
Hide file tree
Showing 9 changed files with 779 additions and 2,176 deletions.
25 changes: 25 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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
14 changes: 12 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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 ?=

Expand Down Expand Up @@ -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; \
Expand Down
75 changes: 0 additions & 75 deletions examples/Dockerfile

This file was deleted.

35 changes: 0 additions & 35 deletions examples/Makefile

This file was deleted.

4 changes: 2 additions & 2 deletions examples/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
4 changes: 3 additions & 1 deletion examples/notebooks/functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,9 @@ def configure_domain(
quantity_factory = QuantityFactory.from_backend(sizer=sizer, backend=backend)

metric_terms = MetricTerms(
quantity_factory=quantity_factory, communicator=communicator
quantity_factory=quantity_factory,
communicator=communicator,
eta_file="eta79.nc",
)

# workaround for single layer
Expand Down
Loading

0 comments on commit b8c8c53

Please sign in to comment.