diff --git a/.buildkite/scripts/pr_test.sh b/.buildkite/scripts/pr_test.sh index cadf79be6..52dff1c8a 100755 --- a/.buildkite/scripts/pr_test.sh +++ b/.buildkite/scripts/pr_test.sh @@ -65,6 +65,30 @@ if [ "$EFFECTIVE_PR" = "false" ] && [ -n "${PR_NUMBER:-}" ]; then fi MODAL_ENV="BUILDKITE_REPO=$BUILDKITE_REPO BUILDKITE_COMMIT=$BUILDKITE_COMMIT BUILDKITE_PULL_REQUEST=$EFFECTIVE_PR BUILDKITE_BRANCH=${BUILDKITE_BRANCH:-} TEST_SCOPE=${TEST_SCOPE:-} IMAGE_VERSION=$IMAGE_VERSION" +POST_RUN_HOOK="" + +upload_performance_artifacts() { + SHORT_SHA=${BUILDKITE_COMMIT:0:7} + LOCAL_DIR="downloaded_reports" + + log "Downloading reports directory from Modal Volume..." + mkdir -p "$LOCAL_DIR" + modal volume get hf-model-weights "perf_reports/" "$LOCAL_DIR" + + TARGET_FILE=$(find "$LOCAL_DIR" -name "*${SHORT_SHA}*" | head -n 1) + log "TARGET_FILE: '$TARGET_FILE'" + + if [ -n "$TARGET_FILE" ]; then + log "Found dashboard: $TARGET_FILE. Uploading to Buildkite..." + buildkite-agent artifact upload "$TARGET_FILE" + buildkite-agent annotate --style info --context "perf" < "$TARGET_FILE" + else + log "Warning: Could not find a dashboard file matching $SHORT_SHA" + fi + + rm -rf "$LOCAL_DIR" +} + case "$TEST_TYPE" in "encoder") log "Running encoder tests..." @@ -124,43 +148,9 @@ case "$TEST_TYPE" in MODAL_COMMAND="$MODAL_ENV HF_API_KEY=$HF_API_KEY python3 -m modal run $MODAL_TEST_FILE::run_lora_extraction_tests" ;; "performance") - # log "Running performance tests..." - # MODAL_COMMAND="$MODAL_ENV HF_API_KEY=$HF_API_KEY python3 -m modal run $MODAL_TEST_FILE::run_performance_tests" - # ;; log "Running performance tests on Modal..." MODAL_COMMAND="$MODAL_ENV HF_API_KEY=$HF_API_KEY python3 -m modal run $MODAL_TEST_FILE::run_performance_tests" - - eval "$MODAL_COMMAND" - TEST_EXIT_CODE=$? - - # 1. Define variables - SHORT_SHA=${BUILDKITE_COMMIT:0:7} - REMOTE_DIR="perf_reports/" - LOCAL_DIR="downloaded_reports" - - log "Downloading reports directory from Modal Volume..." - - # 2. Download the whole folder to a temporary local directory - # modal volume get - mkdir -p "$LOCAL_DIR" - modal volume get hf-model-weights "$REMOTE_DIR" "$LOCAL_DIR" - - # 3. Find the specific file for THIS commit - # We look inside the downloaded folder for a file containing our SHORT_SHA - TARGET_FILE=$(ls "$LOCAL_DIR" | grep "$SHORT_SHA" | head -n 1) - - if [ -n "$TARGET_FILE" ]; then - LOCAL_PATH="$LOCAL_DIR/$TARGET_FILE" - log "Found dashboard: $TARGET_FILE. Uploading to Buildkite..." - - buildkite-agent artifact upload "$LOCAL_PATH" - buildkite-agent annotate --style info --context "perf" < "$LOCAL_PATH" - else - log "Warning: Could not find a dashboard file matching $SHORT_SHA in $REMOTE_DIR" - fi - - # Clean up the temporary folder - rm -rf "$LOCAL_DIR" + POST_RUN_HOOK="upload_performance_artifacts" ;; "api_server") log "Running API server integration tests..." @@ -182,5 +172,10 @@ else log "Error: Modal test failed with exit code: $TEST_EXIT_CODE" fi +if [ -n "$POST_RUN_HOOK" ]; then + log "Executing post-run hook: $POST_RUN_HOOK" + "$POST_RUN_HOOK" +fi + log "=== Test execution completed with exit code: $TEST_EXIT_CODE ===" exit $TEST_EXIT_CODE