@@ -170,24 +170,42 @@ with open(file_path, 'w') as f:
170170 f.write(content)
171171PYTHON_CLEANUP
172172
173- # Run the Python file with pyspark
174- echo " Running Python script..."
175- # Change to workspace directory so relative paths work correctly
173+ # Validate Python syntax first
174+ echo " Validating Python syntax..."
175+ if ! python3 -m py_compile " $PYTHON_FILE " > /dev/null 2> /dev/null; then
176+ echo " ✗ Python syntax validation failed"
177+ FAILED_TESTS=$(( FAILED_TESTS + 1 ))
178+ echo " "
179+ continue
180+ fi
181+
182+ # Run the full Python script with timeout (600 seconds = 10 minutes)
183+ echo " Running Python script (600 second timeout)..."
176184 cd " $EXAMPLES_DIR /.."
177- # Use timeout to prevent hanging tests (10 minutes max per test)
178- # Use absolute path to the Python file
179- if timeout 600 python3 " $PYTHON_FILE " 2>&1 ; then
180- echo " ✓ Test passed"
185+
186+ # Use timeout with progress reporting
187+ START_TIME=$( date +%s)
188+ if timeout 600 python3 " $PYTHON_FILE " | tee /tmp/notebook_output_$$ .log; then
189+ END_TIME=$( date +%s)
190+ ELAPSED=$(( END_TIME - START_TIME))
191+ echo " ✓ Test passed (completed in ${ELAPSED} s)"
181192 PASSED_TESTS=$(( PASSED_TESTS + 1 ))
182193 else
183194 EXIT_CODE=$?
195+ END_TIME=$( date +%s)
196+ ELAPSED=$(( END_TIME - START_TIME))
184197 if [ $EXIT_CODE -eq 124 ]; then
185- echo " ✗ Test timed out (exceeded 10 minutes)"
198+ echo " ✗ Test timed out (exceeded 600 seconds, ran for ${ELAPSED} s)"
199+ echo " Last 20 lines of output:"
200+ tail -20 /tmp/notebook_output_$$ .log 2> /dev/null || echo " (no output captured)"
186201 else
187- echo " ✗ Test failed with exit code $EXIT_CODE "
202+ echo " ✗ Test failed with exit code $EXIT_CODE (ran for ${ELAPSED} s)"
203+ echo " Last 20 lines of output:"
204+ tail -20 /tmp/notebook_output_$$ .log 2> /dev/null || echo " (no output captured)"
188205 fi
189206 FAILED_TESTS=$(( FAILED_TESTS + 1 ))
190207 fi
208+ rm -f /tmp/notebook_output_$$ .log
191209
192210 echo " "
193211done
0 commit comments