Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
P
perxis-python
Manage
Activity
Members
Labels
Plan
Issues
3
Issue boards
Milestones
Wiki
Custom issue tracker
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
perxis
perxis-python
Commits
e559a25d
Commit
e559a25d
authored
3 months ago
by
teplyakov
Browse files
Options
Downloads
Patches
Plain Diff
feat:
AUTO-3805
Add init_collections function
parent
220b469f
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!75
feat: AUTO-3805 Update requirements
Changes
1
Hide 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
]:
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
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