mirror of
https://github.com/clearml/clearml-server
synced 2025-06-26 23:15:47 +00:00
Add support for Task hyper-parameter sections and meta-data
Add new Task configuration section
This commit is contained in:
36
server/mongo/migrations/0.16.0.py
Normal file
36
server/mongo/migrations/0.16.0.py
Normal file
@@ -0,0 +1,36 @@
|
||||
from pymongo.database import Database, Collection
|
||||
|
||||
from bll.task.param_utils import (
|
||||
hyperparams_legacy_type,
|
||||
hyperparams_default_section,
|
||||
split_param_name,
|
||||
)
|
||||
from tools import safe_get
|
||||
|
||||
|
||||
def migrate_backend(db: Database):
|
||||
hyperparam_fields = ("execution.parameters", "hyperparams")
|
||||
configuration_fields = ("execution.model_desc", "configuration")
|
||||
collection: Collection = db["task"]
|
||||
for doc in collection.find(projection=hyperparam_fields + configuration_fields):
|
||||
set_commands = {}
|
||||
for (old_field, new_field), default_section in zip(
|
||||
(hyperparam_fields, configuration_fields),
|
||||
(hyperparams_default_section, None),
|
||||
):
|
||||
legacy = safe_get(doc, old_field, separator=".")
|
||||
if not legacy:
|
||||
continue
|
||||
for full_name, value in legacy.items():
|
||||
section, name = split_param_name(full_name, default_section)
|
||||
new_path = list(filter(None, (new_field, section, name)))
|
||||
# if safe_get(doc, new_path) is not None:
|
||||
# continue
|
||||
new_value = dict(
|
||||
name=name, type=hyperparams_legacy_type, value=str(value)
|
||||
)
|
||||
if section is not None:
|
||||
new_value["section"] = section
|
||||
set_commands[".".join(new_path)] = new_value
|
||||
if set_commands:
|
||||
collection.update_one({"_id": doc["_id"]}, {"$set": set_commands})
|
||||
Reference in New Issue
Block a user