@@ -151,8 +151,9 @@ def labels(self, datasets=None, order_by=None):
151
151
id_param , id_param , where , order_by_str ,
152
152
query .results_query_part (Label ))
153
153
154
- return PaginatedCollection (self .client , query_str , {id_param : self .uid },
155
- ["project" , "labels" ], Label )
154
+ return PaginatedCollection (self .client , query_str ,
155
+ {id_param : self .uid }, ["project" , "labels" ],
156
+ Label )
156
157
157
158
def export_queued_data_rows (self , timeout_seconds = 120 ):
158
159
""" Returns all data rows that are currently enqueued for this project.
@@ -346,7 +347,7 @@ def upsert_instructions(self, instructions_file: str):
346
347
347
348
lfo = list (self .labeling_frontend_options ())[- 1 ]
348
349
instructions_url = self .client .upload_file (instructions_file )
349
- customization_options = json . loads ( lfo . customization_options )
350
+ customization_options = self . ontology (). normalized
350
351
customization_options ['projectInstructions' ] = instructions_url
351
352
option_id = lfo .uid
352
353
@@ -393,11 +394,13 @@ def create_labeler_performance(client, result):
393
394
# python isoformat doesn't accept Z as utc timezone
394
395
result ["lastActivityTime" ] = datetime .fromisoformat (
395
396
result ["lastActivityTime" ].replace ('Z' , '+00:00' ))
396
- return LabelerPerformance (
397
- **
398
- {utils .snake_case (key ): value for key , value in result .items ()})
397
+ return LabelerPerformance (** {
398
+ utils .snake_case (key ): value
399
+ for key , value in result .items ()
400
+ })
399
401
400
- return PaginatedCollection (self .client , query_str , {id_param : self .uid },
402
+ return PaginatedCollection (self .client , query_str ,
403
+ {id_param : self .uid },
401
404
["project" , "labelerPerformance" ],
402
405
create_labeler_performance )
403
406
@@ -409,7 +412,7 @@ def review_metrics(self, net_score):
409
412
Returns:
410
413
int, aggregation count of reviews for given `net_score`.
411
414
"""
412
- if net_score not in (None ,) + tuple (Entity .Review .NetScore ):
415
+ if net_score not in (None , ) + tuple (Entity .Review .NetScore ):
413
416
raise InvalidQueryError (
414
417
"Review metrics net score must be either None "
415
418
"or one of Review.NetScore values" )
@@ -422,41 +425,6 @@ def review_metrics(self, net_score):
422
425
res = self .client .execute (query_str , {id_param : self .uid })
423
426
return res ["project" ]["reviewMetrics" ]["labelAggregate" ]["count" ]
424
427
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
-
460
428
def setup (self , labeling_frontend , labeling_frontend_options ):
461
429
""" Finalizes the Project setup.
462
430
@@ -516,7 +484,7 @@ def _post_batch(self, method, data_row_ids: List[str]):
516
484
}
517
485
}
518
486
}
519
- }
487
+ }
520
488
""" % (method , method )
521
489
522
490
res = self .client .execute (query , {
@@ -552,7 +520,7 @@ def _update_queue_mode(self, mode: QueueMode) -> QueueMode:
552
520
tagSetStatus
553
521
}
554
522
}
555
- }
523
+ }
556
524
""" % "setTagSetStatusPyApi"
557
525
558
526
self .client .execute (query_str , {
@@ -568,7 +536,7 @@ def queue_mode(self):
568
536
project(where: {id: $projectId}) {
569
537
tagSetStatus
570
538
}
571
- }
539
+ }
572
540
""" % "GetTagSetStatusPyApi"
573
541
574
542
status = self .client .execute (
@@ -666,8 +634,8 @@ def unset_labeling_parameter_overrides(self, data_rows):
666
634
query_str = """mutation UnsetLabelingParameterOverridesPyApi($%s: ID!){
667
635
project(where: { id: $%s}) {
668
636
unsetLabelingParameterOverrides(data: [%s]) { success }}}""" % (
669
- id_param , id_param , ",\n " .join (
670
- "{dataRowId: \" %s \" }" % row . uid for row in data_rows ))
637
+ id_param , id_param , ",\n " .join ("{dataRowId: \" %s \" }" % row . uid
638
+ for row in data_rows ))
671
639
res = self .client .execute (query_str , {id_param : self .uid })
672
640
return res ["project" ]["unsetLabelingParameterOverrides" ]["success" ]
673
641
0 commit comments