From 045b1266a4bb41404aa0bf899e32367584c5e7aa Mon Sep 17 00:00:00 2001 From: Nikki <17799906+nikki-t@users.noreply.github.com> Date: Tue, 1 Jul 2025 13:06:20 -0400 Subject: [PATCH 1/2] Update notebook for Cognito authentication and OGC API update method --- libs/unity-py/notebooks/ogc_notebook.ipynb | 466 ++++++++------------- 1 file changed, 169 insertions(+), 297 deletions(-) diff --git a/libs/unity-py/notebooks/ogc_notebook.ipynb b/libs/unity-py/notebooks/ogc_notebook.ipynb index 0e7f71c0..4b9ead3e 100644 --- a/libs/unity-py/notebooks/ogc_notebook.ipynb +++ b/libs/unity-py/notebooks/ogc_notebook.ipynb @@ -22,7 +22,7 @@ "- This notebook uses the [Unity-Py](https://github.com/unity-sds/unity-monorepo/tree/main/libs/unity-py) library to interact with the OGC API\n", "- Unity environment (e.g., DEV, TEST, PROD) and venue (e.g., unity-sbg-dev, unity-emit-dev, unity-asips-int) names. See [this documentation](https://unity-sds.gitbook.io/docs/system-docs/architecture/deployments-projects-and-venues/unity-owned-venues) for guidance\n", "- Unity username and password\n", - "- A URL for the OGC API processes endpoint, something like: `https://unity-dev-httpd-alb-XXXXXXXXXX.us-west-2.elb.amazonaws.com:1234/unity/dev/ogc/`\n", + "- A URL for the OGC API processes endpoint, something like: `https://xxxxx.execute-api.us-west-2.amazonaws.com/dev/ogc/api/`\n", "\n", "## Learning Objectives\n", "\n", @@ -36,7 +36,7 @@ }, { "cell_type": "code", - "execution_count": 1, + "execution_count": null, "id": "700eddd2-77af-4849-8343-3f0fef34ff73", "metadata": { "is_executing": true @@ -44,6 +44,7 @@ "outputs": [], "source": [ "from datetime import datetime\n", + "import json\n", "import time\n", "\n", "from IPython.display import JSON\n", @@ -69,19 +70,10 @@ }, { "cell_type": "code", - "execution_count": 2, - "id": "4029cee7-9c5b-4ac1-bd54-45fb45be9397", + "execution_count": null, + "id": "9c1fad3d-7481-4c2e-bda0-14bf2e1b287a", "metadata": {}, - "outputs": [ - { - "name": "stdin", - "output_type": "stream", - "text": [ - "Please enter your Unity username: tebaldi\n", - "Please enter your Unity password: ········\n" - ] - } - ], + "outputs": [], "source": [ "# Point Unity-Py to DEV environment for testing and development work\n", "unity = Unity(UnityEnvironments.DEV) # Enter Unity username and password" @@ -112,25 +104,10 @@ }, { "cell_type": "code", - "execution_count": 4, + "execution_count": null, "id": "865f0b16-c954-45a9-984a-953be93749a3", "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "cwl_dag details: unity_sds_client.resources.Process(\n", - " id=\"cwl_dag\",\n", - " process_version=\"1.0.0\"\n", - " title=\"Generic CWL Process\",\n", - " abstract=\"This process executes any CWL workflow.\",\n", - " keywords=\"None\"\n", - ")\n", - "\n" - ] - } - ], + "outputs": [], "source": [ "# Retrieve all processes that have been registered at the OGC Processes API endpoint\n", "processes = process_service.get_processes()\n", @@ -144,24 +121,10 @@ }, { "cell_type": "code", - "execution_count": 5, + "execution_count": null, "id": "399a8c39-a69b-49a8-b9b1-03de6b3bc62f", "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "unity_sds_client.resources.Process(\n", - " id=\"cwl_dag\",\n", - " process_version=\"1.0.0\"\n", - " title=\"Generic CWL Process\",\n", - " abstract=\"This process executes any CWL workflow.\",\n", - " keywords=\"None\"\n", - ")\n" - ] - } - ], + "outputs": [], "source": [ "# Retrieve a specific DAG that you would like to execute a job for\n", "process = process_service.get_process(\"cwl_dag\")\n", @@ -180,23 +143,10 @@ }, { "cell_type": "code", - "execution_count": 6, + "execution_count": null, "id": "f08adb26-822e-4e01-8ec1-fbb4eb58bd26", "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "unity_sds_client.resources.Job(\n", - " id=\"22ccd35f-fd72-4ffd-acbb-3de9c4424b69\",\n", - " process=\"cwl_dag\",\n", - " status=\"accepted\",\n", - " inputs=None\n", - ")\n" - ] - } - ], + "outputs": [], "source": [ "# Set the necessary workflow inputs\n", "data = {\n", @@ -227,164 +177,12 @@ }, { "cell_type": "code", - "execution_count": 7, + "execution_count": null, "id": "a18a5727-750c-4307-b77c-7389d4ccc0f4", "metadata": { "scrolled": true }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Job 22ccd35f-fd72-4ffd-acbb-3de9c4424b69 is not complete; Currently in state: JobStatus.RUNNING\n", - "Job 22ccd35f-fd72-4ffd-acbb-3de9c4424b69 is not complete; Currently in state: JobStatus.RUNNING\n", - "Job 22ccd35f-fd72-4ffd-acbb-3de9c4424b69 is not complete; Currently in state: JobStatus.RUNNING\n", - "Job 22ccd35f-fd72-4ffd-acbb-3de9c4424b69 is not complete; Currently in state: JobStatus.RUNNING\n", - "Job 22ccd35f-fd72-4ffd-acbb-3de9c4424b69 is not complete; Currently in state: JobStatus.RUNNING\n", - "Job 22ccd35f-fd72-4ffd-acbb-3de9c4424b69 is not complete; Currently in state: JobStatus.RUNNING\n", - "Job 22ccd35f-fd72-4ffd-acbb-3de9c4424b69 is not complete; Currently in state: JobStatus.RUNNING\n", - "Job 22ccd35f-fd72-4ffd-acbb-3de9c4424b69 is not complete; Currently in state: JobStatus.RUNNING\n", - "Job 22ccd35f-fd72-4ffd-acbb-3de9c4424b69 is not complete; Currently in state: JobStatus.RUNNING\n", - "Job 22ccd35f-fd72-4ffd-acbb-3de9c4424b69 is not complete; Currently in state: JobStatus.RUNNING\n", - "Job 22ccd35f-fd72-4ffd-acbb-3de9c4424b69 is not complete; Currently in state: JobStatus.RUNNING\n", - "Job 22ccd35f-fd72-4ffd-acbb-3de9c4424b69 is not complete; Currently in state: JobStatus.RUNNING\n", - "Job 22ccd35f-fd72-4ffd-acbb-3de9c4424b69 is not complete; Currently in state: JobStatus.RUNNING\n", - "Job 22ccd35f-fd72-4ffd-acbb-3de9c4424b69 is not complete; Currently in state: JobStatus.RUNNING\n", - "Job 22ccd35f-fd72-4ffd-acbb-3de9c4424b69 is not complete; Currently in state: JobStatus.RUNNING\n", - "Job 22ccd35f-fd72-4ffd-acbb-3de9c4424b69 is not complete; Currently in state: JobStatus.RUNNING\n", - "Job 22ccd35f-fd72-4ffd-acbb-3de9c4424b69 is not complete; Currently in state: JobStatus.RUNNING\n", - "Job 22ccd35f-fd72-4ffd-acbb-3de9c4424b69 is not complete; Currently in state: JobStatus.RUNNING\n", - "Job 22ccd35f-fd72-4ffd-acbb-3de9c4424b69 is not complete; Currently in state: JobStatus.RUNNING\n", - "Job 22ccd35f-fd72-4ffd-acbb-3de9c4424b69 is not complete; Currently in state: JobStatus.RUNNING\n", - "Job 22ccd35f-fd72-4ffd-acbb-3de9c4424b69 is not complete; Currently in state: JobStatus.RUNNING\n", - "Job 22ccd35f-fd72-4ffd-acbb-3de9c4424b69 is not complete; Currently in state: JobStatus.RUNNING\n", - "Job 22ccd35f-fd72-4ffd-acbb-3de9c4424b69 is not complete; Currently in state: JobStatus.RUNNING\n", - "Job 22ccd35f-fd72-4ffd-acbb-3de9c4424b69 is not complete; Currently in state: JobStatus.RUNNING\n", - "Job 22ccd35f-fd72-4ffd-acbb-3de9c4424b69 is not complete; Currently in state: JobStatus.RUNNING\n", - "Job 22ccd35f-fd72-4ffd-acbb-3de9c4424b69 is not complete; Currently in state: JobStatus.RUNNING\n", - "Job 22ccd35f-fd72-4ffd-acbb-3de9c4424b69 is not complete; Currently in state: JobStatus.RUNNING\n", - "Job 22ccd35f-fd72-4ffd-acbb-3de9c4424b69 is not complete; Currently in state: JobStatus.RUNNING\n", - "Job 22ccd35f-fd72-4ffd-acbb-3de9c4424b69 is not complete; Currently in state: JobStatus.RUNNING\n", - "Job 22ccd35f-fd72-4ffd-acbb-3de9c4424b69 is not complete; Currently in state: JobStatus.RUNNING\n", - "Job 22ccd35f-fd72-4ffd-acbb-3de9c4424b69 is not complete; Currently in state: JobStatus.RUNNING\n", - "Job 22ccd35f-fd72-4ffd-acbb-3de9c4424b69 is not complete; Currently in state: JobStatus.RUNNING\n", - "Job 22ccd35f-fd72-4ffd-acbb-3de9c4424b69 is not complete; Currently in state: JobStatus.RUNNING\n", - "Job 22ccd35f-fd72-4ffd-acbb-3de9c4424b69 is not complete; Currently in state: JobStatus.RUNNING\n", - "Job 22ccd35f-fd72-4ffd-acbb-3de9c4424b69 is not complete; Currently in state: JobStatus.RUNNING\n", - "Job 22ccd35f-fd72-4ffd-acbb-3de9c4424b69 is not complete; Currently in state: JobStatus.RUNNING\n", - "Job 22ccd35f-fd72-4ffd-acbb-3de9c4424b69 is not complete; Currently in state: JobStatus.RUNNING\n", - "Job 22ccd35f-fd72-4ffd-acbb-3de9c4424b69 is not complete; Currently in state: JobStatus.RUNNING\n", - "Job 22ccd35f-fd72-4ffd-acbb-3de9c4424b69 is not complete; Currently in state: JobStatus.RUNNING\n", - "Job 22ccd35f-fd72-4ffd-acbb-3de9c4424b69 is not complete; Currently in state: JobStatus.RUNNING\n", - "Job 22ccd35f-fd72-4ffd-acbb-3de9c4424b69 is not complete; Currently in state: JobStatus.RUNNING\n", - "Job 22ccd35f-fd72-4ffd-acbb-3de9c4424b69 is not complete; Currently in state: JobStatus.RUNNING\n", - "Job 22ccd35f-fd72-4ffd-acbb-3de9c4424b69 is not complete; Currently in state: JobStatus.RUNNING\n", - "Job 22ccd35f-fd72-4ffd-acbb-3de9c4424b69 is not complete; Currently in state: JobStatus.RUNNING\n", - "Job 22ccd35f-fd72-4ffd-acbb-3de9c4424b69 is not complete; Currently in state: JobStatus.RUNNING\n", - "Job 22ccd35f-fd72-4ffd-acbb-3de9c4424b69 is not complete; Currently in state: JobStatus.RUNNING\n", - "Job 22ccd35f-fd72-4ffd-acbb-3de9c4424b69 is not complete; Currently in state: JobStatus.RUNNING\n", - "Job 22ccd35f-fd72-4ffd-acbb-3de9c4424b69 is not complete; Currently in state: JobStatus.RUNNING\n", - "Job 22ccd35f-fd72-4ffd-acbb-3de9c4424b69 is not complete; Currently in state: JobStatus.RUNNING\n", - "Job 22ccd35f-fd72-4ffd-acbb-3de9c4424b69 is not complete; Currently in state: JobStatus.RUNNING\n", - "Job 22ccd35f-fd72-4ffd-acbb-3de9c4424b69 is not complete; Currently in state: JobStatus.RUNNING\n", - "Job 22ccd35f-fd72-4ffd-acbb-3de9c4424b69 is not complete; Currently in state: JobStatus.RUNNING\n", - "Job 22ccd35f-fd72-4ffd-acbb-3de9c4424b69 is not complete; Currently in state: JobStatus.RUNNING\n", - "Job 22ccd35f-fd72-4ffd-acbb-3de9c4424b69 is not complete; Currently in state: JobStatus.RUNNING\n", - "Job 22ccd35f-fd72-4ffd-acbb-3de9c4424b69 is not complete; Currently in state: JobStatus.RUNNING\n", - "Job 22ccd35f-fd72-4ffd-acbb-3de9c4424b69 is not complete; Currently in state: JobStatus.RUNNING\n", - "Job 22ccd35f-fd72-4ffd-acbb-3de9c4424b69 is not complete; Currently in state: JobStatus.RUNNING\n", - "Job 22ccd35f-fd72-4ffd-acbb-3de9c4424b69 is not complete; Currently in state: JobStatus.RUNNING\n", - "Job 22ccd35f-fd72-4ffd-acbb-3de9c4424b69 is not complete; Currently in state: JobStatus.RUNNING\n", - "Job 22ccd35f-fd72-4ffd-acbb-3de9c4424b69 is not complete; Currently in state: JobStatus.RUNNING\n", - "Job 22ccd35f-fd72-4ffd-acbb-3de9c4424b69 is not complete; Currently in state: JobStatus.RUNNING\n", - "Job 22ccd35f-fd72-4ffd-acbb-3de9c4424b69 is not complete; Currently in state: JobStatus.RUNNING\n", - "Job 22ccd35f-fd72-4ffd-acbb-3de9c4424b69 is not complete; Currently in state: JobStatus.RUNNING\n", - "Job 22ccd35f-fd72-4ffd-acbb-3de9c4424b69 is not complete; Currently in state: JobStatus.RUNNING\n", - "Job 22ccd35f-fd72-4ffd-acbb-3de9c4424b69 is not complete; Currently in state: JobStatus.RUNNING\n", - "Job 22ccd35f-fd72-4ffd-acbb-3de9c4424b69 is not complete; Currently in state: JobStatus.RUNNING\n", - "Job 22ccd35f-fd72-4ffd-acbb-3de9c4424b69 is not complete; Currently in state: JobStatus.RUNNING\n", - "Job 22ccd35f-fd72-4ffd-acbb-3de9c4424b69 is not complete; Currently in state: JobStatus.RUNNING\n", - "Job 22ccd35f-fd72-4ffd-acbb-3de9c4424b69 is not complete; Currently in state: JobStatus.RUNNING\n", - "Job 22ccd35f-fd72-4ffd-acbb-3de9c4424b69 is not complete; Currently in state: JobStatus.RUNNING\n", - "Job 22ccd35f-fd72-4ffd-acbb-3de9c4424b69 is not complete; Currently in state: JobStatus.RUNNING\n", - "Job 22ccd35f-fd72-4ffd-acbb-3de9c4424b69 is not complete; Currently in state: JobStatus.RUNNING\n", - "Job 22ccd35f-fd72-4ffd-acbb-3de9c4424b69 is not complete; Currently in state: JobStatus.RUNNING\n", - "Job 22ccd35f-fd72-4ffd-acbb-3de9c4424b69 is not complete; Currently in state: JobStatus.RUNNING\n", - "Job 22ccd35f-fd72-4ffd-acbb-3de9c4424b69 is not complete; Currently in state: JobStatus.RUNNING\n", - "Job 22ccd35f-fd72-4ffd-acbb-3de9c4424b69 is not complete; Currently in state: JobStatus.RUNNING\n", - "Job 22ccd35f-fd72-4ffd-acbb-3de9c4424b69 is not complete; Currently in state: JobStatus.RUNNING\n", - "Job 22ccd35f-fd72-4ffd-acbb-3de9c4424b69 is not complete; Currently in state: JobStatus.RUNNING\n", - "Job 22ccd35f-fd72-4ffd-acbb-3de9c4424b69 is not complete; Currently in state: JobStatus.RUNNING\n", - "Job 22ccd35f-fd72-4ffd-acbb-3de9c4424b69 is not complete; Currently in state: JobStatus.RUNNING\n", - "Job 22ccd35f-fd72-4ffd-acbb-3de9c4424b69 is not complete; Currently in state: JobStatus.RUNNING\n", - "Job 22ccd35f-fd72-4ffd-acbb-3de9c4424b69 is not complete; Currently in state: JobStatus.RUNNING\n", - "Job 22ccd35f-fd72-4ffd-acbb-3de9c4424b69 is not complete; Currently in state: JobStatus.RUNNING\n", - "Job 22ccd35f-fd72-4ffd-acbb-3de9c4424b69 is not complete; Currently in state: JobStatus.RUNNING\n", - "Job 22ccd35f-fd72-4ffd-acbb-3de9c4424b69 is not complete; Currently in state: JobStatus.RUNNING\n", - "Job 22ccd35f-fd72-4ffd-acbb-3de9c4424b69 is not complete; Currently in state: JobStatus.RUNNING\n", - "Job 22ccd35f-fd72-4ffd-acbb-3de9c4424b69 is not complete; Currently in state: JobStatus.RUNNING\n", - "Job 22ccd35f-fd72-4ffd-acbb-3de9c4424b69 is not complete; Currently in state: JobStatus.RUNNING\n", - "Job 22ccd35f-fd72-4ffd-acbb-3de9c4424b69 is not complete; Currently in state: JobStatus.RUNNING\n", - "Job 22ccd35f-fd72-4ffd-acbb-3de9c4424b69 is not complete; Currently in state: JobStatus.RUNNING\n", - "Job 22ccd35f-fd72-4ffd-acbb-3de9c4424b69 is not complete; Currently in state: JobStatus.RUNNING\n", - "Job 22ccd35f-fd72-4ffd-acbb-3de9c4424b69 is not complete; Currently in state: JobStatus.RUNNING\n", - "Job 22ccd35f-fd72-4ffd-acbb-3de9c4424b69 is not complete; Currently in state: JobStatus.RUNNING\n", - "Job 22ccd35f-fd72-4ffd-acbb-3de9c4424b69 is not complete; Currently in state: JobStatus.RUNNING\n", - "Job 22ccd35f-fd72-4ffd-acbb-3de9c4424b69 is not complete; Currently in state: JobStatus.RUNNING\n", - "Job 22ccd35f-fd72-4ffd-acbb-3de9c4424b69 is not complete; Currently in state: JobStatus.RUNNING\n", - "Job 22ccd35f-fd72-4ffd-acbb-3de9c4424b69 is not complete; Currently in state: JobStatus.RUNNING\n", - "Job 22ccd35f-fd72-4ffd-acbb-3de9c4424b69 is not complete; Currently in state: JobStatus.RUNNING\n", - "Job 22ccd35f-fd72-4ffd-acbb-3de9c4424b69 is not complete; Currently in state: JobStatus.RUNNING\n", - "Job 22ccd35f-fd72-4ffd-acbb-3de9c4424b69 is not complete; Currently in state: JobStatus.RUNNING\n", - "Job 22ccd35f-fd72-4ffd-acbb-3de9c4424b69 is not complete; Currently in state: JobStatus.RUNNING\n", - "Job 22ccd35f-fd72-4ffd-acbb-3de9c4424b69 is not complete; Currently in state: JobStatus.RUNNING\n", - "Job 22ccd35f-fd72-4ffd-acbb-3de9c4424b69 is not complete; Currently in state: JobStatus.RUNNING\n", - "Job 22ccd35f-fd72-4ffd-acbb-3de9c4424b69 is not complete; Currently in state: JobStatus.RUNNING\n", - "Job 22ccd35f-fd72-4ffd-acbb-3de9c4424b69 is not complete; Currently in state: JobStatus.RUNNING\n", - "Job 22ccd35f-fd72-4ffd-acbb-3de9c4424b69 is not complete; Currently in state: JobStatus.RUNNING\n", - "Job 22ccd35f-fd72-4ffd-acbb-3de9c4424b69 is not complete; Currently in state: JobStatus.RUNNING\n", - "Job 22ccd35f-fd72-4ffd-acbb-3de9c4424b69 is not complete; Currently in state: JobStatus.RUNNING\n", - "Job 22ccd35f-fd72-4ffd-acbb-3de9c4424b69 is not complete; Currently in state: JobStatus.RUNNING\n", - "Job 22ccd35f-fd72-4ffd-acbb-3de9c4424b69 is not complete; Currently in state: JobStatus.RUNNING\n", - "Job 22ccd35f-fd72-4ffd-acbb-3de9c4424b69 is not complete; Currently in state: JobStatus.RUNNING\n", - "Job 22ccd35f-fd72-4ffd-acbb-3de9c4424b69 is not complete; Currently in state: JobStatus.RUNNING\n", - "Job 22ccd35f-fd72-4ffd-acbb-3de9c4424b69 is not complete; Currently in state: JobStatus.RUNNING\n", - "Job 22ccd35f-fd72-4ffd-acbb-3de9c4424b69 is not complete; Currently in state: JobStatus.RUNNING\n", - "Job 22ccd35f-fd72-4ffd-acbb-3de9c4424b69 is not complete; Currently in state: JobStatus.RUNNING\n", - "Job 22ccd35f-fd72-4ffd-acbb-3de9c4424b69 is not complete; Currently in state: JobStatus.RUNNING\n", - "Job 22ccd35f-fd72-4ffd-acbb-3de9c4424b69 is not complete; Currently in state: JobStatus.RUNNING\n", - "Job 22ccd35f-fd72-4ffd-acbb-3de9c4424b69 is not complete; Currently in state: JobStatus.RUNNING\n", - "Job 22ccd35f-fd72-4ffd-acbb-3de9c4424b69 is not complete; Currently in state: JobStatus.RUNNING\n", - "Job 22ccd35f-fd72-4ffd-acbb-3de9c4424b69 is not complete; Currently in state: JobStatus.RUNNING\n", - "Job 22ccd35f-fd72-4ffd-acbb-3de9c4424b69 is not complete; Currently in state: JobStatus.RUNNING\n", - "Job 22ccd35f-fd72-4ffd-acbb-3de9c4424b69 is not complete; Currently in state: JobStatus.RUNNING\n", - "Job 22ccd35f-fd72-4ffd-acbb-3de9c4424b69 is not complete; Currently in state: JobStatus.RUNNING\n", - "Job 22ccd35f-fd72-4ffd-acbb-3de9c4424b69 is not complete; Currently in state: JobStatus.RUNNING\n", - "Job 22ccd35f-fd72-4ffd-acbb-3de9c4424b69 is not complete; Currently in state: JobStatus.RUNNING\n", - "Job 22ccd35f-fd72-4ffd-acbb-3de9c4424b69 is not complete; Currently in state: JobStatus.RUNNING\n", - "Job 22ccd35f-fd72-4ffd-acbb-3de9c4424b69 is not complete; Currently in state: JobStatus.RUNNING\n", - "Job 22ccd35f-fd72-4ffd-acbb-3de9c4424b69 is not complete; Currently in state: JobStatus.RUNNING\n", - "Job 22ccd35f-fd72-4ffd-acbb-3de9c4424b69 is not complete; Currently in state: JobStatus.RUNNING\n", - "Job 22ccd35f-fd72-4ffd-acbb-3de9c4424b69 is not complete; Currently in state: JobStatus.RUNNING\n", - "Job 22ccd35f-fd72-4ffd-acbb-3de9c4424b69 is not complete; Currently in state: JobStatus.RUNNING\n", - "Job 22ccd35f-fd72-4ffd-acbb-3de9c4424b69 is not complete; Currently in state: JobStatus.RUNNING\n", - "Job 22ccd35f-fd72-4ffd-acbb-3de9c4424b69 is not complete; Currently in state: JobStatus.RUNNING\n", - "Job 22ccd35f-fd72-4ffd-acbb-3de9c4424b69 is not complete; Currently in state: JobStatus.RUNNING\n", - "Job 22ccd35f-fd72-4ffd-acbb-3de9c4424b69 is not complete; Currently in state: JobStatus.RUNNING\n", - "Job 22ccd35f-fd72-4ffd-acbb-3de9c4424b69 is not complete; Currently in state: JobStatus.RUNNING\n", - "Job 22ccd35f-fd72-4ffd-acbb-3de9c4424b69 is not complete; Currently in state: JobStatus.RUNNING\n", - "Job 22ccd35f-fd72-4ffd-acbb-3de9c4424b69 is not complete; Currently in state: JobStatus.RUNNING\n", - "Job 22ccd35f-fd72-4ffd-acbb-3de9c4424b69 is not complete; Currently in state: JobStatus.RUNNING\n", - "Job 22ccd35f-fd72-4ffd-acbb-3de9c4424b69 is not complete; Currently in state: JobStatus.RUNNING\n", - "Job 22ccd35f-fd72-4ffd-acbb-3de9c4424b69 is not complete; Currently in state: JobStatus.RUNNING\n", - "Job 22ccd35f-fd72-4ffd-acbb-3de9c4424b69 is not complete; Currently in state: JobStatus.RUNNING\n", - "Job 22ccd35f-fd72-4ffd-acbb-3de9c4424b69 is not complete; Currently in state: JobStatus.RUNNING\n", - "Job 22ccd35f-fd72-4ffd-acbb-3de9c4424b69 is not complete; Currently in state: JobStatus.RUNNING\n", - "Job 22ccd35f-fd72-4ffd-acbb-3de9c4424b69 completed with status JobStatus.SUCCESSFUL\n" - ] - } - ], + "outputs": [], "source": [ "# Retrieve status and poll value until the job is complete\n", "status = job.get_status().status\n", @@ -406,25 +204,10 @@ }, { "cell_type": "code", - "execution_count": 8, + "execution_count": null, "id": "ae823803-05cf-420f-a8de-dd88157f7bfe", "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Total jobs: 1\n", - "Job details: \n", - "unity_sds_client.resources.Job(\n", - " id=\"22ccd35f-fd72-4ffd-acbb-3de9c4424b69\",\n", - " process=\"cwl_dag\",\n", - " status=\"successful\",\n", - " inputs=None\n", - ")\n" - ] - } - ], + "outputs": [], "source": [ "jobs = process_service.get_jobs()\n", "\n", @@ -446,23 +229,10 @@ }, { "cell_type": "code", - "execution_count": 9, + "execution_count": null, "id": "2875c57c-7383-4977-8cc0-b4d1ae14653d", "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "unity_sds_client.resources.Job(\n", - " id=\"22ccd35f-fd72-4ffd-acbb-3de9c4424b69\",\n", - " process=\"cwl_dag\",\n", - " status=\"dismissed\",\n", - " inputs=None\n", - ")\n" - ] - } - ], + "outputs": [], "source": [ "status = job.dismiss()\n", "print(status)" @@ -470,24 +240,61 @@ }, { "cell_type": "code", - "execution_count": 10, + "execution_count": null, "id": "b2892ad5-68f7-4e92-b3ea-f60eba0491f6", "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Total jobs: 0\n" - ] - } - ], + "outputs": [], "source": [ "# Display all jobs\n", "jobs = process_service.get_jobs()\n", "print(f\"Total jobs: {len(jobs)}\")" ] }, + { + "cell_type": "markdown", + "id": "c0788a57-8714-4ea8-854e-550a819a7826", + "metadata": {}, + "source": [ + "## Deregister a process (optional)\n", + "\n", + "When you deregister a process it is removed from the SPS deployment. The `Unity-Py` library currently does not have a process for deregistering processes so you will need to use the `requests` library to preform a `DELETE` request." + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "a105b45f-b4da-43df-bfc6-83c91a814489", + "metadata": {}, + "outputs": [], + "source": [ + "# Set up the Unity venue\n", + "unity = Unity(UnityEnvironments.DEV) # Enter Unity username and password\n", + "unity.set_venue_id(\"\") # Leave blank for now\n", + "process_service = unity.client(UnityServices.PROCESS_SERVICE)\n", + "process_service.endpoint = input(\"Please enter the URL for the OGC Processes API without a trailing slash: \")\n", + "\n", + "# List all processes\n", + "processes = process_service.get_processes()\n", + "print(\"All registered processes: \")\n", + "for process in processes:\n", + " print(process)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "a8b38e7f-f778-4580-abfa-7e13cee96f41", + "metadata": {}, + "outputs": [], + "source": [ + "# Grab process \"id\" from above and submit a delete request\n", + "headers = {\n", + " \"Authorization\": f\"Bearer {process_service._session.get_auth()._token}\"\n", + "}\n", + "response = requests.delete(f\"{process_service.endpoint}/processes/cwl_dag\", headers=headers) # Entering id from process details above as the last element in the URL\n", + "print(f\"Deregistered process response: {response}\") # 204 indicates success" + ] + }, { "cell_type": "markdown", "id": "5235ba6d-70d6-47f2-8219-7b0e5c0982fa", @@ -512,7 +319,7 @@ }, { "cell_type": "code", - "execution_count": 11, + "execution_count": null, "id": "1b46ea0b-cb35-4725-94b8-e74c6258b1aa", "metadata": {}, "outputs": [], @@ -605,33 +412,30 @@ "unity = Unity(UnityEnvironments.DEV) # Enter Unity username and password\n", "unity.set_venue_id(\"\") # Leave blank for now\n", "process_service = unity.client(UnityServices.PROCESS_SERVICE)\n", - "process_service.endpoint = input(\"Please enter the URL for the OGC Processes API: \")\n", + "process_service.endpoint = input(\"Please enter the URL for the OGC Processes API with trailing slash: \")\n", "\n", "# Register the process\n", "response = process_service.deploy_process(cwl_dag_process_description)\n", - "print(f\"\\nRegistered process response: {response}\")\n", - "\n", - "# List all processes\n", - "processes = process_service.get_processes()\n", - "print(\"\\nAll registered processes: \")\n", - "for process in processes:\n", - " print(process)" + "print(f\"\\nRegistered process response: {response}\")" ] }, { "cell_type": "markdown", - "id": "c0788a57-8714-4ea8-854e-550a819a7826", + "id": "5e828f02-5526-4980-bab2-359438bed757", "metadata": {}, "source": [ - "## Deregister a process (optional)\n", + "## Update a process (optional)\n", "\n", - "When you deregister a process it is removed from the SPS deployment. The `Unity-Py` library currently does not have a process for deregistering processes so you will need to use the `requests` library to preform a `DELETE` request." + "You can update a process without having to register or deregister it by executing a `PUT` API request on the OGC API. Therefore the steps to develop and update a DAG are:\n", + "\n", + "1. Modify the DAG and check in the new version to the GitHub repository\n", + "2. Send a `PUT` request to the OGC Processes API to update the DAG which deploys the updated DAG code to the SPS system" ] }, { "cell_type": "code", "execution_count": null, - "id": "a105b45f-b4da-43df-bfc6-83c91a814489", + "id": "1e2ce8b7-05f1-421c-a30a-fc35835d0ec6", "metadata": {}, "outputs": [], "source": [ @@ -639,49 +443,117 @@ "unity = Unity(UnityEnvironments.DEV) # Enter Unity username and password\n", "unity.set_venue_id(\"\") # Leave blank for now\n", "process_service = unity.client(UnityServices.PROCESS_SERVICE)\n", - "process_service.endpoint = input(\"Please enter the URL for the OGC Processes API: \")\n", - "\n", - "# List all processes\n", - "processes = process_service.get_processes()\n", - "print(\"All registered processes: \")\n", - "for process in processes:\n", - " print(process)" + "process_service.endpoint = input(\"Please enter the URL for the OGC Processes API without a trailing slash: \")" ] }, { "cell_type": "code", - "execution_count": 15, - "id": "a8b38e7f-f778-4580-abfa-7e13cee96f41", + "execution_count": null, + "id": "d6e9e88a-c1dc-4fbe-9afa-76042ccf66e4", "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Deregistered process response: \n" - ] - } - ], + "outputs": [], "source": [ - "# Grab process \"id\" from above and submit a delete request\n", - "response = requests.delete(f\"{process_service.endpoint}/processes/cwl_dag\") # Entering id from process details above as the last element in the URL\n", - "print(f\"Deregistered process response: {response}\") # 204 indicates success" + "# Select process to update\n", + "process = process_service.get_process(\"cwl_dag\")\n", + "process_id = process.id\n", + "process_id" ] }, { "cell_type": "code", "execution_count": null, - "id": "cb1f7aab-bafa-46d9-ab55-402643421a2f", + "id": "e9716b61-892d-48dc-8fc3-a65a562469f7", "metadata": {}, "outputs": [], - "source": [] + "source": [ + "# Define the CWL process definition\n", + "cwl_dag_process_description = {\n", + " \"executionUnit\": {\n", + " \"image\": \"ghcr.io/unity-sds/unity-sps/sps-docker-cwl:2.5.1\",\n", + " \"type\": \"docker\"\n", + " },\n", + " \"processDescription\": {\n", + " \"description\": \"This process executes any CWL workflow.\",\n", + " \"id\": \"cwl_dag\",\n", + " \"inputs\": {\n", + " \"cwl_args\": {\n", + " \"description\": \"The URL of the CWL workflow's YAML parameters file\",\n", + " \"maxOccurs\": 1,\n", + " \"minOccurs\": 1,\n", + " \"schema\": {\n", + " \"format\": \"uri\",\n", + " \"type\": \"string\"\n", + " },\n", + " \"title\": \"CWL Workflow Parameters URL\"\n", + " },\n", + " \"cwl_workflow\": {\n", + " \"description\": \"The URL of the CWL workflow\",\n", + " \"maxOccurs\": 1,\n", + " \"minOccurs\": 1,\n", + " \"schema\": {\n", + " \"format\": \"uri\",\n", + " \"type\": \"string\"\n", + " },\n", + " \"title\": \"CWL Workflow URL\"\n", + " },\n", + " \"request_instance_type\": {\n", + " \"description\": \"The specific EC2 instance type requested for the job\",\n", + " \"maxOccurs\": 1,\n", + " \"minOccurs\": 1,\n", + " \"schema\": {\n", + " \"type\": \"string\"\n", + " },\n", + " \"title\": \"Requested EC2 Type\"\n", + " },\n", + " \"request_storage\": {\n", + " \"description\": \"The amount of storage requested for the job\",\n", + " \"maxOccurs\": 1,\n", + " \"minOccurs\": 1,\n", + " \"schema\": {\n", + " \"type\": \"string\"\n", + " },\n", + " \"title\": \"Requested Storage\"\n", + " }\n", + " },\n", + " \"jobControlOptions\": [\n", + " \"async-execute\"\n", + " ],\n", + " \"outputs\": {\n", + " \"result\": {\n", + " \"description\": \"The result of the SBG Preprocess Workflow execution\",\n", + " \"schema\": {\n", + " \"$ref\": \"some-ref\"\n", + " },\n", + " \"title\": \"Process Result\"\n", + " }\n", + " },\n", + " \"title\": \"Generic CWL Process\",\n", + " \"version\": \"1.0.0\"\n", + " }\n", + "}" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "18923018-3f1b-4ae5-81a1-09018d577da5", + "metadata": {}, + "outputs": [], + "source": [ + "# Send PUT request to update process\n", + "headers = {\n", + " \"Authorization\": f\"Bearer {process_service._session.get_auth()._token}\"\n", + "}\n", + "response = requests.put(f\"{process_service.endpoint}/processes/{process_id}\", headers=headers, data=json.dumps(cwl_dag_process_description))\n", + "print(f\"Update process response: {response}\") # Should return an empty response with a 204 status" + ] } ], "metadata": { "kernelspec": { - "display_name": "Python [conda env:base] *", + "display_name": "Python 3 (ipykernel)", "language": "python", - "name": "conda-base-py" + "name": "python3" }, "language_info": { "codemirror_mode": { @@ -693,7 +565,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.11.6" + "version": "3.12.9" } }, "nbformat": 4, From 80db0999e7b54891d357a8801d1b8e08cc4fb897 Mon Sep 17 00:00:00 2001 From: Nikki <17799906+nikki-t@users.noreply.github.com> Date: Tue, 1 Jul 2025 13:11:12 -0400 Subject: [PATCH 2/2] Add Jupyter notebook updates to CHANGELOG --- libs/unity-py/CHANGELOG.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/libs/unity-py/CHANGELOG.md b/libs/unity-py/CHANGELOG.md index 0f56469b..c5c8b7dc 100644 --- a/libs/unity-py/CHANGELOG.md +++ b/libs/unity-py/CHANGELOG.md @@ -5,6 +5,11 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [0.13.0] - 2025-07-01 + +### Added +* Modify Unity-Py Jupyter notebook to provide documentation on how to update an OGC process + ## [0.12.0] - 2025-06-10 ### Added