Skip to content
Snippets Groups Projects
Commit e559a25d authored by teplyakov's avatar teplyakov
Browse files

feat: AUTO-3805 Add init_collections function

parent 220b469f
No related branches found
No related tags found
1 merge request!75feat: AUTO-3805 Update requirements
from perxis.collections import collections_pb2
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 +17,27 @@ def make_collection_instances(schemes_dir: str, schemes_mapping: dict[str, str])
name=collection_name,
schema=collection_schema
)
collections.append(collection)
return collections
def init_collections(
schemes_dir: str,
schemes_mapping: dict[str, str],
collections_settings_mapping: dict[str, dict[str, ...]],
) -> list[collections_pb2.Collection]:
return collections
\ No newline at end of file
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
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment