From 60f9e3d5847bcaec7b85d16c69b79b94d1cae64a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?F=C3=A9lix?= Date: Fri, 8 Mar 2024 23:51:20 +0100 Subject: [PATCH] fix optional parameters for payloads --- panoptic_back/panoptic/core/importer.py | 2 +- panoptic_back/panoptic/models/models.py | 30 +++++++++++------------ panoptic_back/panoptic/models/payloads.py | 16 ++++++------ 3 files changed, 24 insertions(+), 24 deletions(-) diff --git a/panoptic_back/panoptic/core/importer.py b/panoptic_back/panoptic/core/importer.py index 1af7e2d2..e2f08e02 100644 --- a/panoptic_back/panoptic/core/importer.py +++ b/panoptic_back/panoptic/core/importer.py @@ -107,7 +107,7 @@ async def import_file(self, options: ImportOptions): # create missing tags to_create = [t for t in import_tags if t not in name_to_tag] for tag_name in to_create: - tag = await self.project.db.add_tag(prop_id, tag_name, None, randint(0, 11)) + tag = await self.project.db.add_tag(prop_id, tag_name, 0, randint(0, 11)) name_to_tag[tag.value] = tag # replace tag names by tag ids values = [[name_to_tag[t].id for t in v] if v else None for v in values] diff --git a/panoptic_back/panoptic/models/models.py b/panoptic_back/panoptic/models/models.py index 3dddb26f..fba7fbfe 100644 --- a/panoptic_back/panoptic/models/models.py +++ b/panoptic_back/panoptic/models/models.py @@ -43,8 +43,8 @@ class Property(BaseModel): class PropertyDescription(Property): - id: int | None - type: PropertyType | None + id: int | None = None + type: PropertyType | None = None col: int @@ -80,8 +80,8 @@ class ImagePropertyValue(CamelModel): class Tag: id: int property_id: int - parents: list[int] value: str + parents: list[int] color: int def __post_init__(self): @@ -91,8 +91,8 @@ def __post_init__(self): class TagUpdate(CamelModel): id: int value: str - parent_id: list[int] | None - color: int | None + parent_id: list[int] | None = None + color: int | None = None @dataclass(slots=True) @@ -143,12 +143,12 @@ class Vector: class VectorDescription(CamelModel): source: str type: str - count: int | None + count: int | None = None class ProjectVectorDescriptions(CamelModel): vectors: list[VectorDescription] = [] - default_vectors: VectorDescription | None + default_vectors: VectorDescription | None = None class Parameters(BaseModel): @@ -157,7 +157,7 @@ class Parameters(BaseModel): class Folder(BaseModel): - id: int | None + id: int | None = None path: str name: str parent: int | None = None @@ -203,13 +203,13 @@ class ActionContext(CamelModel): instance_ids: List[int] | None = None property_ids: List[int] | None = None file: str | None = None - text: str | None = None + text: str | None = None ui_inputs: Dict[str, Any] = {} class ParamDescription(CamelModel): name: str - description: str | None + description: str | None = None type: str default_value: Any @@ -217,13 +217,13 @@ class ParamDescription(CamelModel): class FunctionDescription(CamelModel): id: str name: str - description: str | None + description: str | None = None action: str params: List[ParamDescription] = [] class PluginBaseParamsDescription(BaseModel): - description: str | None + description: str | None = None params: List[ParamDescription] = [] @@ -237,7 +237,7 @@ class PluginDefaultParams(BaseModel): class PluginDescription(CamelModel): name: str - description: str | None + description: str | None = None path: str base_params: PluginBaseParamsDescription registered_functions: List[FunctionDescription] = [] @@ -246,7 +246,7 @@ class PluginDescription(CamelModel): class ActionDescription(CamelModel): name: str - selected_function: str | None + selected_function: str | None = None available_functions: List[str] = [] @@ -263,7 +263,7 @@ class SetMode(Enum): class ColumnOption(BaseModel): ignore:bool = False - property_mode: PropertyMode | None + property_mode: PropertyMode | None = None ImportOptions = dict[int, ColumnOption] diff --git a/panoptic_back/panoptic/models/payloads.py b/panoptic_back/panoptic/models/payloads.py index 33ad1c38..49d158be 100644 --- a/panoptic_back/panoptic/models/payloads.py +++ b/panoptic_back/panoptic/models/payloads.py @@ -20,19 +20,19 @@ class PropertyPayload(CamelModel): class UpdatePropertyPayload(CamelModel): id: int name: str - # id: PropertyType | None + # id: PropertyType | None = None class ExportPropertiesPayload(CamelModel): - name: str | None - properties: list[int] | None - images: list[int] | None - export_images: bool | None + name: str | None = None + properties: list[int] | None = None + images: list[int] | None = None + export_images: bool | None = None class SetPropertyValuePayload(CamelModel): property_id: int - instance_ids: list[int] | None + instance_ids: list[int] | None = None value: Any @@ -55,8 +55,8 @@ class AddTagParentPayload(CamelModel): class UpdateTagPayload(CamelModel): id: int value: str - parent_id: list[int] | None - color: int | None + parent_id: list[int] | None = None + color: int | None = None class MakeClusterPayload(CamelModel):