RyZ commited on
Commit ·
aa0e77f
1
Parent(s): a2d73c6
feat: upgrade kaggle bootstrap notebook with gpu checks, secrets verification, and all dependencies installation
Browse files
scripts/build_kaggle_deploy.py
CHANGED
|
@@ -27,26 +27,51 @@ def build_deploy_dir():
|
|
| 27 |
"metadata": {},
|
| 28 |
"outputs": [],
|
| 29 |
"source": [
|
| 30 |
-
"
|
|
|
|
| 31 |
"import sys\n",
|
| 32 |
"import os\n",
|
| 33 |
"\n",
|
| 34 |
-
"print(\"===
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 35 |
"try:\n",
|
| 36 |
-
"
|
| 37 |
-
" subprocess.check_call([sys.executable, \"-m\", \"pip\", \"install\", \"-e\", \".\"])\n",
|
| 38 |
-
" print(\"
|
| 39 |
"except Exception as e:\n",
|
| 40 |
-
" print(f\"Error installing dependencies: {e}\")\n",
|
| 41 |
" sys.exit(1)\n",
|
| 42 |
"\n",
|
|
|
|
|
|
|
| 43 |
"try:\n",
|
| 44 |
-
" print(\"Launching message consumer...\")\n",
|
| 45 |
" subprocess.check_call([sys.executable, \"-m\", \"src.interface.consumer.run_consumer\"])\n",
|
| 46 |
"except KeyboardInterrupt:\n",
|
| 47 |
-
" print(\"Consumer stopped
|
| 48 |
"except Exception as e:\n",
|
| 49 |
-
" print(f\"Consumer
|
| 50 |
" sys.exit(1)"
|
| 51 |
]
|
| 52 |
}
|
|
|
|
| 27 |
"metadata": {},
|
| 28 |
"outputs": [],
|
| 29 |
"source": [
|
| 30 |
+
"# 1. System/GPU Information Check\n",
|
| 31 |
+
"import torch\n",
|
| 32 |
"import sys\n",
|
| 33 |
"import os\n",
|
| 34 |
"\n",
|
| 35 |
+
"print(\"=== Kaggle GPU & System Check ===\")\n",
|
| 36 |
+
"print(f\"Python Version: {sys.version}\")\n",
|
| 37 |
+
"print(f\"PyTorch Version: {torch.__version__}\")\n",
|
| 38 |
+
"print(f\"CUDA Available: {torch.cuda.is_available()}\")\n",
|
| 39 |
+
"if torch.cuda.is_available():\n",
|
| 40 |
+
" print(f\"GPU Device: {torch.cuda.get_device_name(0)}\")\n",
|
| 41 |
+
"else:\n",
|
| 42 |
+
" print(\"WARNING: GPU is not active. Please enable GPU in the Kaggle settings for optimal performance.\")\n",
|
| 43 |
+
"\n",
|
| 44 |
+
"# 2. Check Kaggle secrets\n",
|
| 45 |
+
"print(\"\\n=== Kaggle Secrets Validation ===\")\n",
|
| 46 |
+
"try:\n",
|
| 47 |
+
" from kaggle_secrets import UserSecretsClient\n",
|
| 48 |
+
" user_secrets = UserSecretsClient()\n",
|
| 49 |
+
" db_url = user_secrets.get_secret(\"DATABASE_URL\")\n",
|
| 50 |
+
" rabbitmq_url = user_secrets.get_secret(\"RABBITMQ_URL\")\n",
|
| 51 |
+
" print(f\"DATABASE_URL secret: {'FOUND' if db_url else 'MISSING'}\")\n",
|
| 52 |
+
" print(f\"RABBITMQ_URL secret: {'FOUND' if rabbitmq_url else 'MISSING'}\")\n",
|
| 53 |
+
"except Exception as e:\n",
|
| 54 |
+
" print(f\"Warning: Could not check secrets: {e}\")\n",
|
| 55 |
+
"\n",
|
| 56 |
+
"# 3. Install Package dependencies\n",
|
| 57 |
+
"print(\"\\n=== Installing Clean Architecture Package ===\")\n",
|
| 58 |
+
"import subprocess\n",
|
| 59 |
"try:\n",
|
| 60 |
+
" # Installs the local code in editable mode with all optional dependencies\n",
|
| 61 |
+
" subprocess.check_call([sys.executable, \"-m\", \"pip\", \"install\", \"-e\", \".[all]\"])\n",
|
| 62 |
+
" print(\"Package & dependencies installed successfully.\")\n",
|
| 63 |
"except Exception as e:\n",
|
| 64 |
+
" print(f\"Error installing package dependencies: {e}\")\n",
|
| 65 |
" sys.exit(1)\n",
|
| 66 |
"\n",
|
| 67 |
+
"# 4. Start the Message Consumer\n",
|
| 68 |
+
"print(\"\\n=== Launching Consumer Daemon ===\")\n",
|
| 69 |
"try:\n",
|
|
|
|
| 70 |
" subprocess.check_call([sys.executable, \"-m\", \"src.interface.consumer.run_consumer\"])\n",
|
| 71 |
"except KeyboardInterrupt:\n",
|
| 72 |
+
" print(\"Consumer stopped.\")\n",
|
| 73 |
"except Exception as e:\n",
|
| 74 |
+
" print(f\"Consumer failed to execute: {e}\")\n",
|
| 75 |
" sys.exit(1)"
|
| 76 |
]
|
| 77 |
}
|