Skip to content

Commit

Permalink
generate sample predictions using JSF
Browse files Browse the repository at this point in the history
  • Loading branch information
matt-bernstein committed Nov 22, 2024
1 parent baedd32 commit 8ea2c3d
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions src/label_studio_sdk/label_interface/interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
from collections import defaultdict, OrderedDict
from lxml import etree
import xmljson
from jsf import JSF

from label_studio_sdk._legacy.exceptions import (
LSConfigParseException,
Expand Down Expand Up @@ -839,9 +840,23 @@ def generate_sample_task(self, mode="upload", secure_mode=False):

return task

def generate_sample_annotation(self):
def generate_sample_prediction(self):
""" """
raise NotImplemented()
prediction = PredictionValue(
model_version='sample model version',
result=[
{
'from_name': control.name,
'to_name': control.to_name[0],
'type': control.tag,
# TODO: put special case for choices in generation instead of validation
'value': {control._label_attr_name: JSF(control.to_json_schema()).generate()}
} for control in self.controls
]
)
prediction_dct = prediction.model_dump()
assert self.validate_prediction(prediction_dct), 'could not generate a sample prediction'
return prediction_dct

#####
##### COMPATIBILITY LAYER
Expand Down

0 comments on commit 8ea2c3d

Please sign in to comment.