|
@@ -196,7 +196,7 @@ class File(NamedBaseModel):
|
|
def create_result(self,
|
|
def create_result(self,
|
|
origin: str,
|
|
origin: str,
|
|
result_type: str,
|
|
result_type: str,
|
|
- label: T.Optional[T.Union[Label, int]] = None,
|
|
|
|
|
|
+ label: T.Optional[T.Union[Label, int, str]] = None,
|
|
data: T.Optional[dict] = None) -> Result:
|
|
data: T.Optional[dict] = None) -> Result:
|
|
"""
|
|
"""
|
|
Creates a result and returns the created object
|
|
Creates a result and returns the created object
|
|
@@ -212,7 +212,12 @@ class File(NamedBaseModel):
|
|
result.data = data
|
|
result.data = data
|
|
|
|
|
|
if label is not None:
|
|
if label is not None:
|
|
- assert isinstance(label, (int, Label)), f"Wrong label type: {type(label)}"
|
|
|
|
|
|
+ assert isinstance(label, (int, Label, str)), f"Label \"{label}\" has invalid type: {type(label)}"
|
|
|
|
+
|
|
|
|
+ if isinstance(label, str):
|
|
|
|
+ label = Label.query.filter(
|
|
|
|
+ Label.project_id == self.project_id,
|
|
|
|
+ Label.reference == label).one_or_none()
|
|
|
|
|
|
if isinstance(label, Label):
|
|
if isinstance(label, Label):
|
|
label = label.id
|
|
label = label.id
|