2828from lib .app .annotation_helpers import add_annotation_polygon_to_json
2929from lib .app .annotation_helpers import add_annotation_polyline_to_json
3030from lib .app .annotation_helpers import add_annotation_template_to_json
31- from lib .app .exceptions import EmptyOutputError
3231from lib .app .helpers import extract_project_folder
3332from lib .app .helpers import get_annotation_paths
3433from lib .app .helpers import reformat_metrics_json
4645from lib .core .exceptions import AppException
4746from lib .core .exceptions import AppValidationException
4847from lib .core .types import ClassesJson
48+ from lib .core .types import AttributeGroup
49+ from lib .core .types import Project
4950from lib .infrastructure .controller import Controller
5051from plotly .subplots import make_subplots
5152from pydantic import EmailStr
@@ -204,14 +205,15 @@ def create_project(
204205
205206@Trackable
206207@validate_arguments
207- def create_project_from_metadata (project_metadata : dict ):
208+ def create_project_from_metadata (project_metadata : Project ):
208209 """Create a new project in the team using project metadata object dict.
209210 Mandatory keys in project_metadata are "name", "description" and "type" (Vector or Pixel)
210211 Non-mandatory keys: "workflow", "contributors", "settings" and "annotation_classes".
211212
212213 :return: dict object metadata the new project
213214 :rtype: dict
214215 """
216+ project_metadata = project_metadata .dict ()
215217 response = controller .create_project (
216218 name = project_metadata ["name" ],
217219 description = project_metadata ["description" ],
@@ -1859,10 +1861,10 @@ def upload_video_to_project(
18591861@Trackable
18601862@validate_arguments
18611863def create_annotation_class (
1862- project : Union [dict , str ],
1863- name : str ,
1864- color : str ,
1865- attribute_groups : Optional [List [dict ]] = None ,
1864+ project : Union [Project , NotEmptyStr ],
1865+ name : NotEmptyStr ,
1866+ color : NotEmptyStr ,
1867+ attribute_groups : Optional [List [AttributeGroup ]] = None ,
18661868):
18671869 """Create annotation class in project
18681870
@@ -1880,6 +1882,9 @@ def create_annotation_class(
18801882 :return: new class metadata
18811883 :rtype: dict
18821884 """
1885+ if isinstance (project , Project ):
1886+ project = project .dict ()
1887+ attribute_groups = list (map (lambda x : x .dict (), attribute_groups )) if attribute_groups else None
18831888 response = controller .create_annotation_class (
18841889 project_name = project , name = name , color = color , attribute_groups = attribute_groups
18851890 )
0 commit comments