diff --git a/examples/tutorial.ipynb b/examples/tutorial.ipynb index 5d50a01..7df6db6 100644 --- a/examples/tutorial.ipynb +++ b/examples/tutorial.ipynb @@ -241,6 +241,35 @@ " arrays.append(ds)\n", "plt.imshow(np.dstack(arrays))" ] + }, + { + "cell_type": "markdown", + "id": "b9e8d8d7-03c2-4fb3-b10e-6dee510676e2", + "metadata": {}, + "source": [ + "For request that completes directly without creating a job, the submit call returns the direct download links." + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "9f498daa-7522-45e2-b726-cd9d18a18f61", + "metadata": {}, + "outputs": [], + "source": [ + "collection = Collection(id='C1233800302-EEDTEST')\n", + "\n", + "request = Request(\n", + " collection=collection,\n", + " spatial=BBox(-140, 20, -50, 60),\n", + " crs='EPSG:31975',\n", + " format='image/jpg',\n", + " max_results=1,\n", + " variables=['blue_var']\n", + ")\n", + "links = harmony_client.submit(request)\n", + "print(links)" + ] } ], "metadata": { diff --git a/harmony/harmony.py b/harmony/harmony.py index 5057cf4..06e09fb 100644 --- a/harmony/harmony.py +++ b/harmony/harmony.py @@ -789,7 +789,7 @@ def submit(self, request: BaseRequest) -> any: request: The Request to submit to Harmony (will be validated before sending) Returns: - The Harmony Job ID + The Harmony Job ID or download links or capability response """ if not request.is_valid(): msgs = ', '.join(request.error_messages()) @@ -802,8 +802,10 @@ def submit(self, request: BaseRequest) -> any: if response.ok: if isinstance(request, CapabilitiesRequest): return response.json() + elif response.json()['status'] == 'successful': + return response.json()['links'] else: - return (response.json())['jobID'] + return response.json()['jobID'] else: self._handle_error_response(response)