From b075aeee186d6164c14a9f40ad165d93b6439d0f Mon Sep 17 00:00:00 2001 From: Matt Bernstein Date: Tue, 26 Nov 2024 01:47:56 -0500 Subject: [PATCH] use an even higher level fn --- src/label_studio_sdk/label_interface/interface.py | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/label_studio_sdk/label_interface/interface.py b/src/label_studio_sdk/label_interface/interface.py index a3f94d984..072f9749d 100644 --- a/src/label_studio_sdk/label_interface/interface.py +++ b/src/label_studio_sdk/label_interface/interface.py @@ -853,13 +853,14 @@ def generate_sample_prediction(self) -> Optional[dict]: 'value': {'choices': ['Neutral']}}]} NOTE: `id` field in result is not required when importing predictions; it will be generated automatically. + NOTE: for each control tag, depends on tag.to_json_schema() being implemented correctly """ prediction = PredictionValue( model_version='sample model version', - result=[ - control.label(JSF(control.to_json_schema()).generate()) + result=self.create_regions({ + control.name: JSF(control.to_json_schema()).generate() for control in self.controls - ] + }) ) prediction_dct = prediction.model_dump() if self.validate_prediction(prediction_dct): @@ -884,13 +885,14 @@ def generate_sample_annotation(self) -> Optional[dict]: 'value': {'choices': ['Negative']}}]} NOTE: `id` field in result is not required when importing predictions; it will be generated automatically. + NOTE: for each control tag, depends on tag.to_json_schema() being implemented correctly """ annotation = AnnotationValue( completed_by=-1, # annotator's user id - result=[ - control.label(JSF(control.to_json_schema()).generate()) + result=self.create_regions({ + control.name: JSF(control.to_json_schema()).generate() for control in self.controls - ] + }) ) annotation_dct = annotation.model_dump() if self.validate_annotation(annotation_dct):