Skip to content

Commit ab05264

Browse files
committed
Updated working with jobs notebook to integrate the use of unity-py.
1 parent d949655 commit ab05264

File tree

1 file changed

+29
-28
lines changed

1 file changed

+29
-28
lines changed

jupyter-notebooks/tutorials/3_working_with_jobs.ipynb

Lines changed: 29 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,8 @@
4848
"from IPython.display import JSON\n",
4949
"\n",
5050
"from unity_py.unity import Unity\n",
51-
"from unity_py.unity_services import UnityServices"
51+
"from unity_py.unity_services import UnityServices\n",
52+
"from unity_py.resources.job_status import JobStatus"
5253
]
5354
},
5455
{
@@ -92,7 +93,6 @@
9293
"cell_type": "markdown",
9394
"id": "98017416-3d3c-4225-843f-8f2fa35be36b",
9495
"metadata": {
95-
"jp-MarkdownHeadingCollapsed": true,
9696
"tags": []
9797
},
9898
"source": [
@@ -150,7 +150,6 @@
150150
"cell_type": "markdown",
151151
"id": "9e36a5fb-25ab-40ad-a9cb-ed2c06597cea",
152152
"metadata": {
153-
"jp-MarkdownHeadingCollapsed": true,
154153
"tags": []
155154
},
156155
"source": [
@@ -197,7 +196,7 @@
197196
"id": "9f1cdbbc-6c38-4c2a-955a-08ac8d13e366",
198197
"metadata": {},
199198
"source": [
200-
"## 5. List processes\n",
199+
"## 5. Listing all deployed processes\n",
201200
"\n",
202201
"The Unity-Py client provides the ability to view all deployed application packages (a.k.a., Processes) on the system using the `get_processes` function. After a successful deployment of an application package to SPS, you should see a new entry for the deployed application.\n",
203202
"\n",
@@ -225,6 +224,27 @@
225224
"print(\"\\n\\nSelected Process:\\n\\n{}\".format(my_process))"
226225
]
227226
},
227+
{
228+
"cell_type": "markdown",
229+
"id": "51426e28-3fa9-41fd-bc52-eca7053c24e7",
230+
"metadata": {},
231+
"source": [
232+
"### Retrieve a deployed process's information\n",
233+
"\n",
234+
"If you know the ID of the process, the process information can be retrieved using the `get_process(id)` method of `ProcessService`.\n"
235+
]
236+
},
237+
{
238+
"cell_type": "code",
239+
"execution_count": null,
240+
"id": "9f2c9ea5-2691-4e4a-bc00-0b682b6a41fd",
241+
"metadata": {},
242+
"outputs": [],
243+
"source": [
244+
"process = process_service.get_process('l1b-cwl:develop')\n",
245+
"print(process)"
246+
]
247+
},
228248
{
229249
"cell_type": "markdown",
230250
"id": "00fc3f8f-8d05-4765-92cb-99bc25778a02",
@@ -265,10 +285,10 @@
265285
"\n",
266286
" # Store Job ID to use in future steps\n",
267287
" job = my_process.execute(data)\n",
288+
" print(job)\n",
268289
"\n",
269290
" # If the job submission is successful, print a success message along with the returned JOB-ID\n",
270291
" print(\"\\nJob Submission Successful!\\nJOB ID: {}\\n\".format(job.id))\n",
271-
" print(job)\n",
272292
"\n",
273293
"except requests.exceptions.HTTPError as e:\n",
274294
" # An error has occurred, print the error message that was generated\n",
@@ -297,13 +317,13 @@
297317
"\n",
298318
" job_status = job.get_status()\n",
299319
" \n",
300-
" while job_status == \"running\":\n",
301-
" print(\"Status for job \\\"{}\\\" ({}): {}\".format(job.id, datetime.now().strftime(\"%H:%M:%S\"), job_status))\n",
320+
" while job_status == JobStatus.RUNNING:\n",
321+
" print(\"Status for job \\\"{}\\\" ({}): {}\".format(job.id, datetime.now().strftime(\"%H:%M:%S\"), job_status.value))\n",
302322
" time.sleep(5)\n",
303323
" job_status = job.get_status()\n",
304324
" \n",
305325
" # Print the job status\n",
306-
" print(\"\\nStatus for job \\\"{}\\\" ({}): {}\\n\".format(job.id, datetime.now().strftime(\"%H:%M:%S\"),job_status))\n",
326+
" print(\"\\nStatus for job \\\"{}\\\" ({}): {}\\n\".format(job.id, datetime.now().strftime(\"%H:%M:%S\"),job_status.value))\n",
307327
" \n",
308328
"except requests.exceptions.HTTPError as e:\n",
309329
" # An error has occurred, print the error message that was generated\n",
@@ -328,18 +348,10 @@
328348
"metadata": {},
329349
"outputs": [],
330350
"source": [
331-
"# Set jobID here if you'd like\n",
332-
"#job_id = \"35284103-b7ce-4ea4-86d1-c0dd0622f898\"\n",
333-
"\n",
334351
"try:\n",
335352
"\n",
336353
" job_data = job.get_result()\n",
337354
"\n",
338-
" #for data in job_data:\n",
339-
" # print(\"ID: \" + data['id'])\n",
340-
" # print(\"Type: \" + data['mimeType'])\n",
341-
" # print(\"Location: \" + data['href'])\n",
342-
" \n",
343355
"except requests.exceptions.HTTPError as e:\n",
344356
" print(e.reason)\n",
345357
"\n",
@@ -402,19 +414,8 @@
402414
"jobs = process_service.get_jobs(my_process)\n",
403415
"\n",
404416
"for job in jobs:\n",
405-
" print(\"{}/{}\".format(job.id, job.status))\n",
406-
" \n",
407-
"print(\"\\n\\nFull JSON output data of get_jobs_for_app\")\n",
408-
"JSON(jobs)"
417+
" print(job)"
409418
]
410-
},
411-
{
412-
"cell_type": "code",
413-
"execution_count": null,
414-
"id": "6181c3d1-88b9-4bb3-be43-73fc5ad582c6",
415-
"metadata": {},
416-
"outputs": [],
417-
"source": []
418419
}
419420
],
420421
"metadata": {

0 commit comments

Comments
 (0)