@@ -846,11 +846,19 @@ def get_frame_number(self, image_hash: str) -> Optional[int]:
846846 raise LabelRowError ("This function is only supported for label rows of image or image group data types." )
847847 return self ._label_row_read_only_data .image_hash_to_frame [image_hash ]
848848
849- def _get_spaces (self ) -> list [Space ]:
849+ def get_spaces (self ) -> list [Space ]:
850+ """Retrieves all spaces in the data unit.
851+
852+ Use this to view the available spaces. To work on a specific space, we
853+ recommend using `LabelRowV2.get_space()`.
854+
855+ Returns:
856+ A list of all Space objects.
857+ """
850858 return list (self ._space_map .values ())
851859
852860 @overload
853- def _get_space (
861+ def get_space (
854862 self ,
855863 * ,
856864 id : str ,
@@ -859,74 +867,74 @@ def _get_space(
859867 pass
860868
861869 @overload
862- def _get_space (self , * , id : str , type_ : Literal ["image" ]) -> ImageSpace :
870+ def get_space (self , * , id : str , type_ : Literal ["image" ]) -> ImageSpace :
863871 pass
864872
865873 @overload
866- def _get_space (self , * , id : str , type_ : Literal ["image_sequence" ]) -> VideoSpace :
874+ def get_space (self , * , id : str , type_ : Literal ["image_sequence" ]) -> VideoSpace :
867875 pass
868876
869877 @overload
870- def _get_space (self , * , id : str , type_ : Literal ["audio" ]) -> AudioSpace :
878+ def get_space (self , * , id : str , type_ : Literal ["audio" ]) -> AudioSpace :
871879 pass
872880
873881 @overload
874- def _get_space (self , * , id : str , type_ : Literal ["text" ]) -> TextSpace :
882+ def get_space (self , * , id : str , type_ : Literal ["text" ]) -> TextSpace :
875883 pass
876884
877885 @overload
878- def _get_space (self , * , id : str , type_ : Literal ["html" ]) -> HTMLSpace :
886+ def get_space (self , * , id : str , type_ : Literal ["html" ]) -> HTMLSpace :
879887 pass
880888
881889 @overload
882- def _get_space (self , * , id : str , type_ : Literal ["medical_file" ]) -> MedicalFileSpace :
890+ def get_space (self , * , id : str , type_ : Literal ["medical_file" ]) -> MedicalFileSpace :
883891 pass
884892
885893 @overload
886- def _get_space (self , * , id : str , type_ : Literal ["medical_stack" ]) -> MedicalStackSpace :
894+ def get_space (self , * , id : str , type_ : Literal ["medical_stack" ]) -> MedicalStackSpace :
887895 pass
888896
889897 @overload
890- def _get_space (self , * , id : str , type_ : Literal ["pdf" ]) -> PdfSpace :
898+ def get_space (self , * , id : str , type_ : Literal ["pdf" ]) -> PdfSpace :
891899 pass
892900
893901 @overload
894- def _get_space (self , * , layout_key : str , type_ : Literal ["video" ]) -> VideoSpace :
902+ def get_space (self , * , layout_key : str , type_ : Literal ["video" ]) -> VideoSpace :
895903 pass
896904
897905 @overload
898- def _get_space (self , * , layout_key : str , type_ : Literal ["image" ]) -> ImageSpace :
906+ def get_space (self , * , layout_key : str , type_ : Literal ["image" ]) -> ImageSpace :
899907 pass
900908
901909 @overload
902- def _get_space (self , * , layout_key : str , type_ : Literal ["image_sequence" ]) -> VideoSpace :
910+ def get_space (self , * , layout_key : str , type_ : Literal ["image_sequence" ]) -> VideoSpace :
903911 pass
904912
905913 @overload
906- def _get_space (self , * , layout_key : str , type_ : Literal ["audio" ]) -> AudioSpace :
914+ def get_space (self , * , layout_key : str , type_ : Literal ["audio" ]) -> AudioSpace :
907915 pass
908916
909917 @overload
910- def _get_space (self , * , layout_key : str , type_ : Literal ["text" ]) -> TextSpace :
918+ def get_space (self , * , layout_key : str , type_ : Literal ["text" ]) -> TextSpace :
911919 pass
912920
913921 @overload
914- def _get_space (self , * , layout_key : str , type_ : Literal ["html" ]) -> HTMLSpace :
922+ def get_space (self , * , layout_key : str , type_ : Literal ["html" ]) -> HTMLSpace :
915923 pass
916924
917925 @overload
918- def _get_space (self , * , layout_key : str , type_ : Literal ["medical_file" ]) -> MedicalFileSpace :
926+ def get_space (self , * , layout_key : str , type_ : Literal ["medical_file" ]) -> MedicalFileSpace :
919927 pass
920928
921929 @overload
922- def _get_space (self , * , layout_key : str , type_ : Literal ["medical_stack" ]) -> MedicalStackSpace :
930+ def get_space (self , * , layout_key : str , type_ : Literal ["medical_stack" ]) -> MedicalStackSpace :
923931 pass
924932
925933 @overload
926- def _get_space (self , * , layout_key : str , type_ : Literal ["pdf" ]) -> PdfSpace :
934+ def get_space (self , * , layout_key : str , type_ : Literal ["pdf" ]) -> PdfSpace :
927935 pass
928936
929- def _get_space (
937+ def get_space (
930938 self ,
931939 * ,
932940 id : Optional [str ] = None ,
@@ -935,9 +943,6 @@ def _get_space(
935943 ) -> Space :
936944 """Retrieves a single space which matches the specified id and type.
937945
938- **BETA**: This feature is in beta. The Space API is experimental and may change
939- in future versions. Use with caution in production environments.
940-
941946 Throws an exception if more than one or no space with the specified id and type is found.
942947
943948 Args:
@@ -2658,47 +2663,47 @@ def _parse_space_labels(
26582663 ) -> None :
26592664 for space_id , space_info in spaces_info .items ():
26602665 if space_info ["space_type" ] == SpaceType .VIDEO :
2661- video_space = self ._get_space (id = space_id , type_ = "video" )
2666+ video_space = self .get_space (id = space_id , type_ = "video" )
26622667 video_space ._parse_space_dict (
26632668 space_info , object_answers = object_answers , classification_answers = classification_answers
26642669 )
26652670 elif space_info ["space_type" ] == SpaceType .IMAGE :
2666- image_space = self ._get_space (id = space_id , type_ = "image" )
2671+ image_space = self .get_space (id = space_id , type_ = "image" )
26672672 image_space ._parse_space_dict (
26682673 space_info , object_answers = object_answers , classification_answers = classification_answers
26692674 )
26702675 elif space_info ["space_type" ] == SpaceType .IMAGE_SEQUENCE :
2671- image_sequence_space = self ._get_space (id = space_id , type_ = "image_sequence" )
2676+ image_sequence_space = self .get_space (id = space_id , type_ = "image_sequence" )
26722677 image_sequence_space ._parse_space_dict (
26732678 space_info , object_answers = object_answers , classification_answers = classification_answers
26742679 )
26752680 elif space_info ["space_type" ] == SpaceType .AUDIO :
2676- audio_space = self ._get_space (id = space_id , type_ = "audio" )
2681+ audio_space = self .get_space (id = space_id , type_ = "audio" )
26772682 audio_space ._parse_space_dict (
26782683 space_info , object_answers = object_answers , classification_answers = classification_answers
26792684 )
26802685 elif space_info ["space_type" ] == SpaceType .TEXT :
2681- text_space = self ._get_space (id = space_id , type_ = "text" )
2686+ text_space = self .get_space (id = space_id , type_ = "text" )
26822687 text_space ._parse_space_dict (
26832688 space_info , object_answers = object_answers , classification_answers = classification_answers
26842689 )
26852690 elif space_info ["space_type" ] == SpaceType .HTML :
2686- html_space = self ._get_space (id = space_id , type_ = "html" )
2691+ html_space = self .get_space (id = space_id , type_ = "html" )
26872692 html_space ._parse_space_dict (
26882693 space_info , object_answers = object_answers , classification_answers = classification_answers
26892694 )
26902695 elif space_info ["space_type" ] == SpaceType .MEDICAL_FILE :
2691- medical_file_space = self ._get_space (id = space_id , type_ = "medical_file" )
2696+ medical_file_space = self .get_space (id = space_id , type_ = "medical_file" )
26922697 medical_file_space ._parse_space_dict (
26932698 space_info , object_answers = object_answers , classification_answers = classification_answers
26942699 )
26952700 elif space_info ["space_type" ] == SpaceType .MEDICAL_STACK :
2696- medical_stack_space = self ._get_space (id = space_id , type_ = "medical_stack" )
2701+ medical_stack_space = self .get_space (id = space_id , type_ = "medical_stack" )
26972702 medical_stack_space ._parse_space_dict (
26982703 space_info , object_answers = object_answers , classification_answers = classification_answers
26992704 )
27002705 elif space_info ["space_type" ] == SpaceType .PDF :
2701- pdf_space = self ._get_space (id = space_id , type_ = "pdf" )
2706+ pdf_space = self .get_space (id = space_id , type_ = "pdf" )
27022707 pdf_space ._parse_space_dict (
27032708 space_info , object_answers = object_answers , classification_answers = classification_answers
27042709 )
@@ -3011,7 +3016,7 @@ def _add_action_answers(self, label_row_dict: dict):
30113016 if space_id is None :
30123017 raise LabelRowError ("Object action does not contain spaceId" )
30133018
3014- space = self ._get_space (id = space_id , type_ = "video" )
3019+ space = self .get_space (id = space_id , type_ = "video" )
30153020 space ._set_answer_from_list (object_hash , answers_list = [answer_dict ])
30163021
30173022 def _create_new_object_instance (self , frame_object_label : FrameObject , frame : int ) -> ObjectInstance :
0 commit comments