Skip to content

Commit 209137c

Browse files
author
Val Brodsky
committed
Add docstrings
1 parent 00f8c6d commit 209137c

File tree

3 files changed

+35
-3
lines changed

3 files changed

+35
-3
lines changed

libs/labelbox/src/labelbox/client.py

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -573,6 +573,8 @@ def _create(self, db_object_type, data, extra_params={}):
573573
db_object_type (type): A DbObjectType subtype.
574574
data (dict): Keys are attributes or their names (in Python,
575575
snake-case convention) and values are desired attribute values.
576+
extra_params (dict): Additional parameters to pass to GraphQL.
577+
These have to be Field(...): value pairs.
576578
Returns:
577579
A new object of the given DB object type.
578580
Raises:
@@ -763,6 +765,16 @@ def create_model_evalution_project(self,
763765
append_to_existing_dataset: bool = False,
764766
data_row_count: int = 100,
765767
**kwargs) -> Project:
768+
"""
769+
Use this method exclusively to create a chat model evaluation project.
770+
Args:
771+
dataset_name_or_id: The name or id of the dataset to use for the project
772+
append_to_existing_dataset: If True, the project will append assets (data rows) to the existing dataset
773+
data_row_count: The number of data row assets to use for the project
774+
**kwargs: Additional parameters to pass to the the create_project method
775+
Returns:
776+
Project: The created project
777+
"""
766778
kwargs["media_type"] = MediaType.Conversational
767779
kwargs["ontology_kind"] = OntologyKind.ModelEvaluation
768780
kwargs["dataset_name_or_id"] = dataset_name_or_id
@@ -987,7 +999,9 @@ def create_ontology_from_feature_schemas(
987999
name (str): Name of the ontology
9881000
feature_schema_ids (List[str]): List of feature schema ids corresponding to
9891001
top level tools and classifications to include in the ontology
990-
media_type (MediaType or None): Media type of a new ontology
1002+
media_type (MediaType or None): Media type of a new ontology. NOTE for chat evaluation, we currently foce media_type to Conversational
1003+
ontology_kind (OntologyKind or None): set to OntologyKind.ModelEvaluation if the ontology is for chat evaluation,
1004+
leave as None otherwise.
9911005
Returns:
9921006
The created Ontology
9931007
"""
@@ -1018,6 +1032,15 @@ def create_ontology_from_feature_schemas(
10181032
)
10191033
normalized = {'tools': tools, 'classifications': classifications}
10201034

1035+
if ontology_kind and ontology_kind is OntologyKind.ModelEvaluation:
1036+
if media_type is None:
1037+
media_type = MediaType.Conversational
1038+
else:
1039+
if media_type is not MediaType.Conversational:
1040+
raise ValueError(
1041+
"For chat evaluation, media_type must be Conversational."
1042+
)
1043+
10211044
return self.create_ontology(name=name,
10221045
normalized=normalized,
10231046
media_type=media_type,
@@ -1230,8 +1253,13 @@ def create_ontology(self,
12301253
name (str): Name of the ontology
12311254
normalized (dict): A normalized ontology payload. See above for details.
12321255
media_type (MediaType or None): Media type of a new ontology
1256+
ontology_kind (OntologyKind or None): set to OntologyKind.ModelEvaluation if the ontology is for chat evaluation,
1257+
leave as None otherwise.
1258+
12331259
Returns:
12341260
The created Ontology
1261+
1262+
NOTE caller of this method is expected to set media_type to Conversational if ontology_kind is ModelEvaluation
12351263
"""
12361264

12371265
if media_type:

libs/labelbox/src/labelbox/schema/ontology_kind.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@
55

66

77
class OntologyKind(Enum):
8+
"""
9+
OntologyKind is an enum that represents the different types of ontologies
10+
At the moment it is only limited to ModelEvaluation
11+
"""
812
ModelEvaluation = "MODEL_EVALUATION"
913
Missing = None
1014

libs/labelbox/src/labelbox/schema/project.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -738,8 +738,8 @@ def setup_editor(self, ontology) -> None:
738738
ontology (Ontology): The ontology to attach to the project
739739
"""
740740

741-
if self.labeling_frontend(
742-
) is not None and not self.is_chat_evalution():
741+
if self.labeling_frontend() is not None and not self.is_chat_evalution(
742+
): # Chat evaluation projects are automatically set up via the same api that creates a project
743743
raise ResourceConflict("Editor is already set up.")
744744

745745
if not self.is_chat_evalution():

0 commit comments

Comments
 (0)