Skip to content

Commit

Permalink
HARMONY-1414: Added support to harmony requests that completes succes…
Browse files Browse the repository at this point in the history
…sfully without creating a job.
  • Loading branch information
ygliuvt committed Aug 3, 2023
1 parent b803685 commit 72c79ca
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 2 deletions.
29 changes: 29 additions & 0 deletions examples/tutorial.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down
6 changes: 4 additions & 2 deletions harmony/harmony.py
Original file line number Diff line number Diff line change
Expand Up @@ -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())
Expand All @@ -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)

Expand Down

0 comments on commit 72c79ca

Please sign in to comment.