|
48 | 48 | "from IPython.display import JSON\n",
|
49 | 49 | "\n",
|
50 | 50 | "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" |
52 | 53 | ]
|
53 | 54 | },
|
54 | 55 | {
|
|
92 | 93 | "cell_type": "markdown",
|
93 | 94 | "id": "98017416-3d3c-4225-843f-8f2fa35be36b",
|
94 | 95 | "metadata": {
|
95 |
| - "jp-MarkdownHeadingCollapsed": true, |
96 | 96 | "tags": []
|
97 | 97 | },
|
98 | 98 | "source": [
|
|
150 | 150 | "cell_type": "markdown",
|
151 | 151 | "id": "9e36a5fb-25ab-40ad-a9cb-ed2c06597cea",
|
152 | 152 | "metadata": {
|
153 |
| - "jp-MarkdownHeadingCollapsed": true, |
154 | 153 | "tags": []
|
155 | 154 | },
|
156 | 155 | "source": [
|
|
197 | 196 | "id": "9f1cdbbc-6c38-4c2a-955a-08ac8d13e366",
|
198 | 197 | "metadata": {},
|
199 | 198 | "source": [
|
200 |
| - "## 5. List processes\n", |
| 199 | + "## 5. Listing all deployed processes\n", |
201 | 200 | "\n",
|
202 | 201 | "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",
|
203 | 202 | "\n",
|
|
225 | 224 | "print(\"\\n\\nSelected Process:\\n\\n{}\".format(my_process))"
|
226 | 225 | ]
|
227 | 226 | },
|
| 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 | + }, |
228 | 248 | {
|
229 | 249 | "cell_type": "markdown",
|
230 | 250 | "id": "00fc3f8f-8d05-4765-92cb-99bc25778a02",
|
|
265 | 285 | "\n",
|
266 | 286 | " # Store Job ID to use in future steps\n",
|
267 | 287 | " job = my_process.execute(data)\n",
|
| 288 | + " print(job)\n", |
268 | 289 | "\n",
|
269 | 290 | " # If the job submission is successful, print a success message along with the returned JOB-ID\n",
|
270 | 291 | " print(\"\\nJob Submission Successful!\\nJOB ID: {}\\n\".format(job.id))\n",
|
271 |
| - " print(job)\n", |
272 | 292 | "\n",
|
273 | 293 | "except requests.exceptions.HTTPError as e:\n",
|
274 | 294 | " # An error has occurred, print the error message that was generated\n",
|
|
297 | 317 | "\n",
|
298 | 318 | " job_status = job.get_status()\n",
|
299 | 319 | " \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", |
302 | 322 | " time.sleep(5)\n",
|
303 | 323 | " job_status = job.get_status()\n",
|
304 | 324 | " \n",
|
305 | 325 | " # 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", |
307 | 327 | " \n",
|
308 | 328 | "except requests.exceptions.HTTPError as e:\n",
|
309 | 329 | " # An error has occurred, print the error message that was generated\n",
|
|
328 | 348 | "metadata": {},
|
329 | 349 | "outputs": [],
|
330 | 350 | "source": [
|
331 |
| - "# Set jobID here if you'd like\n", |
332 |
| - "#job_id = \"35284103-b7ce-4ea4-86d1-c0dd0622f898\"\n", |
333 |
| - "\n", |
334 | 351 | "try:\n",
|
335 | 352 | "\n",
|
336 | 353 | " job_data = job.get_result()\n",
|
337 | 354 | "\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", |
343 | 355 | "except requests.exceptions.HTTPError as e:\n",
|
344 | 356 | " print(e.reason)\n",
|
345 | 357 | "\n",
|
|
402 | 414 | "jobs = process_service.get_jobs(my_process)\n",
|
403 | 415 | "\n",
|
404 | 416 | "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)" |
409 | 418 | ]
|
410 |
| - }, |
411 |
| - { |
412 |
| - "cell_type": "code", |
413 |
| - "execution_count": null, |
414 |
| - "id": "6181c3d1-88b9-4bb3-be43-73fc5ad582c6", |
415 |
| - "metadata": {}, |
416 |
| - "outputs": [], |
417 |
| - "source": [] |
418 | 419 | }
|
419 | 420 | ],
|
420 | 421 | "metadata": {
|
|
0 commit comments