UploadTask

Back to Vectors

class UploadTask(guid, tuid=None, client=None, upload_id=None, result_attrs=None)[source]

An upload task which may or may not have completed yet. Accessing any attributes before the task is completed (for example status) will block until the task completes.

The upload process is two-phased. In the first phase, the input file is processed to extract features from the file. Errors parsing (invalid NDJSon or invalid GeoJson) will be captured in this phase. The features are then transformed into BigQuery inserts including sharding. In the second phase, the inserts are uploaded to BigQuery for processing. Once both phases have completed, the upload is considered done.

If you want to check whether the attributes are available, use get_result() which will raise a TransientResultError if the attributes are not available yet.

Upload tasks don’t have a result or log attribute.

Do not create an UploadTask yourself; it is returned by FeatureCollection.upload and FeatureCollection.list_uploads.

Attributes:

error_rows Property indicating the number of rows that could not be loaded.
errors Property indicating the list of error records from upload.
exception Property indicating the name of the exception raised during the function execution, if any
exception_name Property indicating the name of the exception raised during the function execution, if any
failure_type The type of failure if this task did not succeed.
input_features Property indicating the number of features to insert.
input_rows Property indicating the number of rows to insert.
is_success Did this task succeeed?
log Upload tasks don’t have a log.
output_rows Property indicating the number of rows that were added.
peak_memory_usage Property indicating the peak memory usage for this completed task, in bytes.
ready Property indicating whether the task has completed
result Upload tasks don’t have a result.
runtime Property indicating the time spent executing the function for this task, in seconds.
stacktrace Property indicating the stacktrace of the exception raised during the function execution, if any.
status Property indicating the status of the task, which can be PENDING, RUNNING, SUCCESS or FAILURE.
traceback Property indicating the stacktrace of the exception raised during the function execution, if any.
upload_id Property indicating the upload_id for the task.

Methods:

get_result([wait, timeout]) Attempt to load the result for this upload task.
get_result(wait=False, timeout=None)[source]

Attempt to load the result for this upload task. After returning from this method without an exception raised, the information for the task is available through the various properties.

Parameters:
  • wait (bool) – Whether to wait for the task to complete or raise a TransientResultError if the task hasn’t completed yet.
  • timeout (int) – How long to wait in seconds for the task to complete, or None to wait indefinitely.
Raises:
  • NotFoundError – When the upload id or task id does not exist.
  • TransientResultError – When the result is not ready yet (and not waiting).
  • TimeoutError – When the timeout has been reached (if waiting and set).
property error_rows

Property indicating the number of rows that could not be loaded. This is the sum of the number of invalid features plus the number of valid features which otherwise failed to load.

Return type:int
Returns:The number of rows that could not be loaded.
property errors

Property indicating the list of error records from upload. Errors may come from parsing of the input file or from attempting to add the features to the collection.

Return type:list or None
Returns:Error records from upload.
property exception

Property indicating the name of the exception raised during the function execution, if any

Return type:str
Returns:The name of the exception or None
property exception_name

Property indicating the name of the exception raised during the function execution, if any

Return type:str
Returns:The name of the exception or None
property failure_type

The type of failure if this task did not succeed.

Return type:str
Returns:The failure type
property input_features

Property indicating the number of features to insert. This may be different from the number of lines in the input file due to errors while parsing the input file.

Return type:int
Returns:The number of features to insert.
property input_rows

Property indicating the number of rows to insert. This may be different from the number reported by input_features due to sharding.

Return type:int
Returns:The number of rows to insert.
property is_success

Did this task succeeed?

Return type:bool
Returns:Whether this task succeeded.
property log

Upload tasks don’t have a log.

Raises:AttributeError – No log available
property output_rows

Property indicating the number of rows that were added. This may be different than the number reported by input_rows if errors occurred.

Return type:int
Returns:The number of rows that were added.
property peak_memory_usage

Property indicating the peak memory usage for this completed task, in bytes.

Return type:int
Returns:The peak memory usage
property ready

Property indicating whether the task has completed

Return type:bool
Returns:True if the upload task has completed and status is available, otherwise False.
property result

Upload tasks don’t have a result.

Raises:AttributeError – No result available
property runtime

Property indicating the time spent executing the function for this task, in seconds.

Return type:int
Returns:The time spent executing the function
property stacktrace

Property indicating the stacktrace of the exception raised during the function execution, if any.

Return type:str
Returns:The stacktrace of the exception or None
property status

Property indicating the status of the task, which can be PENDING, RUNNING, SUCCESS or FAILURE.

Some errors may have occurred even when the status is SUCCESS, if the upload was initiated with a non-zero max_errors parameter. The error_rows or errors property should be consulted.

Conversely, some rows may have been inserted even with the status is FAILURE.

Status values of PENDING or RUNNING indicate the upload is still in progress, and can be waited upon for completion.

Return type:str
Returns:The status for this task.
property traceback

Property indicating the stacktrace of the exception raised during the function execution, if any.

Return type:str
Returns:The stacktrace of the exception or None
property upload_id

Property indicating the upload_id for the task.

Return type:str
Returns:The id of the upload that resulted in this task.