sentinelhub.api.batch.utils

Module implementing utilities for working with batch jobs.

sentinelhub.api.batch.utils.monitor_batch_job(batch_request, config=None, sleep_time=120, analysis_sleep_time=10)[source]

A utility function that keeps checking for number of processed tiles until the given batch request finishes. During the process it shows a progress bar and at the end it reports information about finished and failed tiles.

Notes:

  • Before calling this function make sure to start a batch job by calling SentinelHubBatch.start_job method. In case a batch job is still being analysed this function will wait until the analysis ends.

  • This function will be continuously collecting tile information from Sentinel Hub service. To avoid making too many requests please make sure to adjust sleep_time parameter according to the size of your job. Larger jobs don’t need very frequent tile status updates.

  • Some information about the progress of this function is reported to logging level INFO.

Parameters
  • batch_request (Union[str, dict, BatchRequest]) – An object with information about a batch request. Alternatively, it could only be a batch request id or a payload.

  • config (Optional[SHConfig]) – A configuration object with required parameters sh_client_id, sh_client_secret, and sh_auth_base_url which is used for authentication and sh_base_url which defines the service deployment where Batch API will be called.

  • sleep_time (int) – Number of seconds to sleep between consecutive progress bar updates.

  • analysis_sleep_time (int) – Number of seconds between consecutive status updates during analysis phase.

Returns

A dictionary mapping a tile status to a list of tile payloads.

Return type

DefaultDict[BatchTileStatus, List[dict]]

sentinelhub.api.batch.utils.monitor_batch_statistical_job(batch_request, config=None, sleep_time=30, analysis_sleep_time=10)[source]

A utility function that keeps checking the completion percentage of a Batch Statistical request until complete.

Notes:

  • Before calling this function make sure to start a batch job via SentinelHubBatchStatistical.start_job method. In case a batch job is still being analysed this function will wait until the analysis ends.

  • Some information about the progress of this function is reported to logging level INFO.

Parameters
  • batch_request (Union[str, dict, BatchStatisticalRequest]) – An object with information about a batch request. Alternatively, it could only be a batch request id or a payload.

  • config (Optional[SHConfig]) – A configuration object with required parameters sh_client_id, sh_client_secret, and sh_auth_base_url which is used for authentication and sh_base_url which defines the service deployment where Batch API will be called.

  • sleep_time (int) – Number of seconds to sleep between consecutive progress bar updates.

  • analysis_sleep_time (int) – Number of seconds between consecutive status updates during analysis phase.

Returns

Final status of the batch request.

Return type

Dict[str, Any]

sentinelhub.api.batch.utils.monitor_batch_analysis(batch_request, config=None, sleep_time=10)[source]

A utility function that is waiting until analysis phase of a batch job finishes and regularly checks its status. In case analysis phase failed it raises an error at the end.

Parameters
  • batch_request (Union[str, dict, BatchRequest]) – An object with information about a batch request. Alternatively, it could only be a batch request id or a payload.

  • config (Optional[SHConfig]) – A configuration object with required parameters sh_client_id, sh_client_secret, and sh_auth_base_url which is used for authentication and sh_base_url which defines the service deployment where Batch API will be called.

  • sleep_time (int) – Number of seconds between consecutive status updates during analysis phase.

Returns

Batch request info

Return type

BatchRequest

sentinelhub.api.batch.utils.monitor_batch_statistical_analysis(batch_request, config=None, sleep_time=10)[source]

A utility function that is waiting until analysis phase of a batch job finishes and regularly checks its status. In case analysis phase failed it raises an error at the end.

Parameters
  • batch_request (Union[str, dict, BatchStatisticalRequest]) – An object with information about a batch request. Alternatively, it could only be a batch request id or a payload.

  • config (Optional[SHConfig]) – A configuration object with required parameters sh_client_id, sh_client_secret, and sh_auth_base_url which is used for authentication and sh_base_url which defines the service deployment where Batch API will be called.

  • sleep_time (int) – Number of seconds between consecutive status updates during analysis phase.

Returns

Batch request info

Return type

BatchStatisticalRequest