Browse Source

fixed create_result method

Dimitri Korsch 3 năm trước cách đây
mục cha
commit
e6f8044551
2 tập tin đã thay đổi với 8 bổ sung3 xóa
  1. 7 2
      pycs/database/File.py
  2. 1 1
      settings.json

+ 7 - 2
pycs/database/File.py

@@ -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

+ 1 - 1
settings.json

@@ -1,7 +1,7 @@
 {
 {
   "host": "",
   "host": "",
   "port": 5000,
   "port": 5000,
-  "allowedOrigins": ["https://ammod.inf-cv.uni-jena.de", "https://deimos.inf-cv.uni-jena.de"],
+  "allowedOrigins": ["https://ammod.inf-cv.uni-jena.de", "https://deimos.inf-cv.uni-jena.de", "http://localhost:5000"],
   "projects_folder": "projects",
   "projects_folder": "projects",
   "database": "db/data.sqlite3",
   "database": "db/data.sqlite3",
   "pipeline_cache_time": 120,
   "pipeline_cache_time": 120,