mirror of
https://github.com/clearml/clearml-server
synced 2025-06-26 23:15:47 +00:00
Add multi-models support
This commit is contained in:
20
apiserver/mongo/migrations/utils.py
Normal file
20
apiserver/mongo/migrations/utils.py
Normal file
@@ -0,0 +1,20 @@
|
||||
from typing import Sequence
|
||||
|
||||
from boltons.iterutils import partition
|
||||
from pymongo.database import Database, Collection
|
||||
|
||||
|
||||
def _drop_all_indices_from_collections(db: Database, names: Sequence[str]):
|
||||
"""
|
||||
Drop all indices for the existing collections from the specified list
|
||||
"""
|
||||
prefixes, names = partition(names, key=lambda x: x.endswith("*"))
|
||||
prefixes = {p.rstrip("*") for p in prefixes}
|
||||
for collection_name in db.list_collection_names():
|
||||
if not (
|
||||
collection_name in names
|
||||
or any(p for p in prefixes if collection_name.startswith(p))
|
||||
):
|
||||
continue
|
||||
collection: Collection = db[collection_name]
|
||||
collection.drop_indexes()
|
||||
Reference in New Issue
Block a user