|
35 | 35 | BACKFILL_JOB_KEY, |
36 | 36 | DATASET_ID_KEY, |
37 | 37 | DATASET_IS_SCENE_KEY, |
| 38 | + DATASET_ITEM_IDS_KEY, |
38 | 39 | DATASET_ITEMS_KEY, |
39 | 40 | DEFAULT_ANNOTATION_UPDATE_MODE, |
40 | 41 | EMBEDDING_DIMENSION_KEY, |
|
47 | 48 | KEEP_HISTORY_KEY, |
48 | 49 | MESSAGE_KEY, |
49 | 50 | NAME_KEY, |
| 51 | + OBJECT_IDS_KEY, |
50 | 52 | REFERENCE_IDS_KEY, |
51 | 53 | REQUEST_ID_KEY, |
| 54 | + SCENE_IDS_KEY, |
52 | 55 | SLICE_ID_KEY, |
53 | 56 | TRACK_REFERENCE_IDS_KEY, |
54 | 57 | TRACKS_KEY, |
@@ -895,6 +898,51 @@ def create_slice( |
895 | 898 | ) |
896 | 899 | return Slice(response[SLICE_ID_KEY], self._client) |
897 | 900 |
|
| 901 | + def create_slice_by_ids( |
| 902 | + self, |
| 903 | + name: str, |
| 904 | + dataset_item_ids: Optional[List[str]] = None, |
| 905 | + scene_ids: Optional[List[str]] = None, |
| 906 | + annotation_ids: Optional[List[str]] = None, |
| 907 | + prediction_ids: Optional[List[str]] = None, |
| 908 | + ) -> Slice: |
| 909 | + """Creates a :class:`Slice` of dataset items, scenes, annotations, or predictions within a dataset by their IDs. |
| 910 | +
|
| 911 | + .. note:: |
| 912 | + Dataset item, scene, and object (annotation or prediction) IDs may not be mixed. |
| 913 | + However, when creating an object slice, both annotation and prediction IDs may be supplied. |
| 914 | +
|
| 915 | + Parameters: |
| 916 | + name: A human-readable name for the slice. |
| 917 | + dataset_item_ids: List of internal IDs of dataset items to add to the slice:: |
| 918 | + scene_ids: List of internal IDs of scenes to add to the slice:: |
| 919 | + annotation_ids: List of internal IDs of Annotations to add to the slice:: |
| 920 | + prediction_ids: List of internal IDs of Predictions to add to the slice:: |
| 921 | +
|
| 922 | + Returns: |
| 923 | + :class:`Slice`: The newly constructed slice item. |
| 924 | + """ |
| 925 | + if ( |
| 926 | + not dataset_item_ids |
| 927 | + and not scene_ids |
| 928 | + and not annotation_ids |
| 929 | + and not prediction_ids |
| 930 | + ): |
| 931 | + raise Exception("Must provide at least one list of internal IDs") |
| 932 | + payload = { |
| 933 | + NAME_KEY: name, |
| 934 | + DATASET_ITEM_IDS_KEY: dataset_item_ids |
| 935 | + if dataset_item_ids |
| 936 | + else None, |
| 937 | + SCENE_IDS_KEY: scene_ids if scene_ids else None, |
| 938 | + OBJECT_IDS_KEY: [*(annotation_ids or []), *(prediction_ids or [])] |
| 939 | + or None, |
| 940 | + } |
| 941 | + response = self._client.make_request( |
| 942 | + payload, f"dataset/{self.id}/create_slice" |
| 943 | + ) |
| 944 | + return Slice(response[SLICE_ID_KEY], self._client) |
| 945 | + |
898 | 946 | def build_slice( |
899 | 947 | self, |
900 | 948 | name: str, |
|
0 commit comments