Skip to content

Commit 2ce9d3b

Browse files
minor finetuning
issue #499
1 parent 73279a7 commit 2ce9d3b

File tree

3 files changed

+6
-4
lines changed

3 files changed

+6
-4
lines changed

openeo/rest/connection.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1577,7 +1577,7 @@ def execute(
15771577
timeout: Optional[int] = None,
15781578
validate: Optional[bool] = None,
15791579
auto_decode: bool = True,
1580-
):
1580+
) -> Union[dict, requests.Response]:
15811581
"""
15821582
Execute a process graph synchronously and return the result. If the result is a JSON object, it will be parsed.
15831583
@@ -1587,7 +1587,7 @@ def execute(
15871587
(overruling the connection's ``auto_validate`` setting).
15881588
:param auto_decode: Boolean flag to enable/disable automatic JSON decoding of the response. Defaults to True.
15891589
1590-
:return: if possible parsed JSON response, otherwise raw response
1590+
:return: parsed JSON response as a dict if auto_decode is True, otherwise response object
15911591
"""
15921592
pg_with_metadata = self._build_request_with_process_graph(process_graph=process_graph)
15931593
self._preflight_validation(pg_with_metadata=pg_with_metadata, validate=validate)

openeo/rest/datacube.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
from typing import Any, Dict, Iterable, List, Optional, Sequence, Tuple, Union, Callable
1919

2020
import numpy as np
21+
import requests
2122
import shapely.geometry
2223
import shapely.geometry.base
2324
from shapely.geometry import MultiPolygon, Polygon, mapping
@@ -2306,15 +2307,15 @@ def save_user_defined_process(
23062307
returns=returns, categories=categories, examples=examples, links=links,
23072308
)
23082309

2309-
def execute(self, *, validate: Optional[bool] = None, auto_decode: bool = True) -> dict:
2310+
def execute(self, *, validate: Optional[bool] = None, auto_decode: bool = True) -> Union[dict, requests.Response]:
23102311
"""
23112312
Execute a process graph synchronously and return the result. If the result is a JSON object, it will be parsed.
23122313
23132314
:param validate: Optional toggle to enable/prevent validation of the process graphs before execution
23142315
(overruling the connection's ``auto_validate`` setting).
23152316
:param auto_decode: Boolean flag to enable/disable automatic JSON decoding of the response. Defaults to True.
23162317
2317-
:return: if possible parsed JSON response, otherwise raw response
2318+
:return: parsed JSON response as a dict if auto_decode is True, otherwise response object
23182319
"""
23192320
return self._connection.execute(self.flat_graph(), validate=validate, auto_decode=auto_decode)
23202321

tests/rest/datacube/test_datacube.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -573,6 +573,7 @@ def test_execute_tiff_raw(connection, requests_mock):
573573
requests_mock.get(API_URL + "/collections/S2", json={})
574574
requests_mock.post(API_URL + "/result", content=b"tiffdata")
575575
result = connection.load_collection("S2").execute(auto_decode=False)
576+
assert isinstance(result, requests.Response)
576577
assert result.content == b"tiffdata"
577578

578579
@pytest.mark.parametrize(["filename", "expected_format"], [

0 commit comments

Comments
 (0)