Skip to content

Commit bbcc137

Browse files
committed
adding back something that wasn't in my own branch
1 parent 9cabcc5 commit bbcc137

File tree

1 file changed

+35
-0
lines changed

1 file changed

+35
-0
lines changed

labelbox/schema/project.py

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -422,6 +422,41 @@ def review_metrics(self, net_score):
422422
res = self.client.execute(query_str, {id_param: self.uid})
423423
return res["project"]["reviewMetrics"]["labelAggregate"]["count"]
424424

425+
def setup_editor(self, ontology):
426+
"""
427+
Sets up the project using the Pictor editor.
428+
429+
Args:
430+
ontology (Ontology): The ontology to attach to the project
431+
"""
432+
labeling_frontend = next(
433+
self.client.get_labeling_frontends(
434+
where=Entity.LabelingFrontend.name == "Editor"))
435+
self.labeling_frontend.connect(labeling_frontend)
436+
437+
LFO = Entity.LabelingFrontendOptions
438+
self.client._create(
439+
LFO, {
440+
LFO.project:
441+
self,
442+
LFO.labeling_frontend:
443+
labeling_frontend,
444+
LFO.customization_options:
445+
json.dumps({
446+
"tools": [],
447+
"classifications": []
448+
})
449+
})
450+
451+
query_str = """mutation ConnectOntologyPyApi($projectId: ID!, $ontologyId: ID!){
452+
project(where: {id: $projectId}) {connectOntology(ontologyId: $ontologyId) {id}}}"""
453+
self.client.execute(query_str, {
454+
'ontologyId': ontology.uid,
455+
'projectId': self.uid
456+
})
457+
timestamp = datetime.now(timezone.utc).strftime("%Y-%m-%dT%H:%M:%SZ")
458+
self.update(setup_complete=timestamp)
459+
425460
def setup(self, labeling_frontend, labeling_frontend_options):
426461
""" Finalizes the Project setup.
427462

0 commit comments

Comments
 (0)