tensorbay.client.segment#

The segment of remote dataset on TensorBay.

class tensorbay.client.segment.SegmentClientBase(name, dataset_client)[source]#

Bases: object

This class defines the basic concept of SegmentClient.

A SegmentClientBase contains the information needed for determining

a unique segment in a dataset on TensorBay.

Parameters
Return type

None

name#

Segment name.

status#

The status of the dataset client.

upload_label(data)[source]#

Upload label with Data object to the draft.

Parameters

data (Union[tensorbay.dataset.data.Data, tensorbay.dataset.data.RemoteData, tensorbay.dataset.data.AuthData, Iterable[Union[tensorbay.dataset.data.Data, tensorbay.dataset.data.RemoteData, tensorbay.dataset.data.AuthData]]]) – The data object which represents the local file to upload.

Return type

None

class tensorbay.client.segment.SegmentClient(name, data_client)[source]#

Bases: tensorbay.client.segment.SegmentClientBase

This class defines SegmentClient.

SegmentClient inherits from SegmentClientBase and provides methods within a segment scope, such as upload_label(), upload_data(), list_data() and so on. In contrast to FusionSegmentClient, SegmentClient has only one sensor.

Parameters
Return type

None

upload_file(local_path, target_remote_path='')[source]#

Upload data with local path to the draft.

Parameters
  • local_path (str) – The local path of the data to upload.

  • target_remote_path (str) – The path to save the data in segment client.

Return type

None

upload_data(data)[source]#

Upload Data object to the draft.

Parameters

data (tensorbay.dataset.data.Data) – The Data.

Return type

None

import_auth_data(data)[source]#

Import AuthData object to the draft.

Parameters

data (tensorbay.dataset.data.AuthData) – The Data.

Return type

None

copy_data(source_remote_paths, target_remote_paths=None, *, source_client=None, strategy='abort')[source]#

Copy data to this segment.

Parameters
  • source_remote_paths (Union[str, Iterable[str]]) – The source remote paths of the copied data.

  • target_remote_paths (Union[None, str, Iterable[str]]) – The target remote paths of the copied data. This argument is used to specify new remote paths of the copied data. If None, the remote path of the copied data will not be changed after copy.

  • source_client (Optional[tensorbay.client.segment.SegmentClient]) – The source segment client of the copied data. This argument is used to specifies where the copied data comes from when the copied data is from another commit, draft, segment or even another dataset. If None, the copied data comes from this segment.

  • strategy (str) –

    The strategy of handling the name conflict. There are three options:

    1. ”abort”: stop copying and raise exception;

    2. ”override”: the source data will override the origin data;

    3. ”skip”: keep the origin data.

Raises
  • InvalidParamsError – When strategy is invalid.

  • ValueError – When the type of target_remote_paths is not equal with source_remote_paths.

Return type

None

move_data(source_remote_paths, target_remote_paths=None, *, source_client=None, strategy='abort')[source]#

Move data to this segment, also used to rename data.

Parameters
  • source_remote_paths (Union[str, Iterable[str]]) – The source remote paths of the moved data.

  • target_remote_paths (Union[None, str, Iterable[str]]) – The target remote paths of the moved data. This argument is used to specify new remote paths of the moved data. If None, the remote path of the moved data will not be changed after copy.

  • source_client (Optional[tensorbay.client.segment.SegmentClient]) – The source segment client of the moved data. This argument is used to specifies where the moved data comes from when the moved data is from another segment. If None, the moved data comes from this segment.

  • strategy (str) –

    The strategy of handling the name conflict. There are three options:

    1. ”abort”: stop copying and raise exception;

    2. ”override”: the source data will override the origin data;

    3. ”skip”: keep the origin data.

Raises
  • InvalidParamsError – When strategy is invalid.

  • ValueError – When the type or the length of target_remote_paths is not equal with source_remote_paths. Or when the dataset_id and drafter_number of source_client is not equal with the current segment client.

Return type

None

list_data_paths()[source]#

List required data path in a segment in a certain commit.

Returns

The PagingList of data paths.

Return type

tensorbay.client.lazy.PagingList[str]

get_data(remote_path)[source]#

Get required Data object from a dataset segment.

Parameters

remote_path (str) – The remote paths of the required data.

Returns

RemoteData.

Raises

ResourceNotExistError – When the required data does not exist.

Return type

tensorbay.dataset.data.RemoteData

list_data()[source]#

List required Data object in a dataset segment.

Returns

The PagingList of RemoteData.

Return type

tensorbay.client.lazy.PagingList[tensorbay.dataset.data.RemoteData]

delete_data(remote_path)[source]#

Delete data of a segment in a certain commit with the given remote paths.

Parameters

remote_path (str) – The remote path of data in a segment.

Return type

None

list_urls()[source]#

List the data urls in this segment.

Returns

The PagingList of urls.

Return type

tensorbay.client.lazy.PagingList[str]

list_mask_urls(mask_type)[source]#

List the mask urls in this segment.

Parameters

mask_type (str) – The required mask type, the supported types are SEMANTIC_MASK, INSTANCE_MASK and PANOPTIC_MASK

Returns

The PagingList of mask urls.

Return type

tensorbay.client.lazy.PagingList[Optional[str]]

class tensorbay.client.segment.FusionSegmentClient(name, data_client)[source]#

Bases: tensorbay.client.segment.SegmentClientBase

This class defines FusionSegmentClient.

FusionSegmentClient inherits from SegmentClientBase and provides methods within a fusion segment scope, such as FusionSegmentClient.upload_sensor(), FusionSegmentClient.upload_frame() and FusionSegmentClient.list_frames().

In contrast to SegmentClient, FusionSegmentClient has multiple sensors.

Parameters
Return type

None

get_sensors()[source]#

Return the sensors in a fusion segment client.

Returns

The sensors in the fusion segment client.

Return type

tensorbay.sensor.sensor.Sensors

upload_sensor(sensor)[source]#

Upload sensor to the draft.

Parameters

sensor (tensorbay.sensor.sensor.Sensor) – The sensor to upload.

Return type

None

delete_sensor(sensor_name)[source]#

Delete a TensorBay sensor of the draft with the given sensor name.

Parameters

sensor_name (str) – The TensorBay sensor to delete.

Return type

None

upload_frame(frame, timestamp=None)[source]#

Upload frame to the draft.

Parameters
Raises

FrameError – When lacking frame id or frame id conflicts.

Return type

None

list_frames()[source]#

List required frames in the segment in a certain commit.

Returns

The PagingList of Frame.

Return type

tensorbay.client.lazy.PagingList[tensorbay.dataset.frame.Frame]

delete_frame(frame_id)[source]#

Delete a frame of a segment in a certain commit with the given frame id.

Parameters

frame_id (Union[str, ulid.ulid.ULID]) – The id of a frame in a segment.

Return type

None

list_urls()[source]#

List the data urls in this segment.

Returns

The PagingList of url dict, which key is the sensor name, value is the url.

Return type

tensorbay.client.lazy.PagingList[Dict[str, str]]