Skip to content

Commit 026881d

Browse files
committed
Merge branch 'issue570-Deprecate-run_synchronous'
2 parents d225aa2 + 6915ed8 commit 026881d

File tree

9 files changed

+25
-13
lines changed

9 files changed

+25
-13
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
### Changed
1515

1616
- `DataCube.save_result()` (and related methods) now return a `SaveResult`/`StacResource` object instead of another `DataCube` object to be more in line with the official `save_result` specification ([#402](https://github.com/Open-EO/openeo-python-client/issues/402), [#720](https://github.com/Open-EO/openeo-python-client/issues/720))
17+
- Deprecate `BatchJob.run_synchronous` in favor of `BatchJob.start_and_wait` ([#570](https://github.com/Open-EO/openeo-python-client/issues/570)).
1718

1819
### Removed
1920

examples/vito_example.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,8 @@
4242
job = datacube.create_job()
4343
if job:
4444
print(job.job_id)
45-
print(job.run_synchronous("/tmp/testfile"))
45+
job.start_and_wait()
46+
job.download_result(target="/tmp/testfile")
47+
print(job)
4648
else:
4749
print("Job ID is None")

openeo/rest/datacube.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2607,13 +2607,15 @@ def execute_batch(
26072607
log_level=log_level,
26082608
**create_kwargs,
26092609
)
2610-
return job.run_synchronous(
2611-
outputfile=outputfile,
2610+
job.start_and_wait(
26122611
print=print,
26132612
max_poll_interval=max_poll_interval,
26142613
connection_retry_interval=connection_retry_interval,
26152614
show_error_logs=show_error_logs,
26162615
)
2616+
if outputfile is not None:
2617+
job.download_result(target=outputfile)
2618+
return job
26172619

26182620
def create_job(
26192621
self,

openeo/rest/job.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -222,6 +222,7 @@ def logs(self, offset: Optional[str] = None, level: Union[str, int, None] = None
222222
response_data = self.connection.get(url, params=params, expected_status=200).json()
223223
return LogsResponse(response_data=response_data, log_level=level)
224224

225+
@deprecated("Use start_and_wait instead", version="0.39.0")
225226
def run_synchronous(
226227
self,
227228
outputfile: Union[str, Path, None] = None,
@@ -272,6 +273,8 @@ def start_and_wait(
272273
:param soft_error_max: maximum number of soft errors (e.g. temporary connection glitches) to allow
273274
:param show_error_logs: whether to automatically print error logs when the batch job failed.
274275
276+
:return: Handle to the job created at the backend.
277+
275278
.. versionchanged:: 0.37.0
276279
Added argument ``show_error_logs``.
277280
"""

openeo/rest/mlmodel.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -131,14 +131,15 @@ def execute_batch(
131131
job_options=job_options,
132132
log_level=log_level,
133133
)
134-
return job.run_synchronous(
135-
# TODO #135 support multi file result sets too
136-
outputfile=outputfile,
134+
job.start_and_wait(
137135
print=print,
138136
max_poll_interval=max_poll_interval,
139137
connection_retry_interval=connection_retry_interval,
140138
show_error_logs=show_error_logs,
141139
)
140+
if outputfile is not None:
141+
job.download_result(target=outputfile)
142+
return job
142143

143144
def create_job(
144145
self,

openeo/rest/multiresult.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,4 +112,4 @@ def execute_batch(
112112
validate=validate,
113113
log_level=log_level,
114114
)
115-
return job.run_synchronous()
115+
return job.start_and_wait()

openeo/rest/stac_resource.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -207,10 +207,12 @@ def execute_batch(
207207
validate=validate,
208208
log_level=log_level,
209209
)
210-
return job.run_synchronous(
211-
outputfile=outputfile,
210+
job.start_and_wait(
212211
print=print,
213212
max_poll_interval=max_poll_interval,
214213
connection_retry_interval=connection_retry_interval,
215214
show_error_logs=show_error_logs,
216215
)
216+
if outputfile is not None:
217+
job.download_result(target=outputfile)
218+
return job

openeo/rest/vectorcube.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -383,14 +383,15 @@ def execute_batch(
383383
log_level=log_level,
384384
**create_kwargs,
385385
)
386-
return job.run_synchronous(
387-
# TODO #135 support multi file result sets too
388-
outputfile=outputfile,
386+
job.start_and_wait(
389387
print=print,
390388
max_poll_interval=max_poll_interval,
391389
connection_retry_interval=connection_retry_interval,
392390
show_error_logs=show_error_logs,
393391
)
392+
if outputfile is not None:
393+
job.download_result(target=outputfile)
394+
return job
394395

395396
def create_job(
396397
self,

tests/internal/test_documentation.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ def test_extract_main_description():
5555
(DataCube.download, DataCube.execute_batch),
5656
(DataCube.create_job, DataCube.execute_batch),
5757
# DataCube vs BatchJob
58-
(BatchJob.run_synchronous, DataCube.execute_batch),
58+
(BatchJob.start_and_wait, DataCube.execute_batch),
5959
# DataCube vs VectorCube
6060
(DataCube.download, VectorCube.download),
6161
(DataCube.create_job, VectorCube.create_job),

0 commit comments

Comments
 (0)