Skip to content

Commit e67fb72

Browse files
committed
Finetune automatic log printing of failed batch jobs
1 parent b73cc33 commit e67fb72

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1414
- Setting the environment variable `OPENEO_BASEMAP_URL` allows to set a new templated URL to a XYZ basemap for the Vue Components library, `OPENEO_BASEMAP_ATTRIBUTION` allows to set the attribution for the basemap ([#260](https://github.com/Open-EO/openeo-python-client/issues/260))
1515
- Initial support for experimental "federation:missing" flag on partial openEO Platform user job listings ([Open-EO/openeo-api#419](https://github.com/Open-EO/openeo-api/pull/419))
1616
- Best effort detection of mistakenly using Python builtin `sum` or `all` functions in callbacks ([Forum #113](https://discuss.eodc.eu/t/reducing-masks-in-openeo/113))
17+
- Automatically print batch job logs when job doesn't finish successfully (using `execute_batch/run_synchronous/start_and_wait`).
1718

1819

1920
### Changed

openeo/rest/job.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import datetime
22
import logging
3+
import textwrap
34
import time
45
import typing
56
from pathlib import Path
@@ -204,10 +205,15 @@ def soft_error(message: str):
204205
poll_interval = min(1.25 * poll_interval, max_poll_interval)
205206

206207
if status != "finished":
207-
print("Your batch job failed. Logs can be found online in an openEO editor, or you can get them with 'connection.job('my_job_id_123').logs()'")
208+
print(textwrap.dedent("""
209+
Your batch job {i!r} failed.
210+
Logs can be inspected in an openEO (web) editor or with `connection.job({i!r}).logs()`.
211+
""".format(i=self.job_id)))
212+
# TODO: make it possible to disable printing logs automatically?
213+
# TODO: render logs jupyter-aware in a notebook context?
208214
print("Printing logs:")
209215
print(self.logs())
210-
raise JobFailedException("Batch job {i} didn't finish properly. Status: {s} (after {t}).".format(
216+
raise JobFailedException("Batch job {i!r} didn't finish successfully. Status: {s} (after {t}).".format(
211217
i=self.job_id, s=status, t=elapsed()
212218
), job=self)
213219

0 commit comments

Comments
 (0)