diff --git a/CHANGELOG.md b/CHANGELOG.md index 7c4310324..1076cecaf 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/openeo/rest/connection.py b/openeo/rest/connection.py index d4d4d5995..ccafa4cb6 100644 --- a/openeo/rest/connection.py +++ b/openeo/rest/connection.py @@ -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) @@ -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) diff --git a/tests/rest/test_connection.py b/tests/rest/test_connection.py index 6da731f71..f847b8847 100644 --- a/tests/rest/test_connection.py +++ b/tests/rest/test_connection.py @@ -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", [