Skip to content

Commit 14cc3d7

Browse files
committed
Log sync processing identifier by default #890
1 parent e89f4f5 commit 14cc3d7

3 files changed

Lines changed: 18 additions & 1 deletion

File tree

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1010
### Added
1111

1212
- Add public `split_area` function for tile-grid based job splitting
13+
- Log synchronous processing identifier ("OpenEO-Identifier" response header) by default (debug level) ([#890](https://github.com/Open-EO/openeo-python-client/issues/890))
14+
1315

1416
### Changed
1517

openeo/rest/connection.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,8 @@ def __init__(
182182
self._refresh_token_store = refresh_token_store
183183
self._oidc_auth_renewer = oidc_auth_renewer
184184
self._auto_validate = auto_validate
185-
self._on_response_headers_sync = on_response_headers_sync
185+
if on_response_headers_sync:
186+
self._on_response_headers_sync = on_response_headers_sync
186187

187188
@classmethod
188189
def version_discovery(
@@ -222,6 +223,10 @@ def _get_auth_config(self) -> AuthConfig:
222223
self._auth_config = AuthConfig()
223224
return self._auth_config
224225

226+
def _on_response_headers_sync(self, headers: Mapping):
227+
if identifier := headers.get("OpenEO-Identifier"):
228+
_log.debug(f"Synchronous processing identifier: {identifier!r}")
229+
225230
def _get_refresh_token_store(self) -> RefreshTokenStore:
226231
if self._refresh_token_store is None:
227232
self._refresh_token_store = RefreshTokenStore()

tests/rest/test_connection.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4361,6 +4361,16 @@ def test_download_on_response_headers(dummy_backend, tmp_path):
43614361
assert results == [{"OpenEO-Identifier": "r-001"}]
43624362

43634363

4364+
def test_connection_on_response_headers_sync_default_download(dummy_backend, tmp_path, caplog):
4365+
connection = openeo.connect(dummy_backend.connection.root_url)
4366+
with caplog.at_level(logging.DEBUG, logger="openeo"):
4367+
connection.download(
4368+
{"foo1": {"process_id": "foo"}},
4369+
tmp_path / "result.data",
4370+
)
4371+
assert "Synchronous processing identifier: 'r-001'" in caplog.messages
4372+
4373+
43644374
def test_connection_on_response_headers_sync_download(dummy_backend, tmp_path):
43654375
results = []
43664376
connection = openeo.connect(dummy_backend.connection.root_url, on_response_headers_sync=results.append)

0 commit comments

Comments
 (0)