Skip to content

Commit

Permalink
Merge pull request #14 from kbase/dev_dynamic_allocation
Browse files Browse the repository at this point in the history
set dynamic allocation for parallel jobs
  • Loading branch information
Tianhao-Gu authored May 31, 2024
2 parents f53c262 + a982887 commit baa5869
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 9 deletions.
1 change: 1 addition & 0 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -103,5 +103,6 @@ services:
- MINIO_ACCESS_KEY=minio
- MINIO_SECRET_KEY=minio123
- SPARK_MODE=notebook
- MAX_EXECUTORS=2
volumes:
- ./cdr/cdm/jupyter:/cdm_shared_workspace
31 changes: 22 additions & 9 deletions scripts/notebook_entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,36 @@

echo "starting jupyter notebook"

if [ -n "$SPARK_DRIVER_HOST" ]; then
echo "Setting spark.driver.host to $SPARK_DRIVER_HOST"
source /opt/bitnami/scripts/spark-env.sh
if [ -z "$SPARK_CONF_FILE" ]; then
echo "Error: unable to find SPARK_CONF_FILE path"
exit 1
fi
echo "spark.driver.host $SPARK_DRIVER_HOST" >> $SPARK_CONF_FILE
source /opt/bitnami/scripts/spark-env.sh
if [ -z "$SPARK_CONF_FILE" ]; then
echo "Error: unable to find SPARK_CONF_FILE path"
exit 1
fi

# Set Spark configurations
{
# Set dynamic allocation configurations to allow parallel job executions
if [ -z "$MAX_EXECUTORS" ]; then
# If MAX_EXECUTORS is not set, default to 5. Adjust as needed.
MAX_EXECUTORS=5
fi
echo "spark.dynamicAllocation.enabled true"
echo "spark.dynamicAllocation.minExecutors 1"
echo "spark.dynamicAllocation.maxExecutors $MAX_EXECUTORS"

# Set spark.driver.host if SPARK_DRIVER_HOST is set
if [ -n "$SPARK_DRIVER_HOST" ]; then
echo "spark.driver.host $SPARK_DRIVER_HOST"
fi
} >> "$SPARK_CONF_FILE"

WORKSPACE_DIR="/cdm_shared_workspace"
mkdir -p "$WORKSPACE_DIR"
cd "$WORKSPACE_DIR"

# Start Jupyter Lab
jupyter lab --ip=0.0.0.0 \
--port=$NOTEBOOK_PORT \
--port="$NOTEBOOK_PORT" \
--no-browser \
--allow-root \
--notebook-dir="$WORKSPACE_DIR" \
Expand Down

0 comments on commit baa5869

Please sign in to comment.