-
Notifications
You must be signed in to change notification settings - Fork 26
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
update requirements #222
update requirements #222
Changes from 2 commits
784ca8f
85b9352
d8bde91
52d0345
262dc53
e05619b
c389a88
307b93f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,20 @@ | ||
from typing import Optional | ||
|
||
import orjson | ||
from pydantic import BaseModel | ||
|
||
from pccommon.tables import ModelTableService | ||
from pccommon.utils import orjson_dumps | ||
|
||
|
||
class ContainerConfig(BaseModel): | ||
has_cdn: bool = False | ||
|
||
class Config: | ||
json_loads = orjson.loads | ||
json_dumps = orjson_dumps | ||
# json_loads/json_dumps config have been removed | ||
# the authors seems to indicate that parsing/serialization | ||
# in Rust (pydantic-core) is fast (but maybe not as fast as orjson) | ||
# https://github.com/pydantic/pydantic/discussions/6388 | ||
# class Config: | ||
# json_loads = orjson.loads | ||
# json_dumps = orjson_dumps | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. we can't customize this with pydantic 2 but it seems that pydantic 2 is faster anyway |
||
|
||
|
||
class ContainerConfigTable(ModelTableService[ContainerConfig]): | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,8 +4,8 @@ | |
from cachetools import Cache, LRUCache, cachedmethod | ||
from cachetools.func import lru_cache | ||
from cachetools.keys import hashkey | ||
from pydantic import BaseModel, BaseSettings, Field, PrivateAttr | ||
|
||
from pydantic import BaseModel, Field, PrivateAttr | ||
from pydantic_settings import BaseSettings | ||
from pccommon.config.collections import CollectionConfigTable | ||
from pccommon.config.containers import ContainerConfigTable | ||
from pccommon.constants import DEFAULT_TTL | ||
|
@@ -46,6 +46,15 @@ class PCAPIsConfig(BaseSettings): | |
|
||
debug: bool = False | ||
|
||
model_config = { | ||
"env_prefix": ENV_VAR_PCAPIS_PREFIX, | ||
"env_nested_delimiter": "__", | ||
# Mypi is complaining about this with | ||
# error: Incompatible types (expression has type "str", | ||
# TypedDict item "extra" has type "Extra") | ||
"extra": "ignore", # type: ignore | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. todo: remove |
||
} | ||
|
||
@cachedmethod(cache=lambda self: self._cache, key=lambda _: hashkey("collection")) | ||
def get_collection_config_table(self) -> CollectionConfigTable: | ||
return CollectionConfigTable.from_account_key( | ||
|
@@ -80,8 +89,3 @@ def get_ip_exception_list_table(self) -> IPExceptionListTable: | |
@lru_cache(maxsize=1) | ||
def from_environment(cls) -> "PCAPIsConfig": | ||
return PCAPIsConfig() # type: ignore | ||
|
||
class Config: | ||
env_prefix = ENV_VAR_PCAPIS_PREFIX | ||
extra = "ignore" | ||
env_nested_delimiter = "__" |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -45,18 +45,6 @@ class PCClient(CoreCrudClient): | |
|
||
extra_conformance_classes: List[str] = attr.ib(factory=list) | ||
|
||
def conformance_classes(self) -> List[str]: | ||
"""Generate conformance classes list.""" | ||
base_conformance_classes = self.base_conformance_classes.copy() | ||
|
||
for extension in self.extensions: | ||
extension_classes = getattr(extension, "conformance_classes", []) | ||
base_conformance_classes.extend(extension_classes) | ||
|
||
base_conformance_classes.extend(self.extra_conformance_classes) | ||
|
||
return sorted(list(set(base_conformance_classes))) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
|
||
def inject_collection_extras( | ||
self, | ||
collection: Collection, | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TODO