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
name (str) – Segment name.
dataset_client (Union[DatasetClient, FusionDatasetClient]) – The dataset client.
- Return type
None
- name¶
Segment name.
- status¶
The status of the dataset client.
- A
- 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
name (str) –
data_client (DatasetClient) –
- 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_label(data)[source]¶
Upload label with Data object to the draft.
- Parameters
data (tensorbay.dataset.data.Data) – The data object which represents the local file to upload.
- 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:
”abort”: stop copying and raise exception;
”override”: the source data will override the origin data;
”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:
”abort”: stop copying and raise exception;
”override”: the source data will override the origin data;
”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
- 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
- Raises
ResourceNotExistError – When the required data does not exist.
- Return type
- 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
- 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
andPANOPTIC_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 fromSegmentClientBase
and provides methods within a fusion segment scope, such asFusionSegmentClient.upload_sensor()
,FusionSegmentClient.upload_frame()
andFusionSegmentClient.list_frames()
.In contrast to
SegmentClient
,FusionSegmentClient
has multiple sensors.- Parameters
name (str) –
data_client (FusionDatasetClient) –
- Return type
None
- get_sensors()[source]¶
Return the sensors in a fusion segment client.
- Returns
The
sensors
in the fusion segment client.- Return type
- 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
frame (tensorbay.dataset.frame.Frame) – The
Frame
to upload.timestamp (Optional[float]) – The mark to sort frames, supporting timestamp and float.
- 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]]