@@ -652,8 +652,7 @@ def delete_model_config(self, id: str) -> bool:
652652 params = {"id" : id }
653653 result = self .execute (query , params )
654654 if not result :
655- raise labelbox .exceptions .ResourceNotFoundError (
656- Entity .ModelConfig , params )
655+ raise labelbox .exceptions .ResourceNotFoundError (Entity .ModelConfig , params )
657656 return result ['deleteModelConfig' ]['success' ]
658657
659658 def create_dataset (self ,
@@ -741,17 +740,85 @@ def create_project(self, **kwargs) -> Project:
741740 Raises:
742741 InvalidAttributeError: If the Project type does not contain
743742 any of the attribute names given in kwargs.
744-
745- NOTE: the following attributes are used only in chat model evaluation projects:
746- dataset_name_or_id, append_to_existing_dataset, data_row_count, editor_task_type
747- They are not used for general projects and not supported in this method
748743 """
749- # The following arguments are not supported for general projects, only for chat model evaluation projects
750- kwargs .pop ("dataset_name_or_id" , None )
751- kwargs .pop ("append_to_existing_dataset" , None )
752- kwargs .pop ("data_row_count" , None )
753- kwargs .pop ("editor_task_type" , None )
754- return self ._create_project (** kwargs )
744+
745+ auto_audit_percentage = kwargs .get ("auto_audit_percentage" )
746+ auto_audit_number_of_labels = kwargs .get ("auto_audit_number_of_labels" )
747+ if auto_audit_percentage is not None or auto_audit_number_of_labels is not None :
748+ raise ValueError (
749+ "quality_mode must be set instead of auto_audit_percentage or auto_audit_number_of_labels."
750+ )
751+
752+ name = kwargs .get ("name" )
753+ if name is None or not name .strip ():
754+ raise ValueError ("project name must be a valid string." )
755+
756+ queue_mode = kwargs .get ("queue_mode" )
757+ if queue_mode is QueueMode .Dataset :
758+ raise ValueError (
759+ "Dataset queue mode is deprecated. Please prefer Batch queue mode."
760+ )
761+ elif queue_mode is QueueMode .Batch :
762+ logger .warning (
763+ "Passing a queue mode of batch is redundant and will soon no longer be supported."
764+ )
765+
766+ media_type = kwargs .get ("media_type" )
767+ if media_type and MediaType .is_supported (media_type ):
768+ media_type_value = media_type .value
769+ elif media_type :
770+ raise TypeError (f"{ media_type } is not a valid media type. Use"
771+ f" any of { MediaType .get_supported_members ()} "
772+ " from MediaType. Example: MediaType.Image." )
773+ else :
774+ logger .warning (
775+ "Creating a project without specifying media_type"
776+ " through this method will soon no longer be supported." )
777+ media_type_value = None
778+
779+ ontology_kind = kwargs .pop ("ontology_kind" , None )
780+ if ontology_kind and OntologyKind .is_supported (ontology_kind ):
781+ editor_task_type_value = EditorTaskTypeMapper .to_editor_task_type (
782+ ontology_kind , media_type ).value
783+ elif ontology_kind :
784+ raise OntologyKind .get_ontology_kind_validation_error (ontology_kind )
785+ else :
786+ editor_task_type_value = None
787+
788+ quality_mode = kwargs .get ("quality_mode" )
789+ if not quality_mode :
790+ logger .info ("Defaulting quality mode to Benchmark." )
791+
792+ data = kwargs
793+ data .pop ("quality_mode" , None )
794+ if quality_mode is None or quality_mode is QualityMode .Benchmark :
795+ data [
796+ "auto_audit_number_of_labels" ] = BENCHMARK_AUTO_AUDIT_NUMBER_OF_LABELS
797+ data ["auto_audit_percentage" ] = BENCHMARK_AUTO_AUDIT_PERCENTAGE
798+ elif quality_mode is QualityMode .Consensus :
799+ data [
800+ "auto_audit_number_of_labels" ] = CONSENSUS_AUTO_AUDIT_NUMBER_OF_LABELS
801+ data ["auto_audit_percentage" ] = CONSENSUS_AUTO_AUDIT_PERCENTAGE
802+ else :
803+ raise ValueError (f"{ quality_mode } is not a valid quality mode." )
804+
805+ params = {** data }
806+ if media_type_value :
807+ params ["media_type" ] = media_type_value
808+ if editor_task_type_value :
809+ params ["editor_task_type" ] = editor_task_type_value
810+
811+ extra_params = {
812+ Field .String ("dataset_name_or_id" ):
813+ params .pop ("dataset_name_or_id" , None ),
814+ Field .Boolean ("append_to_existing_dataset" ):
815+ params .pop ("append_to_existing_dataset" , None ),
816+ Field .Int ("data_row_count" ):
817+ params .pop ("data_row_count" , None ),
818+ }
819+ extra_params = {k : v for k , v in extra_params .items () if v is not None }
820+
821+ return self ._create (Entity .Project , params , extra_params )
755822
756823 @overload
757824 def create_model_evaluation_project (self ,
@@ -814,99 +881,13 @@ def create_model_evaluation_project(self,
814881 dataset_name_or_id = dataset_name
815882
816883 kwargs ["media_type" ] = MediaType .Conversational
884+ kwargs ["ontology_kind" ] = OntologyKind .ModelEvaluation
817885 kwargs ["dataset_name_or_id" ] = dataset_name_or_id
818886 kwargs ["append_to_existing_dataset" ] = append_to_existing_dataset
819887 kwargs ["data_row_count" ] = data_row_count
820- kwargs ["editor_task_type" ] = EditorTaskType .ModelChatEvaluation .value
821-
822- return self ._create_project (** kwargs )
823-
824- def create_offline_model_evaluation_project (self , ** kwargs ) -> Project :
825- """
826- Creates a project for offline model evaluation.
827- Args:
828- **kwargs: Additional parameters to pass see the create_project method
829- Returns:
830- Project: The created project
831- """
832- kwargs [
833- "media_type" ] = MediaType .Conversational # Only Conversational is supported
834- kwargs [
835- "editor_task_type" ] = EditorTaskType .OfflineModelChatEvaluation .value # Special editor task type for offline model evaluation
836-
837- # The following arguments are not supported for offline model evaluation
838- kwargs .pop ("dataset_name_or_id" , None )
839- kwargs .pop ("append_to_existing_dataset" , None )
840- kwargs .pop ("data_row_count" , None )
841888
842889 return self .create_project (** kwargs )
843890
844- def _create_project (self , ** kwargs ) -> Project :
845- auto_audit_percentage = kwargs .get ("auto_audit_percentage" )
846- auto_audit_number_of_labels = kwargs .get ("auto_audit_number_of_labels" )
847- if auto_audit_percentage is not None or auto_audit_number_of_labels is not None :
848- raise ValueError (
849- "quality_mode must be set instead of auto_audit_percentage or auto_audit_number_of_labels."
850- )
851-
852- name = kwargs .get ("name" )
853- if name is None or not name .strip ():
854- raise ValueError ("project name must be a valid string." )
855-
856- queue_mode = kwargs .get ("queue_mode" )
857- if queue_mode is QueueMode .Dataset :
858- raise ValueError (
859- "Dataset queue mode is deprecated. Please prefer Batch queue mode."
860- )
861- elif queue_mode is QueueMode .Batch :
862- logger .warning (
863- "Passing a queue mode of batch is redundant and will soon no longer be supported."
864- )
865-
866- media_type = kwargs .get ("media_type" )
867- if media_type and MediaType .is_supported (media_type ):
868- media_type_value = media_type .value
869- elif media_type :
870- raise TypeError (f"{ media_type } is not a valid media type. Use"
871- f" any of { MediaType .get_supported_members ()} "
872- " from MediaType. Example: MediaType.Image." )
873- else :
874- logger .warning (
875- "Creating a project without specifying media_type"
876- " through this method will soon no longer be supported." )
877- media_type_value = None
878-
879- quality_mode = kwargs .get ("quality_mode" )
880- if not quality_mode :
881- logger .info ("Defaulting quality mode to Benchmark." )
882-
883- data = kwargs
884- data .pop ("quality_mode" , None )
885- if quality_mode is None or quality_mode is QualityMode .Benchmark :
886- data [
887- "auto_audit_number_of_labels" ] = BENCHMARK_AUTO_AUDIT_NUMBER_OF_LABELS
888- data ["auto_audit_percentage" ] = BENCHMARK_AUTO_AUDIT_PERCENTAGE
889- elif quality_mode is QualityMode .Consensus :
890- data [
891- "auto_audit_number_of_labels" ] = CONSENSUS_AUTO_AUDIT_NUMBER_OF_LABELS
892- data ["auto_audit_percentage" ] = CONSENSUS_AUTO_AUDIT_PERCENTAGE
893- else :
894- raise ValueError (f"{ quality_mode } is not a valid quality mode." )
895-
896- params = {** data }
897- if media_type_value :
898- params ["media_type" ] = media_type_value
899-
900- extra_params = {
901- Field .String ("dataset_name_or_id" ):
902- params .pop ("dataset_name_or_id" , None ),
903- Field .Boolean ("append_to_existing_dataset" ):
904- params .pop ("append_to_existing_dataset" , None ),
905- }
906- extra_params = {k : v for k , v in extra_params .items () if v is not None }
907-
908- return self ._create (Entity .Project , params , extra_params )
909-
910891 def get_roles (self ) -> List [Role ]:
911892 """
912893 Returns:
0 commit comments