|
33 | 33 | from labelbox.schema.identifiable import DataRowIdentifier, GlobalKey, UniqueId |
34 | 34 | from labelbox.schema.identifiables import DataRowIdentifiers, UniqueIds |
35 | 35 | from labelbox.schema.media_type import MediaType |
| 36 | +from labelbox.schema.project_model_config import ProjectModelConfig |
36 | 37 | from labelbox.schema.queue_mode import QueueMode |
37 | 38 | from labelbox.schema.resource_tag import ResourceTag |
38 | 39 | from labelbox.schema.task import Task |
@@ -136,6 +137,28 @@ class Project(DbObject, Updateable, Deletable): |
136 | 137 | def is_chat_evaluation(self) -> bool: |
137 | 138 | return self.media_type == MediaType.Conversational and self.editor_task_type == EditorTaskType.ModelChatEvaluation |
138 | 139 |
|
| 140 | + def project_model_configs(self): |
| 141 | + query_str = """query ProjectModelConfigsPyApi($id: ID!) { |
| 142 | + project(where: {id : $id}) { |
| 143 | + projectModelConfigs { |
| 144 | + id |
| 145 | + modelConfigId |
| 146 | + modelConfig { |
| 147 | + id |
| 148 | + modelId |
| 149 | + inferenceParams |
| 150 | + } |
| 151 | + projectId |
| 152 | + } |
| 153 | + } |
| 154 | + }""" |
| 155 | + data = {"id": self.uid} |
| 156 | + res = self.client.execute(query_str, data) |
| 157 | + return [ |
| 158 | + ProjectModelConfig(self.client, projectModelConfig) |
| 159 | + for projectModelConfig in res["project"]["projectModelConfigs"] |
| 160 | + ] |
| 161 | + |
139 | 162 | def update(self, **kwargs): |
140 | 163 | """ Updates this project with the specified attributes |
141 | 164 |
|
@@ -1226,6 +1249,50 @@ def get_queue_mode(self) -> "QueueMode": |
1226 | 1249 | else: |
1227 | 1250 | raise ValueError("Status not known") |
1228 | 1251 |
|
| 1252 | + def add_model_config(self, model_config_id: str) -> str: |
| 1253 | + """ Adds a model config to this project. |
| 1254 | +
|
| 1255 | + Args: |
| 1256 | + model_config_id (str): ID of a model config to add to this project. |
| 1257 | +
|
| 1258 | + Returns: |
| 1259 | + str, ID of the project model config association. This is needed for updating and deleting associations. |
| 1260 | + """ |
| 1261 | + |
| 1262 | + query = """mutation CreateProjectModelConfigPyApi($projectId: ID!, $modelConfigId: ID!) { |
| 1263 | + createProjectModelConfig(input: {projectId: $projectId, modelConfigId: $modelConfigId}) { |
| 1264 | + projectModelConfigId |
| 1265 | + } |
| 1266 | + }""" |
| 1267 | + |
| 1268 | + params = { |
| 1269 | + "projectId": self.uid, |
| 1270 | + "modelConfigId": model_config_id, |
| 1271 | + } |
| 1272 | + result = self.client.execute(query, params) |
| 1273 | + return result["createProjectModelConfig"]["projectModelConfigId"] |
| 1274 | + |
| 1275 | + def delete_project_model_config(self, project_model_config_id: str) -> bool: |
| 1276 | + """ Deletes the association between a model config and this project. |
| 1277 | +
|
| 1278 | + Args: |
| 1279 | + project_model_config_id (str): ID of a project model config association to delete for this project. |
| 1280 | +
|
| 1281 | + Returns: |
| 1282 | + bool, indicates if the operation was a success. |
| 1283 | + """ |
| 1284 | + query = """mutation DeleteProjectModelConfigPyApi($id: ID!) { |
| 1285 | + deleteProjectModelConfig(input: {id: $id}) { |
| 1286 | + success |
| 1287 | + } |
| 1288 | + }""" |
| 1289 | + |
| 1290 | + params = { |
| 1291 | + "id": project_model_config_id, |
| 1292 | + } |
| 1293 | + result = self.client.execute(query, params) |
| 1294 | + return result["deleteProjectModelConfig"]["success"] |
| 1295 | + |
1229 | 1296 | def set_labeling_parameter_overrides( |
1230 | 1297 | self, data: List[LabelingParameterOverrideInput]) -> bool: |
1231 | 1298 | """ Adds labeling parameter overrides to this project. |
|
0 commit comments