Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Added

- Add public `split_area` function for tile-grid based job splitting
- Expose `OpenEO-Identifier` response header from synchronous processing requests (POST `/result`):
add `on_response_headers` argument to `DataCube.execute()` and `VectorCube.execute()`,
and automatically log the identifier at debug level when it is present in the response.

### Changed

Expand Down
4 changes: 4 additions & 0 deletions openeo/rest/connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -1765,6 +1765,8 @@ def download(
stream=True,
timeout=timeout or DEFAULT_TIMEOUT_SYNCHRONOUS_EXECUTE,
)
if openeo_identifier := response.headers.get("OpenEO-Identifier"):
_log.debug("Synchronous processing request identifier: %s", openeo_identifier)
if on_response_headers := (on_response_headers or self._on_response_headers_sync):
on_response_headers(response.headers)

Expand Down Expand Up @@ -1820,6 +1822,8 @@ def execute(
expected_status=200,
timeout=timeout or DEFAULT_TIMEOUT_SYNCHRONOUS_EXECUTE,
)
if openeo_identifier := response.headers.get("OpenEO-Identifier"):
_log.debug("Synchronous processing request identifier: %s", openeo_identifier)
if on_response_headers := (on_response_headers or self._on_response_headers_sync):
on_response_headers(response.headers)

Expand Down
16 changes: 16 additions & 0 deletions tests/rest/test_connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -4371,6 +4371,22 @@ def test_connection_on_response_headers_sync_download(dummy_backend, tmp_path):
assert results == [{"OpenEO-Identifier": "r-001"}]


def test_download_openeo_identifier_logging(dummy_backend, tmp_path, caplog):
with caplog.at_level(logging.DEBUG, logger="openeo.rest.connection"):
dummy_backend.connection.download(
{"foo1": {"process_id": "foo"}},
tmp_path / "result.data",
)
assert "r-001" in caplog.text


def test_execute_openeo_identifier_logging(dummy_backend, caplog):
dummy_backend.next_result = {"result": 42}
with caplog.at_level(logging.DEBUG, logger="openeo.rest.connection"):
dummy_backend.connection.execute({"foo1": {"process_id": "foo"}})
assert "r-001" in caplog.text


@pytest.mark.parametrize(
"pg",
[
Expand Down