walidsobhie-code Claude Opus 4.6 commited on
Commit
57be99c
·
1 Parent(s): f90ca5c

fix: add retry logic for git clone

Browse files

- Retry up to 3 times on network failures
- Better error handling

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

Files changed (1) hide show
  1. colab_train_stack29.ipynb +1 -1
colab_train_stack29.ipynb CHANGED
@@ -30,7 +30,7 @@
30
  "execution_count": null,
31
  "metadata": {},
32
  "outputs": [],
33
- "source": "# STEP 2: Clone repo (fresh every time)\nimport shutil\n\nif os.path.exists('stack-2.9'):\n print(\"Removing old stack-2.9...\")\n shutil.rmtree('stack-2.9')\n\n!git clone https://github.com/my-ai-stack/stack-2.9.git\n\nos.chdir(REPO_DIR)\nprint(f\"✅ In: {os.getcwd()}\")\n!ls -la"
34
  },
35
  {
36
  "cell_type": "code",
 
30
  "execution_count": null,
31
  "metadata": {},
32
  "outputs": [],
33
+ "source": "# STEP 2: Clone repo (with retry logic)\nimport shutil\nimport time\n\nmax_retries = 3\nfor attempt in range(max_retries):\n try:\n if os.path.exists('stack-2.9'):\n print(f\"Attempt {attempt+1}: Removing old stack-2.9...\")\n shutil.rmtree('stack-2.9')\n \n print(f\"Attempt {attempt+1}: Cloning repository...\")\n result = !git clone https://github.com/my-ai-stack/stack-2.9.git\n \n if os.path.exists('stack-2.9'):\n print(\"✅ Clone successful!\")\n break\n except Exception as e:\n print(f\"⚠️ Attempt {attempt+1} failed: {e}\")\n if attempt < max_retries - 1:\n print(\"Retrying in 5 seconds...\")\n time.sleep(5)\nelse:\n raise RuntimeError(\"Failed to clone repository after 3 attempts\")\n\nos.chdir(REPO_DIR)\nprint(f\"✅ In: {os.getcwd()}\")\n!ls -la"
34
  },
35
  {
36
  "cell_type": "code",