@@ -151,8 +151,9 @@ def labels(self, datasets=None, order_by=None):
151151 id_param , id_param , where , order_by_str ,
152152 query .results_query_part (Label ))
153153
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 )
156157
157158 def export_queued_data_rows (self , timeout_seconds = 120 ):
158159 """ Returns all data rows that are currently enqueued for this project.
@@ -346,7 +347,7 @@ def upsert_instructions(self, instructions_file: str):
346347
347348 lfo = list (self .labeling_frontend_options ())[- 1 ]
348349 instructions_url = self .client .upload_file (instructions_file )
349- customization_options = json . loads ( lfo . customization_options )
350+ customization_options = self . ontology (). normalized
350351 customization_options ['projectInstructions' ] = instructions_url
351352 option_id = lfo .uid
352353
@@ -393,11 +394,13 @@ def create_labeler_performance(client, result):
393394 # python isoformat doesn't accept Z as utc timezone
394395 result ["lastActivityTime" ] = datetime .fromisoformat (
395396 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+ })
399401
400- return PaginatedCollection (self .client , query_str , {id_param : self .uid },
402+ return PaginatedCollection (self .client , query_str ,
403+ {id_param : self .uid },
401404 ["project" , "labelerPerformance" ],
402405 create_labeler_performance )
403406
@@ -409,7 +412,7 @@ def review_metrics(self, net_score):
409412 Returns:
410413 int, aggregation count of reviews for given `net_score`.
411414 """
412- if net_score not in (None ,) + tuple (Entity .Review .NetScore ):
415+ if net_score not in (None , ) + tuple (Entity .Review .NetScore ):
413416 raise InvalidQueryError (
414417 "Review metrics net score must be either None "
415418 "or one of Review.NetScore values" )
@@ -422,41 +425,6 @@ def review_metrics(self, net_score):
422425 res = self .client .execute (query_str , {id_param : self .uid })
423426 return res ["project" ]["reviewMetrics" ]["labelAggregate" ]["count" ]
424427
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-
460428 def setup (self , labeling_frontend , labeling_frontend_options ):
461429 """ Finalizes the Project setup.
462430
@@ -516,7 +484,7 @@ def _post_batch(self, method, data_row_ids: List[str]):
516484 }
517485 }
518486 }
519- }
487+ }
520488 """ % (method , method )
521489
522490 res = self .client .execute (query , {
@@ -552,7 +520,7 @@ def _update_queue_mode(self, mode: QueueMode) -> QueueMode:
552520 tagSetStatus
553521 }
554522 }
555- }
523+ }
556524 """ % "setTagSetStatusPyApi"
557525
558526 self .client .execute (query_str , {
@@ -568,7 +536,7 @@ def queue_mode(self):
568536 project(where: {id: $projectId}) {
569537 tagSetStatus
570538 }
571- }
539+ }
572540 """ % "GetTagSetStatusPyApi"
573541
574542 status = self .client .execute (
@@ -666,8 +634,8 @@ def unset_labeling_parameter_overrides(self, data_rows):
666634 query_str = """mutation UnsetLabelingParameterOverridesPyApi($%s: ID!){
667635 project(where: { id: $%s}) {
668636 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 ))
671639 res = self .client .execute (query_str , {id_param : self .uid })
672640 return res ["project" ]["unsetLabelingParameterOverrides" ]["success" ]
673641
0 commit comments