Skip to content

Commit f136781

Browse files
authored
Add wait and interval params (#235)
* add a --wait flag * use release branch * update script to accept add-wait-param as rc name * use add-wait-param package * use linux/amd64 * Update release.py * Fix run ID extraction when using --wait flag - Add debug output to troubleshoot command execution - Handle different output formats from dagster-cloud CLI when --wait is used - Extract run ID from status messages like 'Run <id> is in progress' - Fix GITHUB_OUTPUT format issue * work with multiple lines in stdout * Add comprehensive tests for wait parameter functionality - Test run script without wait flag (default behavior) - Test run script with wait flag enabled (multi-line output) - Test various truthy values for wait parameter - Test backwards compatibility when INPUT_WAIT is not set - Maintain original test for backwards compatibility - Handle extraction of run ID from both single line and multi-line outputs * Fix regex patterns for run ID extraction to handle test data - Make run ID regex more flexible to handle both UUIDs and test strings - Change from strict 36-char UUID pattern to more permissive alphanumeric pattern - Allows tests to pass with mock data like 'some-run' while still working with real UUIDs * clean up debugging and remove tests * add interval flag to github action if wait is enabled * add pex * use dev not rc add-wait-param in actions * add default interval wait time
1 parent b44111d commit f136781

File tree

6 files changed

+360
-4
lines changed

6 files changed

+360
-4
lines changed

actions/launch_job/action.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,13 @@ inputs:
2323
job_name:
2424
required: true
2525
description: "The name of the job to launch."
26+
wait:
27+
required: false
28+
default: "false"
29+
description: "Whether to wait for the job to complete before exiting. When true, the action will wait for the run to finish and fail if the run fails."
30+
interval:
31+
required: false
32+
description: "Interval in seconds between status checks when waiting for job completion. Can only be used when wait is true. Default is 30 seconds"
2633
runs:
2734
using: "composite"
2835
steps:
@@ -53,5 +60,7 @@ runs:
5360
location_name: ${{ inputs.location_name }}
5461
repository_name: ${{ inputs.repository_name }}
5562
job_name: ${{ inputs.job_name }}
63+
wait: ${{ inputs.wait }}
64+
interval: ${{ inputs.interval }}
5665
env:
5766
DAGSTER_CLOUD_API_TOKEN: ${{ inputs.dagster_cloud_api_token }}

actions/utils/run/action.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,13 @@ inputs:
2727
required: false
2828
description: "A JSON dict of config to apply to the run, input as a string."
2929
default: "{}"
30+
wait:
31+
required: false
32+
default: "false"
33+
description: "Whether to wait for the job to complete before exiting. When true, the action will wait for the run to finish and fail if the run fails."
34+
interval:
35+
required: false
36+
description: "Interval in seconds between status checks when waiting for job completion. Can only be used when wait is true."
3037
dagster_cloud_url:
3138
required: false
3239
description: "Alternative to providing organization ID. The URL of your Dagster Cloud organization."

generated/gha/dagster-cloud.pex

1.24 MB
Binary file not shown.

scripts/release.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ def build_docker_action(version_tag: str, publish_docker_action: bool = True):
6666
".",
6767
"-f",
6868
"src/Dockerfile",
69+
"--platform=linux/amd64",
6970
"-t",
7071
image_name,
7172
],

src/run.sh

Lines changed: 40 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,28 @@ if [ -z $DAGSTER_CLOUD_URL ]; then
99
fi
1010
fi
1111

12-
RUN_ID=$(
12+
# Check for wait flag - handle various true values
13+
wait_flag=""
14+
interval_flag=""
15+
case "$(echo "${INPUT_WAIT}" | tr '[:upper:]' '[:lower:]')" in
16+
"true"|"1"|"yes"|"on")
17+
wait_flag="--wait"
18+
# Only add interval flag if wait is enabled and interval is provided
19+
if [ -n "${INPUT_INTERVAL}" ]; then
20+
interval_flag="--interval ${INPUT_INTERVAL}"
21+
fi
22+
;;
23+
*)
24+
# Validate that interval is not used without wait
25+
if [ -n "${INPUT_INTERVAL}" ]; then
26+
echo "ERROR: interval parameter can only be used when wait is true"
27+
exit 1
28+
fi
29+
;;
30+
esac
31+
32+
# Run the command and capture all output
33+
COMMAND_OUTPUT=$(
1334
dagster-cloud job launch \
1435
--url "${DAGSTER_CLOUD_URL}" \
1536
--deployment "${INPUT_DEPLOYMENT}" \
@@ -18,11 +39,26 @@ RUN_ID=$(
1839
--repository "${INPUT_REPOSITORY_NAME}" \
1940
--job "${INPUT_JOB_NAME}" \
2041
--tags "${INPUT_TAGS_JSON}" \
21-
--config-json "${INPUT_CONFIG_JSON}"
42+
--config-json "${INPUT_CONFIG_JSON}" \
43+
${wait_flag} ${interval_flag} 2>&1
2244
)
2345

24-
if [ -z $RUN_ID ]; then
25-
echo "Failed to launch run"
46+
# Extract run ID from the output
47+
# Look for patterns like "Run <run-id> is in progress" or "Run <run-id> finished"
48+
RUN_ID=""
49+
if [[ "$COMMAND_OUTPUT" =~ Run\ ([a-f0-9-]+) ]]; then
50+
RUN_ID="${BASH_REMATCH[1]}"
51+
else
52+
# Try to get the first line if it looks like a run ID (for non-wait mode)
53+
FIRST_LINE=$(echo "$COMMAND_OUTPUT" | head -n1 | tr -d '\n\r')
54+
if [[ "$FIRST_LINE" =~ ^[a-zA-Z0-9-]+$ ]]; then
55+
RUN_ID="$FIRST_LINE"
56+
fi
57+
fi
58+
59+
if [ -z "$RUN_ID" ]; then
60+
echo "Failed to launch run or extract run ID"
61+
echo "Command output was: $COMMAND_OUTPUT"
2662
exit 1
2763
else
2864
echo "Successfully launched run: ${RUN_ID}"

0 commit comments

Comments
 (0)