Skip to content

Commit de323b0

Browse files
committed
Merge in workflow fixes from v2.5 image
1 parent 6b5cd2d commit de323b0

8 files changed

Lines changed: 28 additions & 64 deletions

File tree

build_artifacts/v2/v2.6/v2.6.0/dirs/etc/sagemaker-ui/workflows/requirements/requirements.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,5 @@
33

44
amzn_sagemaker_studio
55
amzn_SagemakerWorkflowsOperator
6+
7+

build_artifacts/v2/v2.6/v2.6.0/dirs/etc/sagemaker-ui/workflows/start-workflows-container.sh

Lines changed: 9 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -6,21 +6,18 @@ handle_workflows_startup_error() {
66
local detailed_status=""
77
case $step in
88
0)
9-
detailed_status="Workflows blueprint not enabled"
10-
;;
11-
1)
129
detailed_status="Not enough memory"
1310
;;
14-
2)
11+
1)
1512
detailed_status="Error creating directories"
1613
;;
17-
3)
14+
2)
1815
detailed_status="Error installing docker"
1916
;;
20-
4)
17+
3)
2118
detailed_status="Error copying prerequisite files"
2219
;;
23-
5)
20+
4)
2421
detailed_status="Error starting workflows image"
2522
# Kill any orphans that may have started
2623
python /etc/sagemaker-ui/workflows/workflow_client.py stop-local-runner
@@ -66,18 +63,12 @@ if [ ! -f "${WORKFLOW_HEALTH_PATH}/status.json" ]; then
6663
echo "[]" > "${WORKFLOW_HEALTH_PATH}/status.json"
6764
fi
6865

69-
# Only start local runner if Workflows blueprint is enabled
70-
if [ "$(python /etc/sagemaker-ui/workflows/workflow_client.py check-blueprint --domain-id "$DZ_DOMAIN_ID")" = "False" ]; then
71-
echo "Workflows blueprint is not enabled. Workflows will not start."
72-
handle_workflows_startup_error 0
73-
fi
74-
7566
# Do minimum system requirements check: 4GB RAM and more than 2 CPU cores
7667
free_mem=$(free -m | awk '/^Mem:/ {print $7}')
7768
cpu_cores=$(nproc)
7869
if [[ $free_mem -lt 4096 ]] || [[ $cpu_cores -le 2 ]]; then
7970
echo "There is less than 4GB of available RAM or <=2 CPU cores. Workflows will not start. Free mem: $free_mem MB, CPU cores: $cpu_cores"
80-
handle_workflows_startup_error 1
71+
handle_workflows_startup_error 0
8172
fi
8273

8374
(
@@ -91,7 +82,7 @@ mkdir -p $WORKFLOW_REQUIREMENTS_PATH
9182
mkdir -p $WORKFLOW_PLUGINS_PATH
9283
mkdir -p $WORKFLOW_STARTUP_PATH
9384
mkdir -p $WORKFLOW_OUTPUT_PATH
94-
) || handle_workflows_startup_error 2
85+
) || handle_workflows_startup_error 1
9586

9687
(
9788
# Set the status of the status file to 'starting'
@@ -111,7 +102,7 @@ sudo apt-get update
111102
VERSION_ID=$(cat /etc/os-release | grep -oP 'VERSION_ID=".*"' | cut -d'"' -f2)
112103
VERSION_STRING=$(sudo apt-cache madison docker-ce | awk '{ print $3 }' | grep -i $VERSION_ID | head -n 1)
113104
sudo apt-get install docker-ce-cli=$VERSION_STRING docker-compose-plugin=2.29.2-1~ubuntu.22.04~jammy -y --allow-downgrades
114-
) || handle_workflows_startup_error 3
105+
) || handle_workflows_startup_error 2
115106

116107
(
117108
# Set status to copying files
@@ -158,7 +149,7 @@ if [ -d $USER_PLUGINS_FOLDER ]; then
158149
cp -r $USER_PLUGINS_FOLDER/* $WORKFLOW_PLUGINS_PATH
159150
fi
160151

161-
) || handle_workflows_startup_error 4
152+
) || handle_workflows_startup_error 3
162153

163154
(
164155
# Set status to installing workflows image
@@ -179,7 +170,7 @@ DZ_ENV_ID=$DZ_ENV_ID \
179170
DZ_DOMAIN_REGION=$DZ_DOMAIN_REGION \
180171
DZ_PROJECT_S3PATH=$DZ_PROJECT_S3PATH \
181172
docker compose -f /etc/sagemaker-ui/workflows/docker-compose.yaml up -d --quiet-pull
182-
) || handle_workflows_startup_error 5
173+
) || handle_workflows_startup_error 4
183174

184175
# Set status to waiting for image to start
185176
python /etc/sagemaker-ui/workflows/workflow_client.py update-local-runner-status --status 'starting' --detailed-status 'Waiting for workflows image to start'
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,3 @@
11
#!/bin/sh
2+
3+

build_artifacts/v2/v2.6/v2.6.0/dirs/etc/sagemaker-ui/workflows/workflow_client.py

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,11 @@
11
import argparse
2-
import boto3
32
from typing import Optional
43
import requests
54
from datetime import datetime, timezone
65

76
JUPYTERLAB_URL = "http://default:8888/jupyterlab/default/"
87
WORKFLOWS_API_ENDPOINT = "api/sagemaker/workflows"
98
TIMESTAMP_FORMAT = "%Y-%m-%d %H:%M:%S.%f%z"
10-
DZ_CLIENT = boto3.client("datazone")
119

1210
def _validate_response(function_name: str, response: requests.Response):
1311
if response.status_code == 200:
@@ -50,18 +48,10 @@ def stop_local_runner(session: requests.Session, **kwargs):
5048
)
5149
return _validate_response("StopLocalRunner", response)
5250

53-
def check_blueprint(domain_id: str, **kwargs):
54-
try:
55-
workflow_blueprint = DZ_CLIENT.list_environment_blueprints(domainIdentifier=domain_id, name='Workflows')['items']
56-
print(str(bool(workflow_blueprint)))
57-
except:
58-
print("False")
59-
6051
COMMAND_REGISTRY = {
6152
"update-local-runner-status": update_local_runner_status,
6253
"start-local-runner": start_local_runner,
63-
"stop-local-runner": stop_local_runner,
64-
"check-blueprint": check_blueprint
54+
"stop-local-runner": stop_local_runner
6555
}
6656

6757
def main():
@@ -80,9 +70,6 @@ def main():
8070

8171
stop_parser = subparsers.add_parser("stop-local-runner", help="Stop local runner")
8272

83-
check_blueprint_parser = subparsers.add_parser("check-blueprint", help="Check Workflows blueprint")
84-
check_blueprint_parser.add_argument("--domain-id", type=str, required=True, help="Datazone Domain ID for blueprint check")
85-
8673
args = parser.parse_args()
8774

8875
# create the request session

template/v2/dirs/etc/sagemaker-ui/workflows/requirements/requirements.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,5 @@
33

44
amzn_sagemaker_studio
55
amzn_SagemakerWorkflowsOperator
6+
7+

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

Lines changed: 9 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -6,21 +6,18 @@ handle_workflows_startup_error() {
66
local detailed_status=""
77
case $step in
88
0)
9-
detailed_status="Workflows blueprint not enabled"
10-
;;
11-
1)
129
detailed_status="Not enough memory"
1310
;;
14-
2)
11+
1)
1512
detailed_status="Error creating directories"
1613
;;
17-
3)
14+
2)
1815
detailed_status="Error installing docker"
1916
;;
20-
4)
17+
3)
2118
detailed_status="Error copying prerequisite files"
2219
;;
23-
5)
20+
4)
2421
detailed_status="Error starting workflows image"
2522
# Kill any orphans that may have started
2623
python /etc/sagemaker-ui/workflows/workflow_client.py stop-local-runner
@@ -66,18 +63,12 @@ if [ ! -f "${WORKFLOW_HEALTH_PATH}/status.json" ]; then
6663
echo "[]" > "${WORKFLOW_HEALTH_PATH}/status.json"
6764
fi
6865

69-
# Only start local runner if Workflows blueprint is enabled
70-
if [ "$(python /etc/sagemaker-ui/workflows/workflow_client.py check-blueprint --domain-id "$DZ_DOMAIN_ID")" = "False" ]; then
71-
echo "Workflows blueprint is not enabled. Workflows will not start."
72-
handle_workflows_startup_error 0
73-
fi
74-
7566
# Do minimum system requirements check: 4GB RAM and more than 2 CPU cores
7667
free_mem=$(free -m | awk '/^Mem:/ {print $7}')
7768
cpu_cores=$(nproc)
7869
if [[ $free_mem -lt 4096 ]] || [[ $cpu_cores -le 2 ]]; then
7970
echo "There is less than 4GB of available RAM or <=2 CPU cores. Workflows will not start. Free mem: $free_mem MB, CPU cores: $cpu_cores"
80-
handle_workflows_startup_error 1
71+
handle_workflows_startup_error 0
8172
fi
8273

8374
(
@@ -91,7 +82,7 @@ mkdir -p $WORKFLOW_REQUIREMENTS_PATH
9182
mkdir -p $WORKFLOW_PLUGINS_PATH
9283
mkdir -p $WORKFLOW_STARTUP_PATH
9384
mkdir -p $WORKFLOW_OUTPUT_PATH
94-
) || handle_workflows_startup_error 2
85+
) || handle_workflows_startup_error 1
9586

9687
(
9788
# Set the status of the status file to 'starting'
@@ -111,7 +102,7 @@ sudo apt-get update
111102
VERSION_ID=$(cat /etc/os-release | grep -oP 'VERSION_ID=".*"' | cut -d'"' -f2)
112103
VERSION_STRING=$(sudo apt-cache madison docker-ce | awk '{ print $3 }' | grep -i $VERSION_ID | head -n 1)
113104
sudo apt-get install docker-ce-cli=$VERSION_STRING docker-compose-plugin=2.29.2-1~ubuntu.22.04~jammy -y --allow-downgrades
114-
) || handle_workflows_startup_error 3
105+
) || handle_workflows_startup_error 2
115106

116107
(
117108
# Set status to copying files
@@ -158,7 +149,7 @@ if [ -d $USER_PLUGINS_FOLDER ]; then
158149
cp -r $USER_PLUGINS_FOLDER/* $WORKFLOW_PLUGINS_PATH
159150
fi
160151

161-
) || handle_workflows_startup_error 4
152+
) || handle_workflows_startup_error 3
162153

163154
(
164155
# Set status to installing workflows image
@@ -179,7 +170,7 @@ DZ_ENV_ID=$DZ_ENV_ID \
179170
DZ_DOMAIN_REGION=$DZ_DOMAIN_REGION \
180171
DZ_PROJECT_S3PATH=$DZ_PROJECT_S3PATH \
181172
docker compose -f /etc/sagemaker-ui/workflows/docker-compose.yaml up -d --quiet-pull
182-
) || handle_workflows_startup_error 5
173+
) || handle_workflows_startup_error 4
183174

184175
# Set status to waiting for image to start
185176
python /etc/sagemaker-ui/workflows/workflow_client.py update-local-runner-status --status 'starting' --detailed-status 'Waiting for workflows image to start'
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,3 @@
11
#!/bin/sh
2+
3+

template/v2/dirs/etc/sagemaker-ui/workflows/workflow_client.py

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,11 @@
11
import argparse
2-
import boto3
32
from typing import Optional
43
import requests
54
from datetime import datetime, timezone
65

76
JUPYTERLAB_URL = "http://default:8888/jupyterlab/default/"
87
WORKFLOWS_API_ENDPOINT = "api/sagemaker/workflows"
98
TIMESTAMP_FORMAT = "%Y-%m-%d %H:%M:%S.%f%z"
10-
DZ_CLIENT = boto3.client("datazone")
119

1210
def _validate_response(function_name: str, response: requests.Response):
1311
if response.status_code == 200:
@@ -50,18 +48,10 @@ def stop_local_runner(session: requests.Session, **kwargs):
5048
)
5149
return _validate_response("StopLocalRunner", response)
5250

53-
def check_blueprint(domain_id: str, **kwargs):
54-
try:
55-
workflow_blueprint = DZ_CLIENT.list_environment_blueprints(domainIdentifier=domain_id, name='Workflows')['items']
56-
print(str(bool(workflow_blueprint)))
57-
except:
58-
print("False")
59-
6051
COMMAND_REGISTRY = {
6152
"update-local-runner-status": update_local_runner_status,
6253
"start-local-runner": start_local_runner,
63-
"stop-local-runner": stop_local_runner,
64-
"check-blueprint": check_blueprint
54+
"stop-local-runner": stop_local_runner
6555
}
6656

6757
def main():
@@ -80,9 +70,6 @@ def main():
8070

8171
stop_parser = subparsers.add_parser("stop-local-runner", help="Stop local runner")
8272

83-
check_blueprint_parser = subparsers.add_parser("check-blueprint", help="Check Workflows blueprint")
84-
check_blueprint_parser.add_argument("--domain-id", type=str, required=True, help="Datazone Domain ID for blueprint check")
85-
8673
args = parser.parse_args()
8774

8875
# create the request session

0 commit comments

Comments
 (0)