Skip to content

Commit

Permalink
feature: use specific base_url for Jupyter server if SAGEMAKER_APP_TY…
Browse files Browse the repository at this point in the history
…PE is set (#78)

**Description**

* If SAGEMAKER_APP_TYPE env variable is set, use
  /<app-type-in-lower-case>/default as the base URI for Jupyter server

**Motivation**

* SageMaker will require the base URL of Jupyter server to be set to
  include app type for the image to be used by SageMaker apps.

**Testing Done**

* bb release
* Tested with `docker run -p 8888:8888 --env SAGEMAKER_APP_TYPE=Savitur
  --entrypoint entrypoint-jupyter-server` and confirmed base URI is
correctly set
* Tested with `docker run -p 8888:8888 --entrypoint
  entrypoint-jupyter-server` and confirmed base URI is not set

**Backwards Compatibility Criteria (if any)**

* N/A

Co-authored-by: Zuoyuan Huang <[email protected]>
  • Loading branch information
zuoyuanh and Zuoyuan Huang authored Oct 16, 2023
1 parent 49d50e5 commit aab51cf
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,16 @@ eval "$(micromamba shell hook --shell=bash)"
micromamba activate base

# Start Jupyter server
jupyter lab --ip 0.0.0.0 --port 8888 \
--ServerApp.token='' \
--ServerApp.allow_origin='*'
if [ -n "$SAGEMAKER_APP_TYPE" ]; then
# SAGEMAKER_APP_TYPE is set, indicating the server is running within a SageMaker
# app. Configure the base url to be `/<app-type-in-lower-case>/default`.
SAGEMAKER_APP_TYPE_LOWERCASE=$(echo $SAGEMAKER_APP_TYPE | tr '[:upper:]' '[:lower:]')
jupyter lab --ip 0.0.0.0 --port 8888 \
--ServerApp.base_url="/$SAGEMAKER_APP_TYPE_LOWERCASE/default" \
--ServerApp.token='' \
--ServerApp.allow_origin='*'
else
jupyter lab --ip 0.0.0.0 --port 8888 \
--ServerApp.token='' \
--ServerApp.allow_origin='*'
fi
16 changes: 13 additions & 3 deletions template/dirs/usr/local/bin/start-jupyter-server
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,16 @@ eval "$(micromamba shell hook --shell=bash)"
micromamba activate base

# Start Jupyter server
jupyter lab --ip 0.0.0.0 --port 8888 \
--ServerApp.token='' \
--ServerApp.allow_origin='*'
if [ -n "$SAGEMAKER_APP_TYPE" ]; then
# SAGEMAKER_APP_TYPE is set, indicating the server is running within a SageMaker
# app. Configure the base url to be `/<app-type-in-lower-case>/default`.
SAGEMAKER_APP_TYPE_LOWERCASE=$(echo $SAGEMAKER_APP_TYPE | tr '[:upper:]' '[:lower:]')
jupyter lab --ip 0.0.0.0 --port 8888 \
--ServerApp.base_url="/$SAGEMAKER_APP_TYPE_LOWERCASE/default" \
--ServerApp.token='' \
--ServerApp.allow_origin='*'
else
jupyter lab --ip 0.0.0.0 --port 8888 \
--ServerApp.token='' \
--ServerApp.allow_origin='*'
fi

0 comments on commit aab51cf

Please sign in to comment.