Fix backward compatibility when importing old projects

This commit is contained in:
allegroai 2022-07-08 17:49:36 +03:00
parent c28f478ea8
commit a41ae112a1

View File

@ -746,6 +746,15 @@ class PrePopulate:
module = importlib.import_module(module_name)
return getattr(module, class_name)
@staticmethod
def _upgrade_project_data(project_data: dict) -> dict:
if not project_data.get("basename"):
name: str = project_data["name"]
_, _, basename = name.rpartition("/")
project_data["basename"] = basename
return project_data
@staticmethod
def _upgrade_model_data(model_data: dict) -> dict:
metadata_key = "metadata"
@ -846,6 +855,7 @@ class PrePopulate:
data_upgrade_funcs: Mapping[Type, Callable] = {
cls.task_cls: cls._upgrade_task_data,
cls.model_cls: cls._upgrade_model_data,
cls.project_cls: cls._upgrade_project_data,
}
for item in cls.json_lines(f):
upgrade_func = data_upgrade_funcs.get(cls_)