Skip to content

Failed upload exception

FailedUploadException #

FailedUploadException(
    dataset: RapidataDataset,
    failed_uploads: list[FailedUpload[Datapoint]],
    job_definition: Optional[RapidataJobDefinition] = None,
    machine: Optional[JobDefinitionCreationMachine] = None,
)

Bases: Exception

Custom error class for failed datapoint uploads during job-definition creation.

Source code in src/rapidata/rapidata_client/exceptions/failed_upload_exception.py
def __init__(
    self,
    dataset: RapidataDataset,
    failed_uploads: list[FailedUpload[Datapoint]],
    job_definition: Optional[RapidataJobDefinition] = None,
    machine: Optional[JobDefinitionCreationMachine] = None,
):
    self.dataset = dataset
    self.job_definition = job_definition
    self._failed_uploads = failed_uploads
    self._machine = machine
    super().__init__(str(self))

machine property #

machine: Optional[JobDefinitionCreationMachine]

The creation state machine backing retry() for job-definition creation.

failed_uploads property #

failed_uploads: list[Datapoint]

Get list of failed datapoints (backward compatibility).

Returns:

Type Description
list[Datapoint]

List of datapoints that failed to upload.

detailed_failures property #

detailed_failures: list[FailedUpload[Datapoint]]

Get detailed failure information including error messages.

Returns:

Type Description
list[FailedUpload[Datapoint]]

List of FailedUpload objects with item and error details.

failures_by_reason property #

failures_by_reason: dict[str, list[Datapoint]]

Get failures grouped by error reason.

Returns:

Type Description
dict[str, list[Datapoint]]

Dictionary mapping error reasons to lists of failed datapoints.

failures_by_stage property #

failures_by_stage: dict[str, list[Datapoint]]

Get failures grouped by ingestion stage (remote-URL assets).

Only failures that carry a stage are included, so an empty dict means no failure reached the asset service with a classified stage (e.g. local file errors or datapoint-creation failures). The "internal" key is the only Rapidata-side fault; every other stage is caller-actionable.

Returns:

Type Description
dict[str, list[Datapoint]]

Dictionary mapping ingestion stage to lists of failed datapoints.

retry #

Retry the failed datapoints and finish creating the job definition.

Re-uploads only the datapoints that failed into the same dataset (never a new one), then creates the job definition once the upload is within the configured failure tolerance. Returns the created RapidataJobDefinition. If some datapoints still fail beyond the tolerance, this raises FailedUploadException again (with the same dataset attached) so it can be caught and retried in a loop.

This is the intended recovery path for a failed job-definition creation: fix whatever caused the failures (e.g. correct file paths), then call retry() - no need to re-specify the datapoints or drop down to dataset.add_datapoints manually.

Source code in src/rapidata/rapidata_client/exceptions/failed_upload_exception.py
def retry(self) -> RapidataJobDefinition:
    """Retry the failed datapoints and finish creating the job definition.

    Re-uploads only the datapoints that failed into the **same** dataset
    (never a new one), then creates the job definition once the upload is
    within the configured failure tolerance. Returns the created
    ``RapidataJobDefinition``. If some datapoints still fail beyond the
    tolerance, this raises ``FailedUploadException`` again (with the same
    dataset attached) so it can be caught and retried in a loop.

    This is the intended recovery path for a failed job-definition
    creation: fix whatever caused the failures (e.g. correct file paths),
    then call ``retry()`` - no need to re-specify the datapoints or drop
    down to ``dataset.add_datapoints`` manually.
    """
    if self._machine is None:
        raise RuntimeError(
            "retry() is only available for failed job-definition creation. "
            "To re-upload the failed datapoints manually, use "
            "dataset.add_datapoints(exception.failed_uploads)."
        )
    return self._machine.resume()