8000 pydantic v2 by eduard-terletskiy · Pull Request #105 · u2d-ai/msaDocModels · GitHub
[go: up one dir, main page]

Skip to content

pydantic v2 #105

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions docs/release-notes.md
Original file line number Diff line number Diff line change
@@ -1,17 +1,21 @@
# msaDocModels Release Notes
## Possible future features:

# 0.0.101

- added supporting pydantic v2

# 0.0.100

- add Input and DTO models for Spellcheck
- add Input and DTO models for Spellcheck

# 0.0.98

- fix algorithm to DocClassifier Input
- fix algorithm to DocClassifier Input

# 0.0.97

- add algorithm to DocClassifier Input
- add algorithm to DocClassifier Input
- change dto model for DocClassifier

# 0.0.96
Expand Down
Binary file modified docs/saved_req_package_pip_info.pkl
Binary file not shown.
2 changes: 1 addition & 1 deletion msaDocModels/__init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import glob
from os.path import basename, dirname, isfile, join

version = "0.0.100"
version = "0.0.101"
__author__ = "Stefan Welcker"
__copyright__ = "Copyright 2022, U2D.ai"
__license__ = "MIT"
Expand Down
4 changes: 2 additions & 2 deletions msaDocModels/health.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,5 @@ class MSAHealthMessage(BaseModel):
"""Health Pydantic Response Service Message"""

healthy: bool = False
message: Optional[str]
error: Optional[str]
message: Optional[str] = None
error: Optional[str] = None
16 changes: 6 additions & 10 deletions msaDocModels/msg.py
< 8000 td id="diff-56017517bc443dbd4a6ccf818ff6bdf8e079da2c3d58dcf4c8f230b7bdbcc7f6L8" data-line-number="8" class="blob-num blob-num-context js-linkable-line-number">
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
import datetime
from typing import TypeVar
import uuid
from typing import List, Optional, TypeVar

from fastapi.encoders import jsonable_encoder
from genson import SchemaBuilder
from pydantic import BaseModel
from pydantic.types import UUID

_T = TypeVar("_T")


try:
import orjson as json
except:
Expand All @@ -18,13 +22,6 @@
json.__version__ = ""


import uuid
from typing import List, Optional

from fastapi.encoders import jsonable_encoder
from pydantic import BaseModel


class titem(BaseModel):
item_me: str = "Stefan"

Expand Down Expand Up @@ -64,9 +61,8 @@ def toMsg(self) -> str:
classes = {}
for k, v in self.__dict__.items():
classes[k] = v.__class__.__name__
# print("TOMSG:",k,v, type(v), v.__class__.__name__)
self.__dict__["classes"] = classes
return json.dumps(self, default=lambda x: jsonable_encoder(x.__dict__)).decode("utf8").replace("'", '"')
return json.dumps(self, default=lambda x: jsonable_encoder(x.__dict__)).replace("'", '"')

def fromMsg(self, message: str):
self.__dict__ = json.loads(message)
Expand Down
6 changes: 3 additions & 3 deletions msaDocModels/pubsub.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
from enum import Enum
from typing import Any, Dict

from pydantic import BaseModel, validator
from pydantic import BaseModel, field_validator


class UpdateStatusTypes(Enum):
class UpdateStatusTypes(str, Enum):
"""
Enum Class that represents choices for statuses in pubsub message.
"""
Expand All @@ -28,7 +28,7 @@ class DatabaseUpdateMessageDTO(BaseModel):
type: str
entry: Dict[str, Any]

@validator("type")
@field_validator("type")
def validate_notification_type(cls, _type: str):
available_types = [attr.value for attr in UpdateStatusTypes]
if _type in available_types:
Expand Down
14 changes: 7 additions & 7 deletions msaDocModels/scheduler.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,18 +45,18 @@ class MSASchedulerTaskDetail(BaseModel):
force_run: bool
force_termination: bool
status: str
timeout: Optional[Union[str, int, datetime.timedelta]]
timeout: Optional[Union[str, int, datetime.timedelta]] = None
parameters: Any
start_cond: Any
end_cond: Any
on_startup: bool
on_shutdown: bool
last_run: Optional[datetime.datetime]
last_success: Optional[datetime.datetime]
last_fail: Optional[datetime.datetime]
last_terminate: Optional[datetime.datetime]
last_inaction: Optional[datetime.datetime]
last_crash: Optional[datetime.datetime]
last_run: Optional[datetime.datetime] = None
last_success: Optional[datetime.datetime] = None
last_fail: Optional[datetime.datetime] = None
last_terminate: Optional[datetime.datetime] = None
last_inaction: Optional[datetime.datetime] = None
last_crash: Optional[datetime.datetime] = None
func: Any
path: Any
func_name: str
Expand Down
Loading
0