Skip to content
Snippets Groups Projects

feat: AUTO-3805 Update requirements

Merged feat: AUTO-3805 Update requirements
All threads resolved!
Merged Anton Teplyakov requested to merge feature/AUTO-3805 into master
All threads resolved!
Files
5
from perxis.collections import collections_pb2
from typing import TypedDict
from typing_extensions import deprecated
def make_collection_instances(schemes_dir: str, schemes_mapping: dict[str, str]) -> list[collections_pb2.Collection]:
@deprecated("This function is deprecated. Use `init_collections` instead.")
def make_collection_instances(
schemes_dir: str, schemes_mapping: dict[str, str]
) -> list[collections_pb2.Collection]:
collections = []
for collection_id, collection_name in schemes_mapping.items():
@@ -13,7 +18,34 @@ def make_collection_instances(schemes_dir: str, schemes_mapping: dict[str, str])
name=collection_name,
schema=collection_schema
)
collections.append(collection)
return collections
class CollectionProps(TypedDict):
single: bool
system: bool
no_data: bool
hidden: bool
return collections
\ No newline at end of file
def init_collections(
schemes_dir: str,
schemes_mapping: dict[str, str],
collections_settings_mapping: dict[str, CollectionProps],
) -> list[collections_pb2.Collection]:
collections = []
for collection_id, collection_name in schemes_mapping.items():
with open(f"{schemes_dir}/{collection_id}.json", "r") as file:
collection_schema = file.read()
kwargs = {
**(collections_settings_mapping.get(collection_id) or {}),
"id": collection_id,
"name": collection_name,
"schema": collection_schema,
}
collection = collections_pb2.Collection(**kwargs)
collections.append(collection)
return collections
Loading