Skip to content

Commit 2eb0dff

Browse files
authored
Merge branch 'aws:main' into main
2 parents f8610be + dd1016b commit 2eb0dff

11 files changed

+64
-28
lines changed

template/v2/dirs/etc/sagemaker-ui/libmgmt/install-lib.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
#!/bin/bash
22
set -eux
3-
3+
PROJECT_DIR=${SMUS_PROJECT_DIR:-"$HOME/src"}
44
# Check if the .libs.json file exists
5-
if [ -e $1/.libs.json ]; then
6-
lib_config_json=`cat $1/.libs.json`
5+
if [ -e $PROJECT_DIR/.libs.json ]; then
6+
lib_config_json=`cat $PROJECT_DIR/.libs.json`
77

88
apply_change_to_space=`echo $lib_config_json | jq -r '.ApplyChangeToSpace'`
99
# Extract conda channels from the config, add `-c ` before each channel and join the strings

template/v2/dirs/etc/sagemaker-ui/sagemaker_ui_post_startup.sh

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,26 @@ echo "Checking Project Storage Type"
157157
is_s3_storage
158158
is_s3_storage_flag=$? # 0 if S3 storage, 1 if Git
159159

160+
if [ "$is_s3_storage_flag" -eq 0 ]; then
161+
export SMUS_PROJECT_DIR="$HOME/shared"
162+
echo "Project is using S3 storage, project directory set to: $SMUS_PROJECT_DIR"
163+
else
164+
export SMUS_PROJECT_DIR="$HOME/src"
165+
echo "Project is using Git storage, project directory set to: $SMUS_PROJECT_DIR"
166+
fi
167+
168+
if grep -q "^SMUS_PROJECT_DIR=" ~/.bashrc; then
169+
echo "SMUS_PROJECT_DIR is defined in the env"
170+
else
171+
echo SMUS_PROJECT_DIR="$SMUS_PROJECT_DIR" >> ~/.bashrc
172+
echo readonly SMUS_PROJECT_DIR >> ~/.bashrc
173+
fi
174+
175+
# Write SMUS_PROJECT_DIR to a JSON file to be accessed by JupyterLab Extensions
176+
jq -n \
177+
--arg smusProjectDirectory "$SMUS_PROJECT_DIR" \
178+
'{ smusProjectDirectory: $smusProjectDirectory }' > $HOME/.config/smus-storage-metadata.json
179+
160180
if [ $is_s3_storage_flag -ne 0 ]; then
161181
# Creating a directory where the repository will be cloned
162182
mkdir -p "$HOME/src"
@@ -189,7 +209,7 @@ if [ "${SAGEMAKER_APP_TYPE_LOWERCASE}" = "jupyterlab" ]; then
189209
# code will be returned if there is not a minimum of 2
190210
# CPU cores available.
191211
# Start workflows local runner
192-
bash /etc/sagemaker-ui/workflows/start-workflows-container.sh "$is_s3_storage_flag"
212+
bash /etc/sagemaker-ui/workflows/start-workflows-container.sh
193213

194214
# ensure functions inherit traps and fail immediately
195215
set -eE
@@ -198,7 +218,7 @@ if [ "${SAGEMAKER_APP_TYPE_LOWERCASE}" = "jupyterlab" ]; then
198218
trap 'write_status_to_file "error" "An unexpected error occurred. Please stop and restart your space to retry."' ERR
199219

200220
# Install conda and pip dependencies if lib mgmt config existing
201-
bash /etc/sagemaker-ui/libmgmt/install-lib.sh $HOME/src
221+
bash /etc/sagemaker-ui/libmgmt/install-lib.sh
202222

203223
# Install sm-spark-cli
204224
bash /etc/sagemaker-ui/workflows/sm-spark-cli-install.sh

template/v2/dirs/etc/sagemaker-ui/workflows/docker-compose.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ x-airflow-common: &airflow-common
4343
- /home/sagemaker-user/.workflows_setup/plugins:/usr/local/airflow/plugins
4444
- /home/sagemaker-user/.workflows_setup/requirements:/usr/local/airflow/requirements
4545
- /home/sagemaker-user/.workflows_setup/startup:/usr/local/airflow/startup
46-
- /home/sagemaker-user/src:/home/sagemaker-user/src:rw
46+
- ${MOUNT_DIR}:/home/sagemaker-user/src:rw
4747
- /home/sagemaker-user/jobs:/home/sagemaker-user/jobs:rw
4848
depends_on: &airflow-common-depends-on
4949
postgres:

template/v2/dirs/etc/sagemaker-ui/workflows/start-workflows-container.sh

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,12 @@
11
#!/bin/bash
22
set -eu
33

4-
# Get the is_s3_storage_flag parameter passed from the calling script
5-
is_s3_storage=${1:-"1"} # Default to 1 (Git storage) if no parameter is passed
6-
# Set project directory based on storage type
7-
if [ "$is_s3_storage" -eq 0 ]; then
8-
PROJECT_DIR="$HOME/shared"
9-
echo "Project is using S3 storage, project directory set to: $PROJECT_DIR"
4+
# Get project directory based on storage type
5+
PROJECT_DIR=${SMUS_PROJECT_DIR:-"$HOME/src"}
6+
if [ -z "$SMUS_PROJECT_DIR" ]; then
7+
MOUNT_DIR=$PROJECT_DIR
108
else
11-
PROJECT_DIR="$HOME/src"
12-
echo "Project is using Git storage, project directory set to: $PROJECT_DIR"
9+
MOUNT_DIR=$(readlink -f "$PROJECT_DIR") # get the symlink source
1310
fi
1411

1512
# Datazone project metadata
@@ -186,6 +183,7 @@ cp -n "/etc/sagemaker-ui/workflows/sample_dag.py" "${WORKFLOW_DAG_PATH}/"
186183
aws ecr get-login-password --region ${AWS_REGION} | docker login --username AWS --password-stdin ${ECR_ACCOUNT_ID}.dkr.ecr.${AWS_REGION}.amazonaws.com
187184

188185
PROJECT_DIR=$(basename $PROJECT_DIR) \
186+
MOUNT_DIR=$MOUNT_DIR \
189187
ECR_ACCOUNT_ID=$ECR_ACCOUNT_ID \
190188
ACCOUNT_ID=$AWS_ACCOUNT_ID \
191189
DZ_DOMAIN_ID=$DZ_DOMAIN_ID \

template/v3/dirs/etc/sagemaker-ui/libmgmt/install-lib.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
#!/bin/bash
22
set -eux
3-
3+
PROJECT_DIR=${SMUS_PROJECT_DIR:-"$HOME/src"}
44
# Check if the .libs.json file exists
5-
if [ -e $1/.libs.json ]; then
6-
lib_config_json=`cat $1/.libs.json`
5+
if [ -e $PROJECT_DIR/.libs.json ]; then
6+
lib_config_json=`cat $PROJECT_DIR/.libs.json`
77

88
apply_change_to_space=`echo $lib_config_json | jq -r '.ApplyChangeToSpace'`
99
# Extract conda channels from the config, add `-c ` before each channel and join the strings

template/v3/dirs/etc/sagemaker-ui/sagemaker_ui_post_startup.sh

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,26 @@ echo "Checking Project Storage Type"
157157
is_s3_storage
158158
is_s3_storage_flag=$? # 0 if S3 storage, 1 if Git
159159

160+
if [ "$is_s3_storage_flag" -eq 0 ]; then
161+
export SMUS_PROJECT_DIR="$HOME/shared"
162+
echo "Project is using S3 storage, project directory set to: $SMUS_PROJECT_DIR"
163+
else
164+
export SMUS_PROJECT_DIR="$HOME/src"
165+
echo "Project is using Git storage, project directory set to: $SMUS_PROJECT_DIR"
166+
fi
167+
168+
if grep -q "^SMUS_PROJECT_DIR=" ~/.bashrc; then
169+
echo "SMUS_PROJECT_DIR is defined in the env"
170+
else
171+
echo SMUS_PROJECT_DIR="$SMUS_PROJECT_DIR" >> ~/.bashrc
172+
echo readonly SMUS_PROJECT_DIR >> ~/.bashrc
173+
fi
174+
175+
# Write SMUS_PROJECT_DIR to a JSON file to be accessed by JupyterLab Extensions
176+
jq -n \
177+
--arg smusProjectDirectory "$SMUS_PROJECT_DIR" \
178+
'{ smusProjectDirectory: $smusProjectDirectory }' > $HOME/.config/smus-storage-metadata.json
179+
160180
if [ $is_s3_storage_flag -ne 0 ]; then
161181
# Creating a directory where the repository will be cloned
162182
mkdir -p "$HOME/src"
@@ -189,7 +209,7 @@ if [ "${SAGEMAKER_APP_TYPE_LOWERCASE}" = "jupyterlab" ]; then
189209
# code will be returned if there is not a minimum of 2
190210
# CPU cores available.
191211
# Start workflows local runner
192-
bash /etc/sagemaker-ui/workflows/start-workflows-container.sh "$is_s3_storage_flag"
212+
bash /etc/sagemaker-ui/workflows/start-workflows-container.sh
193213

194214
# ensure functions inherit traps and fail immediately
195215
set -eE
@@ -198,7 +218,7 @@ if [ "${SAGEMAKER_APP_TYPE_LOWERCASE}" = "jupyterlab" ]; then
198218
trap 'write_status_to_file "error" "An unexpected error occurred. Please stop and restart your space to retry."' ERR
199219

200220
# Install conda and pip dependencies if lib mgmt config existing
201-
bash /etc/sagemaker-ui/libmgmt/install-lib.sh $HOME/src
221+
bash /etc/sagemaker-ui/libmgmt/install-lib.sh
202222

203223
# Install sm-spark-cli
204224
bash /etc/sagemaker-ui/workflows/sm-spark-cli-install.sh

template/v3/dirs/etc/sagemaker-ui/workflows/docker-compose.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ x-airflow-common: &airflow-common
4343
- /home/sagemaker-user/.workflows_setup/plugins:/usr/local/airflow/plugins
4444
- /home/sagemaker-user/.workflows_setup/requirements:/usr/local/airflow/requirements
4545
- /home/sagemaker-user/.workflows_setup/startup:/usr/local/airflow/startup
46-
- /home/sagemaker-user/src:/home/sagemaker-user/src:rw
46+
- ${MOUNT_DIR}:/home/sagemaker-user/src:rw
4747
- /home/sagemaker-user/jobs:/home/sagemaker-user/jobs:rw
4848
depends_on: &airflow-common-depends-on
4949
postgres:

0 commit comments

Comments
 (0)