Export Task

class labelbox.schema.export_task.BufferedJsonConverterOutput(json: Any)[source]

Bases: object

Output with the JSON object

class labelbox.schema.export_task.BufferedStream(ctx: _TaskContext)[source]

Bases: Generic[OutputT]

Streams data from a Reader.

start(stream_handler: Callable[[OutputT], None] | None = None) None[source]

Starts streaming the result data. Calls the stream_handler for each result.

class labelbox.schema.export_task.ExportTask(task: Task, is_export_v2: bool = False)[source]

Bases: object

An adapter class for working with task objects, providing extended functionality and convenient access to task-related information.

This class wraps a Task object, allowing you to interact with tasks of this type. It offers methods to retrieve task results, errors, and metadata, as well as properties for accessing task details such as UID, status, and creation time.

exception ExportTaskException[source]

Bases: Exception

Raised when the task is not ready yet.

property completion_percentage

Returns the completion percentage of the task.

property created_at

Returns the time the task was created.

property created_by

Returns the user who created the task.

property deleted

Returns whether the task is deleted.

property errors

Returns the errors of the task.

property errors_url

Returns the errors URL of the task.

get_buffered_stream(stream_type: StreamType = StreamType.RESULT) BufferedStream[source]

Returns the result of the task.

Parameters:

stream_type (StreamType, optional) – The type of stream to retrieve. Defaults to StreamType.RESULT.

Returns:

The buffered stream object.

Return type:

Stream

Raises:
static get_task(client, task_id)[source]

Returns the task with the given id.

get_total_file_size(stream_type: StreamType) int | None[source]

Returns the total file size for a specific task.

get_total_lines(stream_type: StreamType) int | None[source]

Returns the total file size for a specific task.

has_errors() bool[source]

Returns whether the task has errors.

has_result() bool[source]

Returns whether the task has a result.

property metadata

Returns the metadata of the task.

property name

Returns the name of the task.

property organization

Returns the organization of the task.

property result

Returns the result of the task.

property result_url

Returns the result URL of the task.

property status

Returns the status of the task.

property type

Returns the type of the task.

property uid

Returns the uid of the task.

property updated_at

Returns the last time the task was updated.

wait_till_done(timeout_seconds: int = 7200) None[source]

Waits until the task is done.

class labelbox.schema.export_task.FileConverter(file_path: str)[source]

Bases: Converter[FileConverterOutput]

Converts data to a file.

convert(input_args: ConverterInputArgs) Iterator[FileConverterOutput][source]

Converts the data. Returns an iterator that yields the converted data.

Parameters:
  • current_offset – The global offset indicating the position of the data within the exported files. It represents a cumulative offset in characters across multiple files.

  • raw_data – The raw data to convert.

Yields:

Iterator[OutputT] – The converted data.

class labelbox.schema.export_task.FileConverterOutput(file_path: Path, total_size: int, total_lines: int, current_offset: int, current_line: int, bytes_written: int)[source]

Bases: object

Output with statistics about the written file.

class labelbox.schema.export_task.JsonConverter[source]

Bases: Converter[JsonConverterOutput]

Converts JSON data.

Deprecated: This converter is deprecated and will be removed in a future release.

convert(input_args: ConverterInputArgs) Iterator[JsonConverterOutput][source]

Converts the data. Returns an iterator that yields the converted data.

Parameters:
  • current_offset – The global offset indicating the position of the data within the exported files. It represents a cumulative offset in characters across multiple files.

  • raw_data – The raw data to convert.

Yields:

Iterator[OutputT] – The converted data.

class labelbox.schema.export_task.JsonConverterOutput(current_offset: int, current_line: int, json_str: str)[source]

Bases: object

Output with the JSON string.

class labelbox.schema.export_task.Stream(ctx: _TaskContext, reader: _Reader, converter: Converter)[source]

Bases: Generic[OutputT]

Streams data from a Reader.

start(stream_handler: Callable[[OutputT], None] | None = None) None[source]

Starts streaming the result data. Calls the stream_handler for each result.

with_line(line: int) Stream[OutputT][source]

Sets the line number for the stream.

with_offset(offset: int) Stream[OutputT][source]

Sets the offset for the stream.

class labelbox.schema.export_task.StreamType(value)[source]

Bases: Enum

The type of the stream.