Skip to content

Commit 83f0945

Browse files
committed
download optional
1 parent 8bd7935 commit 83f0945

File tree

1 file changed

+15
-8
lines changed

1 file changed

+15
-8
lines changed

openeo/extra/job_management/_manager.py

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -157,10 +157,14 @@ def start_job(
157157
- get_error_log_path
158158
- get_job_metadata_path
159159
160+
:param auto_download_results:
161+
Optional disable the automated download of job results.
162+
160163
:param cancel_running_job_after:
161164
Optional temporal limit (in seconds) after which running jobs should be canceled
162165
by the job manager.
163166
167+
164168
.. versionadded:: 0.14.0
165169
166170
.. versionchanged:: 0.32.0
@@ -193,6 +197,7 @@ def __init__(
193197
poll_sleep: int = 60,
194198
root_dir: Optional[Union[str, Path]] = ".",
195199
*,
200+
auto_download_results: bool = True,
196201
cancel_running_job_after: Optional[int] = None,
197202
):
198203
"""Create a MultiBackendJobManager."""
@@ -204,6 +209,8 @@ def __init__(
204209
# An explicit None or "" should also default to "."
205210
self._root_dir = Path(root_dir or ".")
206211

212+
self.auto_download_results = auto_download_results
213+
207214
self._cancel_running_job_after = (
208215
datetime.timedelta(seconds=cancel_running_job_after) if cancel_running_job_after is not None else None
209216
)
@@ -712,16 +719,16 @@ def on_job_done(self, job: BatchJob, row):
712719
:param row: DataFrame row containing the job's metadata.
713720
"""
714721
# TODO: param `row` is never accessed in this method. Remove it? Is this intended for future use?
722+
if self.auto_download_results:
723+
job_metadata = job.describe()
724+
job_dir = self.get_job_dir(job.job_id)
725+
metadata_path = self.get_job_metadata_path(job.job_id)
715726

716-
job_metadata = job.describe()
717-
job_dir = self.get_job_dir(job.job_id)
718-
metadata_path = self.get_job_metadata_path(job.job_id)
719-
720-
self.ensure_job_dir_exists(job.job_id)
721-
job.get_results().download_files(target=job_dir)
727+
self.ensure_job_dir_exists(job.job_id)
728+
job.get_results().download_files(target=job_dir)
722729

723-
with metadata_path.open("w", encoding="utf-8") as f:
724-
json.dump(job_metadata, f, ensure_ascii=False)
730+
with metadata_path.open("w", encoding="utf-8") as f:
731+
json.dump(job_metadata, f, ensure_ascii=False)
725732

726733
def on_job_error(self, job: BatchJob, row):
727734
"""

0 commit comments

Comments
 (0)