Skip to content

Commit 40270bb

Browse files
tejaskashTejas Kashinath
andauthored
Adding env var for project storage path, updating path to libmgmt script (#719)
Co-authored-by: Tejas Kashinath <[email protected]>
1 parent 0fc2d44 commit 40270bb

File tree

6 files changed

+44
-30
lines changed

6 files changed

+44
-30
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: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,21 @@ 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+
160175
if [ $is_s3_storage_flag -ne 0 ]; then
161176
# Creating a directory where the repository will be cloned
162177
mkdir -p "$HOME/src"
@@ -189,7 +204,7 @@ if [ "${SAGEMAKER_APP_TYPE_LOWERCASE}" = "jupyterlab" ]; then
189204
# code will be returned if there is not a minimum of 2
190205
# CPU cores available.
191206
# Start workflows local runner
192-
bash /etc/sagemaker-ui/workflows/start-workflows-container.sh "$is_s3_storage_flag"
207+
bash /etc/sagemaker-ui/workflows/start-workflows-container.sh
193208

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

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

203218
# Install sm-spark-cli
204219
bash /etc/sagemaker-ui/workflows/sm-spark-cli-install.sh

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

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,8 @@
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"
10-
else
11-
PROJECT_DIR="$HOME/src"
12-
echo "Project is using Git storage, project directory set to: $PROJECT_DIR"
13-
fi
4+
# Get project directory based on storage type
5+
PROJECT_DIR=${SMUS_PROJECT_DIR:-"$HOME/src"}
146

157
# Datazone project metadata
168
RESOURCE_METADATA_FILE=/opt/ml/metadata/resource-metadata.json

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: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,21 @@ 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+
160175
if [ $is_s3_storage_flag -ne 0 ]; then
161176
# Creating a directory where the repository will be cloned
162177
mkdir -p "$HOME/src"
@@ -189,7 +204,7 @@ if [ "${SAGEMAKER_APP_TYPE_LOWERCASE}" = "jupyterlab" ]; then
189204
# code will be returned if there is not a minimum of 2
190205
# CPU cores available.
191206
# Start workflows local runner
192-
bash /etc/sagemaker-ui/workflows/start-workflows-container.sh "$is_s3_storage_flag"
207+
bash /etc/sagemaker-ui/workflows/start-workflows-container.sh
193208

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

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

203218
# Install sm-spark-cli
204219
bash /etc/sagemaker-ui/workflows/sm-spark-cli-install.sh

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

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,8 @@
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"
10-
else
11-
PROJECT_DIR="$HOME/src"
12-
echo "Project is using Git storage, project directory set to: $PROJECT_DIR"
13-
fi
4+
# Get project directory based on storage type
5+
PROJECT_DIR=${SMUS_PROJECT_DIR:-"$HOME/src"}
146

157
# Datazone project metadata
168
RESOURCE_METADATA_FILE=/opt/ml/metadata/resource-metadata.json

0 commit comments

Comments
 (0)