Skip to main content

summary.OperationSummary

Summary of batch operation results (processing, downloading, etc.).

Usage

Source

summary.OperationSummary(
    n_total,
    n_processed,
    n_skipped,
    n_failed,
    products,
    failed_items,
    processing_time=0.0
)

Parameters

n_total: int

Total number of operations attempted.

n_processed: int

Number of successfully processed items.

n_skipped: int

Number of skipped operations (already existed).

n_failed: int

Number of failed operations.

products: list[T]

The products successfully processed or already existed.

failed_items: list[ErrorResult]

List of operation results for failed items.

processing_time: float = 0.0
Total operation time in seconds.

Attributes

Name Description
success_rate Calculate success rate.

success_rate

Calculate success rate.

success_rate: float

The operation was successful if the item was processed or skipped (already existing).

Methods

Name Description
from_results() Create summary from a collection of operation results.
print_summary() Print formatted summary table.
raise_on_failure() Raise if any item failed, otherwise return the summary.

from_results()

Create summary from a collection of operation results.

Usage

Source

from_results(results, start_time, end_time)
Parameters
results: Collection[OkResult[T] | ErrorResult]

Results from individual operations.

start_time: float

Unix timestamp at start of batch.

end_time: float
Unix timestamp at end of batch.
Returns
OperationSummary[T]
Aggregated summary of results.


raise_on_failure()

Raise if any item failed, otherwise return the summary.

Usage

Source

raise_on_failure(ignore=())

Runs after the batch, when every product that could be made has been written, and raises one error listing all failures. Running the batch again skips the existing products and retries only the failed items, except bursts a BurstCatalog already found missing at the source, which the same catalog reports as failed again without a retry. Returning the summary lets the check sit inside a call chain, as in processor.create_coherences(pairs, crs=crs).raise_on_failure().products.

Parameters
ignore: type[BaseException] | tuple[type[BaseException], …] = ()
Error type, or tuple of types, whose failures are tolerated, such as BurstNotFoundError for bursts the source no longer serves. They do not raise, and stay in failed_items.
Returns
Self
This summary, unchanged.
Raises
OperationFailedError
If any item failed with an error that is not ignored. Its message lists those items and their errors and counts the ignored ones; its summary is this summary, so err.summary.products still holds the products that were made.