Skip to content

Commit

Permalink
fix optional parameters for payloads
Browse files Browse the repository at this point in the history
  • Loading branch information
Tyrannas committed Mar 8, 2024
1 parent c4cb13f commit 60f9e3d
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 24 deletions.
2 changes: 1 addition & 1 deletion panoptic_back/panoptic/core/importer.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
30 changes: 15 additions & 15 deletions panoptic_back/panoptic/models/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand Down Expand Up @@ -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):
Expand All @@ -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)
Expand Down Expand Up @@ -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):
Expand All @@ -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
Expand Down Expand Up @@ -203,27 +203,27 @@ 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


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] = []


Expand All @@ -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] = []
Expand All @@ -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] = []


Expand All @@ -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]
Expand Down
16 changes: 8 additions & 8 deletions panoptic_back/panoptic/models/payloads.py
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand All @@ -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):
Expand Down

0 comments on commit 60f9e3d

Please sign in to comment.