Skip to content

Commit

Permalink
use str for guid type instead of UUID (#181)
Browse files Browse the repository at this point in the history
  • Loading branch information
viseshrp authored Nov 15, 2024
1 parent 00830b5 commit bed7f7a
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/ansys/dynamicreporting/core/serverless/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,10 @@ def is_generic_class(cls):
return not isinstance(cls, type) or get_origin(cls) is not None


def get_uuid():
return str(uuid.uuid1())


class BaseMeta(ABCMeta):
_cls_registry: dict[str, type["BaseModel"]] = {}
_model_cls_registry: dict[str, type[Model]] = {}
Expand Down Expand Up @@ -130,7 +134,7 @@ def __getattribute__(cls, name):


class BaseModel(metaclass=BaseMeta):
guid: UUID = field(compare=False, kw_only=True, default_factory=uuid.uuid1)
guid: str = field(compare=False, kw_only=True, default_factory=get_uuid)
tags: str = field(compare=False, kw_only=True, default="")
_saved: bool = field(
init=False, compare=False, default=False
Expand Down Expand Up @@ -374,6 +378,9 @@ def from_db(cls, orm_instance, parent=None):
value = type_(obj_set)
else:
value = type_()
else:
if value is not None and not isinstance(value, field_type):
value = field_type(value)

# set the orm value on the proxy object
setattr(obj, attr, value)
Expand Down

0 comments on commit bed7f7a

Please sign in to comment.