Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
P
perxis-python
Manage
Activity
Members
Plan
Custom issue tracker
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Package registry
Operate
Terraform modules
Analyze
Contributor analytics
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
perxis
perxis-python
Commits
e559a25d
Commit
e559a25d
authored
6 months ago
by
teplyakov
Browse files
Options
Downloads
Patches
Plain Diff
feat:
AUTO-3805
Add init_collections function
parent
220b469f
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
perxis/collections/helpers.py
+27
-3
27 additions, 3 deletions
perxis/collections/helpers.py
with
27 additions
and
3 deletions
perxis/collections/helpers.py
+
27
−
3
View file @
e559a25d
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
]:
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
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment