@@ -21,12 +21,14 @@ total_count=0
2121successful_notebooks=()
2222successful_count=0
2323
24+ declare -A notebook_ops
25+
2426for x in $TARGET ; do
2527 total_count=$(( total_count + 1 ))
2628 # Use the full path from the repository for display name
2729 DISPLAY_NAME=" ${x## generative-ai/ } "
2830 DISPLAY_NAME=" ${DISPLAY_NAME% .ipynb} -$current_date -$current_time "
29- echo " Starting execution for ${x} "
31+ echo " Launching async execution for ${x} "
3032
3133 # Execute and get the operation ID
3234 OPERATION_ID=$( gcloud colab executions create \
@@ -37,37 +39,36 @@ for x in $TARGET; do
3739 --project=" $PROJECT_ID " \
3840 --region=" $REGION " \
3941 --service-account=" $SA " \
40- --verbosity=debug \
4142 --execution-timeout=" 1h30m" \
42- --format=" value(name)" )
43+ --format=" value(name)" \
44+ --async)
4345
4446 echo " Operation ID: $OPERATION_ID "
4547 TRUNCATED_OPERATION_ID=$( echo " $OPERATION_ID " | cut -c 67-85)
48+ notebook_ops[" $TRUNCATED_OPERATION_ID " ]=" $x "
49+ done
4650
47- # check job status
48- echo " Waiting for execution to complete..."
49- if ! EXECUTION_DETAILS=$( gcloud colab executions describe " $TRUNCATED_OPERATION_ID " --region=" $REGION " ) ; then
50- echo " Error describing execution for ${x} . See logs for details."
51- failed_count=$(( failed_count + 1 ))
52- failed_notebooks+=(" ${x} " )
53- continue
54- else
55- echo " Execution completed for ${x} "
56- fi
51+ # Wait and collect results
52+ for op_id in " ${! notebook_ops[@]} " ; do
53+ notebook=" ${notebook_ops[$op_id]} "
54+ echo " Checking status for $notebook (operation ID: $op_id )"
55+
56+ until EXECUTION_DETAILS=$( gcloud colab executions describe " $op_id " --region=" $REGION " 2> /dev/null) ; do
57+ echo " Waiting for operation $op_id ..."
58+ sleep 10
59+ done
5760
5861 # Check the jobState
5962 JOB_STATE=$( echo " $EXECUTION_DETAILS " | grep " jobState:" | awk ' {print $2}' )
6063 if [[ " $JOB_STATE " == " JOB_STATE_SUCCEEDED" ]]; then
61- echo " Notebook execution succeeded."
64+ echo " Notebook $notebook succeeded."
6265 successful_count=$(( successful_count + 1 ))
63- successful_notebooks+=(" ${x} " )
66+ successful_notebooks+=(" $notebook " )
6467 else
65- echo " Notebook execution failed. Job state: $JOB_STATE . Please use id $TRUNCATED_OPERATION_ID to troubleshoot notebook ${x} . See log for details. "
68+ echo " Notebook $notebook failed. Job state: $JOB_STATE "
6669 failed_count=$(( failed_count + 1 ))
67- failed_notebooks+=(" ${x} " )
68- continue
70+ failed_notebooks+=(" $notebook " )
6971 fi
70-
7172done
7273
7374# Print the final list of failed notebooks
0 commit comments