tensorbay.client.segment¶
SegmentClientBase, SegmentClient and FusionSegmentClient.
The SegmentClient
is a remote concept. It
contains the information needed for determining a unique segment in a dataset
on TensorBay, and provides a series of methods within a segment scope,
such as SegmentClient.upload_label()
, SegmentClient.upload_data()
,
SegmentClient.list_data()
and so on.
In contrast to the SegmentClient
,
Segment
is a local concept.
It represents a segment created locally. Please refer to
Segment
for more information.
Similarly to the SegmentClient
, the FusionSegmentClient
represents
the fusion segment in a fusion dataset on TensorBay, and its local counterpart
is FusionSegment
.
Please refer to FusionSegment
for more information.
- class tensorbay.client.segment.SegmentClientBase(name: str, dataset_client: Union[DatasetClient, FusionDatasetClient])[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 – Segment name.
dataset_client – The dataset client.
- name¶
Segment name.
- status¶
The status of the dataset client.
- A
- class tensorbay.client.segment.SegmentClient(name: str, data_client: DatasetClient)[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.- upload_file(local_path: str, target_remote_path: str = '') None [source]¶
Upload data with local path to the draft.
- Parameters
local_path – The local path of the data to upload.
target_remote_path – The path to save the data in segment client.
- upload_label(data: tensorbay.dataset.data.Data) None [source]¶
Upload label with Data object to the draft.
- Parameters
data – The data object which represents the local file to upload.
- upload_data(data: tensorbay.dataset.data.Data) None [source]¶
Upload Data object to the draft.
- Parameters
data – The
Data
.
- import_auth_data(data: tensorbay.dataset.data.AuthData) None [source]¶
Import AuthData object to the draft.
- Parameters
data – The
Data
.
- copy_data(source_remote_paths: Union[str, Iterable[str]], target_remote_paths: Union[None, str, Iterable[str]] = None, *, source_client: Optional[tensorbay.client.segment.SegmentClient] = None, strategy: str = 'abort') None [source]¶
Copy data to this segment.
- Parameters
source_remote_paths – The source remote paths of the copied data.
target_remote_paths – 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 – 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 –
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.
OperationError – When the type of target_remote_paths is not equal with source_remote_paths.
- move_data(source_remote_paths: Union[str, Iterable[str]], target_remote_paths: Union[None, str, Iterable[str]] = None, *, source_client: Optional[tensorbay.client.segment.SegmentClient] = None, strategy: str = 'abort') None [source]¶
Move data to this segment, also used to rename data.
- Parameters
source_remote_paths – The source remote paths of the moved data.
target_remote_paths – 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 – 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 –
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.
OperationError – 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.
- list_data_paths() tensorbay.client.lazy.PagingList[str] [source]¶
List required data path in a segment in a certain commit.
- Returns
The PagingList of data paths.
- list_data() tensorbay.client.lazy.PagingList[tensorbay.dataset.data.RemoteData] [source]¶
List required Data object in a dataset segment.
- Returns
The PagingList of
RemoteData
.
- list_urls() tensorbay.client.lazy.PagingList[str] [source]¶
List the data urls in this segment.
- Returns
The PagingList of urls.
- list_mask_urls(mask_type: str) tensorbay.client.lazy.PagingList[str] [source]¶
List the mask urls in this segment.
- Parameters
mask_type – The required mask type, the supported types are
SEMANTIC_MASK
,INSTANCE_MASK
andPANOPTIC_MASK
- Returns
The PagingList of mask urls.
- class tensorbay.client.segment.FusionSegmentClient(name: str, data_client: FusionDatasetClient)[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.- get_sensors() tensorbay.sensor.sensor.Sensors [source]¶
Return the sensors in a fusion segment client.
- Returns
The
sensors
in the fusion segment client.
- upload_sensor(sensor: tensorbay.sensor.sensor.Sensor) None [source]¶
Upload sensor to the draft.
- Parameters
sensor – The sensor to upload.
- delete_sensor(sensor_name: str) None [source]¶
Delete a TensorBay sensor of the draft with the given sensor name.
- Parameters
sensor_name – The TensorBay sensor to delete.
- upload_frame(frame: tensorbay.dataset.frame.Frame, timestamp: Optional[float] = None) None [source]¶
Upload frame to the draft.
- Parameters
frame – The
Frame
to upload.timestamp – The mark to sort frames, supporting timestamp and float.
- Raises
FrameError – When lacking frame id or frame id conflicts.
- list_frames() tensorbay.client.lazy.PagingList[tensorbay.dataset.frame.Frame] [source]¶
List required frames in the segment in a certain commit.
- Returns
The PagingList of
Frame
.
- list_urls() tensorbay.client.lazy.PagingList[Dict[str, str]] [source]¶
List the data urls in this segment.
- Returns
The PagingList of url dict, which key is the sensor name, value is the url.