|
2 | 2 | "cells": [
|
3 | 3 | {
|
4 | 4 | "cell_type": "code",
|
5 |
| - "execution_count": null, |
| 5 | + "execution_count": 1, |
6 | 6 | "id": "a814e91b-3afe-4c28-a3d6-fe087c7af552",
|
7 | 7 | "metadata": {},
|
8 | 8 | "outputs": [],
|
|
13 | 13 | },
|
14 | 14 | {
|
15 | 15 | "cell_type": "code",
|
16 |
| - "execution_count": 16, |
| 16 | + "execution_count": 2, |
17 | 17 | "id": "1e26faef-9e2e-4793-b8af-0e18470b482d",
|
18 | 18 | "metadata": {},
|
19 |
| - "outputs": [ |
20 |
| - { |
21 |
| - "name": "stdout", |
22 |
| - "output_type": "stream", |
23 |
| - "text": [ |
24 |
| - "google-maps-restaurant-reviews.zip: Skipping, found more recently modified local copy (use --force to force download)\n", |
25 |
| - "Archive: /home/jovyan/data/google-maps-restaurant-reviews.zip\n", |
26 |
| - " inflating: /persist-data/google-maps-restaurant-reviews/reviews.csv \n", |
27 |
| - " inflating: /persist-data/google-maps-restaurant-reviews/sepetcioglu_restaurant.csv \n" |
28 |
| - ] |
29 |
| - } |
30 |
| - ], |
| 19 | + "outputs": [], |
31 | 20 | "source": [
|
32 | 21 | "import os\n",
|
33 | 22 | "# navigate to https://www.kaggle.com/settings/account and generate an API token to be used to setup the env variable. See https://www.kaggle.com/docs/api#authentication how to create one.\n",
|
|
42 | 31 | },
|
43 | 32 | {
|
44 | 33 | "cell_type": "code",
|
45 |
| - "execution_count": 17, |
| 34 | + "execution_count": 3, |
46 | 35 | "id": "050f2c66-b92e-4ca6-a3b7-b7448d066f8e",
|
47 | 36 | "metadata": {},
|
48 | 37 | "outputs": [],
|
|
53 | 42 | },
|
54 | 43 | {
|
55 | 44 | "cell_type": "code",
|
56 |
| - "execution_count": 20, |
| 45 | + "execution_count": 4, |
57 | 46 | "id": "c82cdcad-c74c-4196-9aa0-2e6bb49f4b58",
|
58 | 47 | "metadata": {},
|
59 |
| - "outputs": [ |
60 |
| - { |
61 |
| - "name": "stdout", |
62 |
| - "output_type": "stream", |
63 |
| - "text": [ |
64 |
| - "Overwriting test/test.py\n" |
65 |
| - ] |
66 |
| - } |
67 |
| - ], |
| 48 | + "outputs": [], |
68 | 49 | "source": [
|
69 | 50 | "%%writefile test/test.py\n",
|
70 | 51 | "# Comment out the above line if you want to see notebook print out, but the line is required for the actual ray job (the test.py is downloaded by the ray workers)\n",
|
|
255 | 236 | },
|
256 | 237 | {
|
257 | 238 | "cell_type": "code",
|
258 |
| - "execution_count": 21, |
| 239 | + "execution_count": 5, |
259 | 240 | "id": "aeeb7b7a-23d8-4c6a-8165-7ce5516d2a41",
|
260 | 241 | "metadata": {},
|
261 | 242 | "outputs": [],
|
262 | 243 | "source": [
|
263 |
| - "import ray\n", |
| 244 | + "import ray, time\n", |
264 | 245 | "from ray.job_submission import JobSubmissionClient\n",
|
265 | 246 | "client = JobSubmissionClient(\"ray://example-cluster-kuberay-head-svc:10001\")"
|
266 | 247 | ]
|
267 | 248 | },
|
268 | 249 | {
|
269 | 250 | "cell_type": "code",
|
270 |
| - "execution_count": 22, |
271 |
| - "id": "4f9f7495-b239-44e0-a96c-356ac5d48b3a", |
| 251 | + "execution_count": 6, |
| 252 | + "id": "7ba6c3ff-a25a-4f4d-b58e-68f7fe7d33df", |
272 | 253 | "metadata": {},
|
273 |
| - "outputs": [ |
274 |
| - { |
275 |
| - "name": "stderr", |
276 |
| - "output_type": "stream", |
277 |
| - "text": [ |
278 |
| - "2024-02-12 21:28:25,605\tINFO dashboard_sdk.py:338 -- Uploading package gcs://_ray_pkg_6cb7c74b99fef592.zip.\n", |
279 |
| - "2024-02-12 21:28:25,606\tINFO packaging.py:518 -- Creating a file package for local directory '/home/jovyan/test'.\n" |
280 |
| - ] |
281 |
| - }, |
282 |
| - { |
283 |
| - "name": "stdout", |
284 |
| - "output_type": "stream", |
285 |
| - "text": [ |
286 |
| - "jobid: raysubmit_8cQxrAChfX9BYKUW\n" |
287 |
| - ] |
288 |
| - } |
289 |
| - ], |
| 254 | + "outputs": [], |
290 | 255 | "source": [
|
291 | 256 | "job_id = client.submit_job(\n",
|
292 | 257 | " entrypoint=\"python test.py\",\n",
|
|
303 | 268 | " \"cloud-sql-python-connector[pg8000]==1.7.0\",\n",
|
304 | 269 | " \"SQLAlchemy==2.0.7\",\n",
|
305 | 270 | " \"huggingface_hub\",\n",
|
306 |
| - " ]\n", |
| 271 | + " ]\n", |
307 | 272 | " }\n",
|
308 | 273 | ")\n",
|
309 |
| - "print(\"jobid:\", job_id)" |
310 |
| - ] |
311 |
| - }, |
312 |
| - { |
313 |
| - "cell_type": "code", |
314 |
| - "execution_count": 23, |
315 |
| - "id": "2724d3a4-7613-4d98-951b-991419208d45", |
316 |
| - "metadata": {}, |
317 |
| - "outputs": [ |
318 |
| - { |
319 |
| - "name": "stdout", |
320 |
| - "output_type": "stream", |
321 |
| - "text": [ |
322 |
| - "Job submission server address: http://10.48.2.6:8265\n", |
323 |
| - "Status for job 'raysubmit_8cQxrAChfX9BYKUW': RUNNING\n", |
324 |
| - "Status message: Job is currently running.\n", |
325 |
| - "\u001b[0m" |
326 |
| - ] |
327 |
| - } |
328 |
| - ], |
329 |
| - "source": [ |
330 |
| - "!ray job status {job_id} --address \"ray://example-cluster-kuberay-head-svc:10001\" " |
| 274 | + "\n", |
| 275 | + "print(\"Job submitted with ID:\", job_id)\n", |
| 276 | + "prev_status = \"\"\n", |
| 277 | + "while True:\n", |
| 278 | + " status = client.get_job_status(job_id)\n", |
| 279 | + " if status != prev_status:\n", |
| 280 | + " print(\"Job status:\", status)\n", |
| 281 | + " prev_status = status\n", |
| 282 | + " if status.is_terminal():\n", |
| 283 | + " if status == 'FAILED':\n", |
| 284 | + " print(\"Job info:\", client.get_job_info(job_id))\n", |
| 285 | + " break\n", |
| 286 | + " time.sleep(5)\n" |
331 | 287 | ]
|
332 |
| - }, |
333 |
| - { |
334 |
| - "cell_type": "code", |
335 |
| - "execution_count": null, |
336 |
| - "id": "9c5c68f3-14d4-4ecf-afbd-c8f5c742618e", |
337 |
| - "metadata": {}, |
338 |
| - "outputs": [], |
339 |
| - "source": [] |
340 | 288 | }
|
341 | 289 | ],
|
342 | 290 | "metadata": {
|
|
0 commit comments