Skip to content

Commit c295f32

Browse files
author
Val Brodsky
committed
Add Project set_project_model_setup_complete
1 parent 10840ce commit c295f32

File tree

2 files changed

+35
-14
lines changed

2 files changed

+35
-14
lines changed

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

Lines changed: 33 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,9 @@
1313

1414
from labelbox import parser
1515
from labelbox import utils
16-
from labelbox.exceptions import (
17-
InvalidQueryError,
18-
LabelboxError,
19-
ProcessingWaitTimeout,
20-
ResourceConflict,
21-
ResourceNotFoundError
22-
)
16+
from labelbox.exceptions import (InvalidQueryError, LabelboxError,
17+
ProcessingWaitTimeout, ResourceConflict,
18+
ResourceNotFoundError)
2319
from labelbox.orm import query
2420
from labelbox.orm.db_object import DbObject, Deletable, Updateable, experimental
2521
from labelbox.orm.model import Entity, Field, Relationship
@@ -122,6 +118,7 @@ class Project(DbObject, Updateable, Deletable):
122118
media_type = Field.Enum(MediaType, "media_type", "allowedMediaType")
123119
editor_task_type = Field.Enum(EditorTaskType, "editor_task_type")
124120
data_row_count = Field.Int("data_row_count")
121+
model_setup_complete: Field = Field.Boolean("model_setup_complete")
125122

126123
# Relationships
127124
created_by = Relationship.ToOne("User", False, "created_by")
@@ -1299,6 +1296,24 @@ def delete_project_model_config(self, project_model_config_id: str) -> bool:
12991296
raise ResourceNotFoundError(ProjectModelConfig, params)
13001297
return result["deleteProjectModelConfig"]["success"]
13011298

1299+
def set_project_model_setup_complete(self) -> bool:
1300+
""" Checks if the model setup is complete for this project.
1301+
1302+
Returns:
1303+
bool, indicates if the model setup is complete.
1304+
"""
1305+
query = """query ModelSetupCompletePyApi($projectId: ID!) {
1306+
project(where: {id: $projectId}, data: {modelSetupComplete: true}) {
1307+
modelSetupComplete
1308+
}
1309+
}"""
1310+
1311+
result = self.client.execute(query, {"projectId": self.uid})
1312+
1313+
self.update(
1314+
model_setup_complete=result["project"]["modelSetupComplete"])
1315+
return result["project"]["modelSetupComplete"]
1316+
13021317
def set_labeling_parameter_overrides(
13031318
self, data: List[LabelingParameterOverrideInput]) -> bool:
13041319
""" Adds labeling parameter overrides to this project.
@@ -1752,7 +1767,9 @@ def __check_data_rows_have_been_processed(
17521767
return response["queryAllDataRowsHaveBeenProcessed"][
17531768
"allDataRowsHaveBeenProcessed"]
17541769

1755-
def get_overview(self, details=False) -> Union[ProjectOverview, ProjectOverviewDetailed]:
1770+
def get_overview(
1771+
self,
1772+
details=False) -> Union[ProjectOverview, ProjectOverviewDetailed]:
17561773
"""Return the overview of a project.
17571774
17581775
This method returns the number of data rows per task queue and issues of a project,
@@ -1792,7 +1809,7 @@ def get_overview(self, details=False) -> Union[ProjectOverview, ProjectOverviewD
17921809

17931810
# Must use experimental to access "issues"
17941811
result = self.client.execute(query, {"projectId": self.uid},
1795-
experimental=True)["project"]
1812+
experimental=True)["project"]
17961813

17971814
# Reformat category names
17981815
overview = {
@@ -1805,26 +1822,28 @@ def get_overview(self, details=False) -> Union[ProjectOverview, ProjectOverviewD
18051822

18061823
# Rename categories
18071824
overview["to_label"] = overview.pop("unlabeled")
1808-
overview["total_data_rows"] = overview.pop("all")
1825+
overview["total_data_rows"] = overview.pop("all")
18091826

18101827
if not details:
18111828
return ProjectOverview(**overview)
18121829
else:
18131830
# Build dictionary for queue details for review and rework queues
18141831
for category in ["rework", "review"]:
18151832
queues = [
1816-
{tq["name"]: tq.get("dataRowCount")}
1833+
{
1834+
tq["name"]: tq.get("dataRowCount")
1835+
}
18171836
for tq in result.get("taskQueues")
18181837
if tq.get("queueType") == f"MANUAL_{category.upper()}_QUEUE"
18191838
]
18201839

1821-
overview[f"in_{category}"] = {
1840+
overview[f"in_{category}"] = {
18221841
"data": queues,
18231842
"total": overview[f"in_{category}"]
18241843
}
1825-
1844+
18261845
return ProjectOverviewDetailed(**overview)
1827-
1846+
18281847
def clone(self) -> "Project":
18291848
"""
18301849
Clones the current project.

libs/labelbox/tests/integration/test_chat_evaluation_ontology_project.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ def test_create_chat_evaluation_ontology_project(
2424
assert classification.feature_schema_id
2525

2626
project = chat_evaluation_project_create_dataset
27+
assert project.model_setup_complete is None
28+
2729
project.setup_editor(ontology)
2830

2931
assert project.labeling_frontend().name == "Editor"

0 commit comments

Comments
 (0)