Skip to content

Commit a5bae62

Browse files
committed
Increase timeouts
1 parent 76e305a commit a5bae62

File tree

2 files changed

+15
-4
lines changed

2 files changed

+15
-4
lines changed

.github/workflows/translate.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ on:
1111
jobs:
1212
translate:
1313
runs-on: ubuntu-latest
14+
timeout-minutes: 120
1415

1516
permissions:
1617
contents: write # Required to push translations
@@ -118,3 +119,11 @@ jobs:
118119
else
119120
echo "ℹ️ No translation changes needed" >> $GITHUB_STEP_SUMMARY
120121
fi
122+
123+
# Add translation stats if available
124+
if [ -n "${{ steps.translate.outputs.translation_success }}" ]; then
125+
echo "" >> $GITHUB_STEP_SUMMARY
126+
echo "**Translation Stats:**" >> $GITHUB_STEP_SUMMARY
127+
echo "- ✅ Succeeded: ${{ steps.translate.outputs.translation_success }}" >> $GITHUB_STEP_SUMMARY
128+
echo "- ⚠️ Failed: ${{ steps.translate.outputs.translation_failed }}" >> $GITHUB_STEP_SUMMARY
129+
fi

translate.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,9 @@
2121
"api": {
2222
"provider": "openai",
2323
"model": "gpt-4o-mini",
24-
"timeout": 60,
25-
"max_retries": 3
24+
"timeout": 180,
25+
"max_retries": 3,
26+
"retry_delay": 5
2627
},
2728
"translation": {
2829
"source_language": "en",
@@ -83,7 +84,8 @@ def translate_with_openai(content, target_lang, source_lang="en"):
8384
Translated document in {target_lang_name}:"""
8485

8586
max_retries = api_config.get("max_retries", 3)
86-
timeout = api_config.get("timeout", 60)
87+
timeout = api_config.get("timeout", 180)
88+
retry_delay = api_config.get("retry_delay", 5)
8789

8890
for attempt in range(max_retries):
8991
try:
@@ -113,7 +115,7 @@ def translate_with_openai(content, target_lang, source_lang="en"):
113115

114116
except Exception as e:
115117
if attempt < max_retries - 1:
116-
wait_time = 2 ** attempt
118+
wait_time = retry_delay * (2 ** attempt) # Exponential backoff
117119
print(f" Retry {attempt + 1}/{max_retries} after error: {e}")
118120
time.sleep(wait_time)
119121
else:

0 commit comments

Comments
 (0)