refined snakeapi_service files

This commit is contained in:
yoshi 2025-04-29 15:01:23 -07:00
parent 61650658eb
commit 0a143b3dc7
4 changed files with 127 additions and 29 deletions

View file

@ -1,17 +1,16 @@
#!/usr/bin/env bash
NOTEBOOK_DIR="notebooks"
mkdir -p ${NOTEBOOK_DIR}
mkdir -p "${NOTEBOOK_DIR}"
while true; do
aws --endpoint-url "$AWS_ENDPOINT_URL_S3" --region "$AWS_REGION" \
s3 sync "s3://$BUCKET_NAME/$INSTANCE_PREFIX/notebooks/" "${NOTEBOOK_DIR}/"
# fetch latest notebook
aws --endpoint-url "$AWS_ENDPOINT_URL_S3" --region "$AWS_REGION" \
s3 sync "s3://$BUCKET_NAME/$INSTANCE_PREFIX/notebooks/" "${NOTEBOOK_DIR}/"
latest_notebook=$(ls -t ${NOTEBOOK_DIR}/*.ipynb | head -1)
# convert to Python script for dynamic import
latest_ipynb=$(ls -t "${NOTEBOOK_DIR}"/*.ipynb | head -1)
if [ -n "$latest_ipynb" ]; then
jupyter nbconvert --to script "$latest_ipynb" --output "${NOTEBOOK_DIR}/notebook.py"
fi
if [ -n "$latest_notebook" ]; then
jupyter nbconvert --to notebook --execute --inplace --ExecutePreprocessor.timeout=0 "$latest_notebook"
fi
sleep 5
done
# start the Flask server
python snakeapi_server.py