Skip to content
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

Merge into main #76

Merged
merged 16 commits into from
Oct 30, 2023
Merged
Show file tree
Hide file tree
Changes from 14 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions base_images/isce2/docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ ARG DEBIAN_FRONTEND=noninteractive

# install maap-py library
ENV MAAP_CONF='/maap-py/'
RUN git clone --single-branch --branch v3.0.1 https://github.com/MAAP-Project/maap-py.git \
RUN git clone --single-branch --branch v3.1.3 https://github.com/MAAP-Project/maap-py.git \
&& cd maap-py \
&& pip install -e .

Expand All @@ -30,13 +30,14 @@ RUN mkdir /projects
WORKDIR /projects
RUN sed -i -e 's/\/root/\/projects/g' /etc/passwd

RUN conda install -y -c conda-forge mamba=1.3.1
RUN pip install pyOpenSSL==23.2.0
RUN conda install -y -c conda-forge pyOpenSSL=23.2.0 && \
conda install -y -n base conda-libmamba-solver=23.7.0 && \
conda config --set solver libmamba

# need to uninstall jupyter_server_terminals as it conflicts with Jupyterlab 3.4.x. Doesn't seem to break anything
# but can get rid of if/when we upgrade jlab
RUN mamba install -y -c conda-forge -c plant plant=0.1.89dev isce2=2.6.2 matplotlib=3.5.1 Cython=0.29.28 \
numba=0.55.1 pygeos=0.14.0 pyproj=3.4.1 rasterio=1.3.6 && \
RUN conda install -y --solver=libmamba -c conda-forge -c plant plant=0.1.89dev isce2=2.6.2 matplotlib=3.6.2 Cython=0.29.33 \
numba=0.56.4 pygeos=0.14 pyproj=3.4.1 rasterio=1.3.4 && \
pip uninstall -y jupyter_server_terminals && \
find /opt/conda/ -follow -type f -name '*.a' -delete && \
find /opt/conda/ -follow -type f -name '*.js.map' -delete && \
Expand Down
9 changes: 5 additions & 4 deletions base_images/isce3/docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ ARG DEBIAN_FRONTEND=noninteractive

# install maap-py library
ENV MAAP_CONF='/maap-py/'
RUN git clone --single-branch --branch v3.0.1 https://github.com/MAAP-Project/maap-py.git \
RUN git clone --single-branch --branch v3.1.3 https://github.com/MAAP-Project/maap-py.git \
&& cd maap-py \
&& pip install -e .

Expand All @@ -16,10 +16,11 @@ RUN mkdir /projects
WORKDIR /projects
RUN sed -i -e 's/\/root/\/projects/g' /etc/passwd

RUN conda install -y -c conda-forge mamba=1.4.2
RUN pip install pyOpenSSL==23.2.0
RUN conda install -y -c conda-forge pyOpenSSL=23.2.0 && \
conda install -y -n base conda-libmamba-solver=23.7.0 && \
conda config --set solver libmamba

RUN mamba install -y -c conda-forge isce3=0.12.0 xarray=2023.4.2 \
RUN conda install -y --solver=libmamba -c conda-forge isce3=0.12.0 xarray=2023.4.2 \
hvplot=0.8.3 fsspec=2023.5.0 scikit-learn=1.2.2 && \
find /opt/conda/ -follow -type f -name '*.a' -delete && \
find /opt/conda/ -follow -type f -name '*.js.map' -delete && \
Expand Down
9 changes: 6 additions & 3 deletions base_images/pangeo/docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,19 @@ ARG DEBIAN_FRONTEND=noninteractive

# install maap-py library
ENV MAAP_CONF='/maap-py/'
RUN git clone --single-branch --branch v3.0.1 https://github.com/MAAP-Project/maap-py.git \
RUN git clone --single-branch --branch v3.1.3 https://github.com/MAAP-Project/maap-py.git \
&& cd maap-py \
&& pip install -e .

RUN mkdir /projects
WORKDIR /projects
RUN sed -i -e 's/\/root/\/projects/g' /etc/passwd

RUN conda install -c conda-forge mamba && \
mamba install -c conda-forge -y gdal=3.6.2 matplotlib=3.6.2 Cython=0.29.33 h5py=3.7.0 numba=0.56.4 \
RUN conda install -y -c conda-forge pyOpenSSL=23.2.0 && \
conda install -y -n base conda-libmamba-solver=23.7.0 && \
conda config --set solver libmamba

RUN conda install -y --solver=libmamba -c conda-forge gdal=3.6.2 matplotlib=3.6.2 Cython=0.29.33 h5py=3.7.0 numba=0.56.4 \
pygeos=0.14 pyproj=3.4.1 rasterio=1.3.4 scipy=1.10.0 \
&& find /opt/conda/ -follow -type f -name '*.a' -delete \
&& find /opt/conda/ -follow -type f -name '*.js.map' -delete \
Expand Down
9 changes: 5 additions & 4 deletions base_images/r/docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ ARG DEBIAN_FRONTEND=noninteractive

# install maap-py library
ENV MAAP_CONF='/maap-py/'
RUN git clone --single-branch --branch v3.0.1 https://github.com/MAAP-Project/maap-py.git \
RUN git clone --single-branch --branch v3.1.3 https://github.com/MAAP-Project/maap-py.git \
&& cd maap-py \
&& pip install -e .

Expand All @@ -16,10 +16,11 @@ RUN mkdir /projects
WORKDIR /projects
RUN sed -i -e 's/\/root/\/projects/g' /etc/passwd

RUN conda install -y -c conda-forge mamba=1.3.1
RUN pip install pyOpenSSL==23.2.0
RUN conda install -y -c conda-forge pyOpenSSL=23.2.0 && \
conda install -y -n base conda-libmamba-solver=23.7.0 && \
conda config --set solver libmamba

RUN mamba install -y -c conda-forge r==4.2 r-rgdal==1.5_32 r-sf==1.0_7 r-irkernel==1.3.2 r-gridExtra==2.3 \
RUN conda install -y --solver=libmamba -c conda-forge r==4.2 r-rgdal==1.5_32 r-sf==1.0_7 r-irkernel==1.3.2 r-gridExtra==2.3 \
r-tidyverse==2.0.0 r-randomForest==4.7_1.1 r-raster==3.6_20 r-data.table==1.14.8 r-rlist==0.4.6.2 \
r-gdalutils==2.0.3.2 r-stringr==1.5.0 && \
find /opt/conda/ -follow -type f -name '*.a' -delete && \
Expand Down
12 changes: 8 additions & 4 deletions base_images/rgedi/docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ FROM continuumio/miniconda3:4.12.0

# install maap-py library
ENV MAAP_CONF='/maap-py/'
RUN git clone --single-branch --branch v3.0.1 https://github.com/MAAP-Project/maap-py.git \
RUN git clone --single-branch --branch v3.1.3 https://github.com/MAAP-Project/maap-py.git \
&& cd maap-py \
&& pip install -e .

Expand All @@ -11,9 +11,13 @@ WORKDIR /projects
RUN sed -i -e 's/\/root/\/projects/g' /etc/passwd && echo "source activate r-with-gdal" > ~/.bashrc
RUN apt-get update && apt-get install -y libxt-dev && apt-get clean

RUN conda install -y -c conda-forge mamba && \
mamba install -y -c conda-forge nb_conda_kernels
RUN mamba create --name r-with-gdal -c conda-forge -c r -c csdms-stack gdal r-rgdal r-sf r-irkernel r-gridExtra r-tidyverse \
RUN conda install -y -c conda-forge pyOpenSSL=23.2.0 && \
conda install -y -n base conda-libmamba-solver=23.7.0 && \
conda config --set solver libmamba

RUN conda install -y --solver=libmamba -c conda-forge nb_conda_kernels

RUN conda create --name r-with-gdal --solver=libmamba -c conda-forge -c r -c csdms-stack gdal r-rgdal r-sf r-irkernel r-gridExtra r-tidyverse \
r-randomForest r-raster r-data.table r-rlist r-gdalutils r-stringr r-devtools sysroot_linux-64=2.17 gcc r-lwgeom szip --yes && \
/opt/conda/bin/conda clean -afy
RUN mkdir -p ~/.R/ && echo "LDFLAGS=-lproj" >> ~/.R/Makevars && \
Expand Down
20 changes: 13 additions & 7 deletions base_images/vanilla/docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,21 +1,27 @@
FROM continuumio/miniconda3:22.11.1
ENV LANG en_US.UTF-8
ENV TZ US/Pacific
ARG DEBIAN_FRONTEND=noninteractive

# install maap-py library
ENV MAAP_CONF='/maap-py/'
RUN git clone --single-branch --branch v3.0.1 https://github.com/MAAP-Project/maap-py.git \
RUN git clone --single-branch --branch v3.1.3 https://github.com/MAAP-Project/maap-py.git \
&& cd maap-py \
&& pip install -e .

RUN mkdir /projects
WORKDIR /projects
RUN sed -i -e 's/\/root/\/projects/g' /etc/passwd

RUN conda install -c conda-forge mamba && \
mamba install -c conda-forge -y gdal=3.4.1 matplotlib=3.5.1 Cython=0.29.28 h5py=3.6.0 numba=0.55.1 \
pygeos=0.12.0 pyproj=3.3.0 rasterio=1.2.10 scipy=1.8.0 && \
find /opt/conda/ -follow -type f -name '*.a' -delete && \
find /opt/conda/ -follow -type f -name '*.js.map' -delete && \
/opt/conda/bin/conda clean -afy
RUN conda install -y -c conda-forge pyOpenSSL=23.2.0 && \
conda install -y -n base conda-libmamba-solver=23.7.0 && \
conda config --set solver libmamba

RUN conda install -y --solver=libmamba -c conda-forge gdal=3.6.2 matplotlib=3.6.2 Cython=0.29.33 h5py=3.7.0 numba=0.56.4 \
pygeos=0.14 pyproj=3.4.1 rasterio=1.3.4 scipy=1.10.0 \
&& find /opt/conda/ -follow -type f -name '*.a' -delete \
&& find /opt/conda/ -follow -type f -name '*.js.map' -delete \
&& /opt/conda/bin/conda clean -afy

ARG IMAGE_REF
ENV DOCKERIMAGE_PATH=${IMAGE_REF}
15 changes: 8 additions & 7 deletions jupyterlab3/docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,15 @@ RUN apt-get clean && apt-get update && \
RUN echo "Checking if environment.yml exists for ${BASE_IMAGE_TYPE}" \
; if [ -f "/${BASE_IMAGE_TYPE}/environment.yml" ]; then \
echo "Installing packages from '/${BASE_IMAGE_TYPE}/environment.yml'" \
; mamba env update --name base --file "/${BASE_IMAGE_TYPE}/environment.yml" \
; conda env update --name base --file "/${BASE_IMAGE_TYPE}/environment.yml" --solver libmamba \
; else \
echo "Installing packages from '/shared/environment.yml'" \
; mamba env update --name base --file "/shared/environment.yml" \
; conda env update --name base --file "/shared/environment.yml" --solver libmamba \
; fi

RUN npm install typescript -g
RUN pip install jupyter-server==2.5.0
RUN pip install jupyter-resource-usage==0.7.2

# Adjust permissions on home directory so writable by group root.
RUN chgrp -Rf root /home/$NB_USER && chmod -Rf g+w /home/$NB_USER
Expand All @@ -50,18 +51,18 @@ RUN jupyter labextension disable @jupyterlab/apputils-extension:announcements
###############################
# Custom Jupyter Extensions
###############################
RUN jupyter labextension install @maap-jupyterlab/dps-jupyter-extension@0.4.6 --no-build
RUN jupyter labextension install @maap-jupyterlab/dps-jupyter-extension@0.5.1 --no-build

# PyPi package prepended with 'maap' so it more easily discoverable
RUN pip install maap-jupyter-server-extension==1.1.1
RUN pip install maap-jupyter-server-extension==1.2.2
RUN jupyter server extension enable jupyter_server_extension

RUN jupyter labextension install @maap-jupyterlab/algorithms_jupyter_extension@0.1.1 --no-build
RUN jupyter labextension install @maap-jupyterlab/algorithms_jupyter_extension@0.2.0 --no-build
RUN jupyter labextension install @maap-jupyterlab/[email protected] --no-build
RUN jupyter labextension install @maap-jupyterlab/[email protected] --no-build
RUN jupyter labextension install @maap-jupyterlab/[email protected] --no-build
RUN jupyter labextension install @maap-jupyterlab/[email protected].3 --no-build
RUN jupyter labextension install @maap-jupyterlab/maap-help-jupyter-extension@0.0.46 --no-build
RUN jupyter labextension install @maap-jupyterlab/[email protected].5 --no-build
RUN jupyter labextension install @maap-jupyterlab/maap-help-jupyter-extension@1.0.0 --no-build
RUN jupyter labextension install @maap-jupyterlab/[email protected] --no-build

RUN jupyter lab build && \
Expand Down
54 changes: 47 additions & 7 deletions jupyterlab3/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/bin/bash

# A more robust method of constructing the workspace url prefix
get_workspace_url_prefix() {
get_request_data() {
python3 - <<END
import os
import json
Expand All @@ -13,11 +13,10 @@ namespace = "$1"
# Replicate Che's namespace converter policy
# by substituting any non-alphanumeric characters with hyphens.
namespace = re.sub("[^0-9a-zA-Z-]+", "-", namespace)
api_endpoint = "$2"

svc_host = os.environ.get('KUBERNETES_SERVICE_HOST')
svc_host_https_port = os.environ.get('KUBERNETES_SERVICE_PORT_HTTPS')
che_workspace_id = os.environ.get('CHE_WORKSPACE_ID')
che_machine_name = os.environ.get('CHE_MACHINE_NAME').lower().replace('/', '-')

with open ("/var/run/secrets/kubernetes.io/serviceaccount/token", "r") as t:
token=t.read()
Expand All @@ -26,33 +25,50 @@ headers = {
'Authorization': 'Bearer ' + token,
}

request_string = 'https://' + svc_host + ':' + svc_host_https_port + '/api/v1/namespaces/' + namespace + '/endpoints/'
request_string = 'https://' + svc_host + ':' + svc_host_https_port + '/api/v1/namespaces/' + namespace + '/' + api_endpoint + '/'
httprequest = Request(request_string, headers=headers)
context = ssl._create_unverified_context()
with urlopen(httprequest, context=context) as raw_response:
response = raw_response.read().decode()
data = json.loads(response)
print(data)

END
}

# A more robust method of constructing the workspace url prefix
get_workspace_url_prefix() {
python3 - <<END
data=$(get_request_data "$1" "endpoints")

import os
che_workspace_id = os.environ.get('CHE_WORKSPACE_ID')
che_machine_name = os.environ.get('CHE_MACHINE_NAME').lower().replace('/', '-')

endpoints = data['items']
for endpoint in endpoints:
if che_machine_name in endpoint['metadata']['name']:
if che_workspace_id == endpoint['metadata']['labels']['che.workspace_id']:
print("/%s/%s" % (endpoint['metadata']['name'], endpoint['subsets'][0]['ports'][0]['name']))
break

END
}

for i in {1..300}
do
echo "Attempt $i to construct PREVIEW_URL"
PREVIEW_URL=$(get_workspace_url_prefix "$CHE_WORKSPACE_NAMESPACE-che") # Che 7 OPS configuration where the (actual) namespace is "<username>-che"
NAMESPACE="$CHE_WORKSPACE_NAMESPACE-che"
if test -z "$PREVIEW_URL"
then
PREVIEW_URL=$(get_workspace_url_prefix "$CHE_WORKSPACE_NAMESPACE-$CHE_WORKSPACE_ID") # Che 7 UAT configuration fallback where the default namespace is "<username>-<workspaceid>", this will be deprecated
NAMESPACE="$CHE_WORKSPACE_NAMESPACE-$CHE_WORKSPACE_ID"
fi
if test -z "$PREVIEW_URL"
then
PREVIEW_URL=$(get_workspace_url_prefix "$CHE_WORKSPACE_ID") # Che 6 configuration fallback where the default namespace is the workspace id, this will be deprecated
NAMESPACE="$CHE_WORKSPACE_ID"
fi
if ! test -z "$PREVIEW_URL" # exit loop when it has a preview_url
then
Expand Down Expand Up @@ -115,13 +131,37 @@ mkdir -p /projects/.ssh/
chmod 700 /projects/.ssh/
service ssh restart

# Get maximum memory allocation for this workspace to display at bottom of notebook
get_max_memory() {
python3 - <<END
data_pods=$(get_request_data "$1" "pods")

import os
import sys
che_workspace_id = os.environ.get('CHE_WORKSPACE_ID')

for item in data_pods['items']:
if che_workspace_id == item['metadata']['labels'].get('che.workspace_id'):
for container in item['spec']['containers']:
if container['name']=="jupyter":
print(container['resources']['limits']['memory'])
sys.exit()

print(8489271296) #default memory
END
}

MEMORY=$(get_max_memory "$NAMESPACE")

# TBD maap-py install

source /opt/conda/bin/activate base
export SHELL=/bin/bash
VERSION=$(jupyter lab --version)
if [[ $VERSION > '2' ]] && [[ $VERSION < '3' ]]; then
SHELL=/bin/bash jupyter lab --ip=0.0.0.0 --port=3100 --allow-root --NotebookApp.token='' --NotebookApp.base_url=$PREVIEW_URL --no-browser --debug
jupyter lab --ip=0.0.0.0 --port=3100 --allow-root --NotebookApp.token='' --NotebookApp.base_url=$PREVIEW_URL --no-browser --debug
elif [[ $VERSION > '3' ]] && [[ $VERSION < '4' ]]; then
SHELL=/bin/bash jupyter lab --ip=0.0.0.0 --port=3100 --allow-root --ContentsManager.allow_hidden=True --ServerApp.token='' --ServerApp.base_url=$PREVIEW_URL --no-browser --debug --ServerApp.disable_check_xsrf=True
jupyter lab --ip=0.0.0.0 --port=3100 --allow-root --ContentsManager.allow_hidden=True --ServerApp.token='' --ServerApp.base_url=$PREVIEW_URL --no-browser --debug --ServerApp.disable_check_xsrf=True --ResourceUseDisplay.mem_limit=$MEMORY --ResourceUseDisplay.mem_warning_threshold=0.2
else
echo "Error! Jupyterlab version not supported."
fi
fi
2 changes: 1 addition & 1 deletion jupyterlab3/environments.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
"auth_server": "auth.maap-project.org",
"mas_server": "mas.maap-project.org",
"edsc_server": "ade.maap-project.org:30052",
"workspace_bucket": "maap-ops-dataset",
"workspace_bucket": "maap-ops-workspace",
"default_host": false
}
]
9 changes: 8 additions & 1 deletion jupyterlab3/pangeo/environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,14 @@ dependencies:
- shapely=2.0.1
- xmltodict=0.13.0
- xarray=2023.5.0
- pip
- pip:
- rio_tiler==4.1.11
- pystac_client==0.6.1
- git+https://github.com/MAAP-Project/[email protected]#egg-info=stac_ipyleaflet
- git+https://github.com/MAAP-Project/[email protected]#egg-info=stac_ipyleaflet
variables:
TITILER_STAC_ENDPOINT: 'https://titiler-stac.maap-project.org/'
TITILER_ENDPOINT: 'https://titiler.maap-project.org/'
STAC_CATALOG_NAME: 'MAAP STAC'
STAC_CATALOG_URL: 'https://stac.maap-project.org/'
STAC_BROWSER_URL: 'https://stac-browser.maap-project.org/'