Skip to content

Commit c16ec7c

Browse files
committed
Refactor Python examples workflow to enhance testing with dataset variations and improve logging
1 parent abfce54 commit c16ec7c

1 file changed

Lines changed: 63 additions & 31 deletions

File tree

.github/workflows/test-python-examples.yml

Lines changed: 63 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -52,13 +52,6 @@ jobs:
5252
# Install dependencies needed by examples
5353
pip install numpy requests
5454
55-
- name: Download sample data
56-
run: |
57-
cd bindings/python/examples
58-
echo "📥 Downloading sample data for examples..."
59-
# Download large dataset for comprehensive testing
60-
python download_sample_data.py
61-
6255
- name: Run all examples
6356
id: run_examples
6457
env:
@@ -90,29 +83,67 @@ jobs:
9083
9184
# Run each example
9285
for example in $examples; do
93-
total=$((total + 1))
94-
echo "----------------------------------------"
95-
echo "📝 Running: $example"
96-
echo "----------------------------------------"
97-
98-
# Create a timeout wrapper to prevent hanging
99-
if timeout 1800 python "$example" > "${example}.log" 2>&1; then
100-
echo "✅ PASSED: $example" | tee -a $results_file
101-
passed=$((passed + 1))
86+
# For example 04, test both small and large datasets
87+
if [ "$example" = "04_csv_import_documents.py" ]; then
88+
for size in small large; do
89+
total=$((total + 1))
90+
example_name="$example (--size $size)"
91+
log_file="${example%.py}_${size}.log"
92+
93+
echo "----------------------------------------"
94+
echo "📝 Running: $example_name"
95+
echo "----------------------------------------"
96+
97+
# Create a timeout wrapper to prevent hanging (30 min for small, 60 min for large)
98+
if [ "$size" = "small" ]; then
99+
timeout_duration=1800
100+
else
101+
timeout_duration=3600
102+
fi
103+
104+
if timeout $timeout_duration python "$example" --size "$size" > "$log_file" 2>&1; then
105+
echo "✅ PASSED: $example_name" | tee -a $results_file
106+
passed=$((passed + 1))
107+
else
108+
exit_code=$?
109+
if [ $exit_code -eq 124 ]; then
110+
echo "⏱️ TIMEOUT: $example_name (exceeded $((timeout_duration/60)) minutes)" | tee -a $results_file
111+
failed=$((failed + 1))
112+
else
113+
echo "❌ FAILED: $example_name (exit code: $exit_code)" | tee -a $results_file
114+
failed=$((failed + 1))
115+
fi
116+
# Show last 20 lines of error log
117+
echo "Last 20 lines of output:"
118+
tail -n 20 "$log_file"
119+
fi
120+
echo ""
121+
done
102122
else
103-
exit_code=$?
104-
if [ $exit_code -eq 124 ]; then
105-
echo "⏱️ TIMEOUT: $example (exceeded 30 minutes)" | tee -a $results_file
106-
failed=$((failed + 1))
123+
total=$((total + 1))
124+
echo "----------------------------------------"
125+
echo "📝 Running: $example"
126+
echo "----------------------------------------"
127+
128+
# Create a timeout wrapper to prevent hanging
129+
if timeout 1800 python "$example" > "${example}.log" 2>&1; then
130+
echo "✅ PASSED: $example" | tee -a $results_file
131+
passed=$((passed + 1))
107132
else
108-
echo "❌ FAILED: $example (exit code: $exit_code)" | tee -a $results_file
109-
failed=$((failed + 1))
133+
exit_code=$?
134+
if [ $exit_code -eq 124 ]; then
135+
echo "⏱️ TIMEOUT: $example (exceeded 30 minutes)" | tee -a $results_file
136+
failed=$((failed + 1))
137+
else
138+
echo "❌ FAILED: $example (exit code: $exit_code)" | tee -a $results_file
139+
failed=$((failed + 1))
140+
fi
141+
# Show last 20 lines of error log
142+
echo "Last 20 lines of output:"
143+
tail -n 20 "${example}.log"
110144
fi
111-
# Show last 20 lines of error log
112-
echo "Last 20 lines of output:"
113-
tail -n 20 "${example}.log"
145+
echo ""
114146
fi
115-
echo ""
116147
done
117148
118149
# Print summary
@@ -185,12 +216,13 @@ jobs:
185216
echo "" >> $GITHUB_STEP_SUMMARY
186217
echo "### Examples Tested" >> $GITHUB_STEP_SUMMARY
187218
echo "" >> $GITHUB_STEP_SUMMARY
188-
echo "- 01_simple_document_store.py - Document CRUD operations" >> $GITHUB_STEP_SUMMARY
189-
echo "- 02_social_network_graph.py - Graph modeling and traversal" >> $GITHUB_STEP_SUMMARY
190-
echo "- 03_vector_search.py - Vector embeddings and similarity search" >> $GITHUB_STEP_SUMMARY
191-
echo "- 04_csv_import_documents.py - CSV data import with type inference" >> $GITHUB_STEP_SUMMARY
219+
echo "- **01_simple_document_store.py** - Document CRUD operations with comprehensive data types" >> $GITHUB_STEP_SUMMARY
220+
echo "- **02_social_network_graph.py** - Graph modeling with vertices, edges, and traversal" >> $GITHUB_STEP_SUMMARY
221+
echo "- **03_vector_search.py** - Vector embeddings and semantic similarity search (experimental)" >> $GITHUB_STEP_SUMMARY
222+
echo "- **04_csv_import_documents.py** - CSV import with automatic dataset download and type inference" >> $GITHUB_STEP_SUMMARY
223+
echo " - Tested with \`--size small\` (~1 MB, ~100K ratings, 30 min timeout)" >> $GITHUB_STEP_SUMMARY
224+
echo " - Tested with \`--size large\` (~265 MB, ~33M ratings, 60 min timeout)" >> $GITHUB_STEP_SUMMARY
192225
echo "" >> $GITHUB_STEP_SUMMARY
193-
echo "_Note: Example 04 requires the MovieLens dataset. If it fails, the dataset may need to be downloaded._" >> $GITHUB_STEP_SUMMARY
194226
195227
- name: Upload example logs
196228
if: always()

0 commit comments

Comments
 (0)