Fix docker_cmd projection in backwards compatibility

Fix support to clear input/output models and docker_cmd in backwards compatibility mode
Fix schema
This commit is contained in:
allegroai 2021-05-03 18:06:39 +03:00
parent 3d73d60826
commit dc9623e964
5 changed files with 42 additions and 35 deletions

View File

@ -185,6 +185,7 @@ def escape_paths(paths: Sequence[str]) -> Sequence[str]:
for old_prefix, new_prefix in ( for old_prefix, new_prefix in (
("execution.parameters", f"hyperparams.{hyperparams_default_section}"), ("execution.parameters", f"hyperparams.{hyperparams_default_section}"),
("execution.model_desc", f"configuration"), ("execution.model_desc", f"configuration"),
("execution.docker_cmd", "container")
): ):
path: str path: str
paths = [path.replace(old_prefix, new_prefix) for path in paths] paths = [path.replace(old_prefix, new_prefix) for path in paths]

View File

@ -1,13 +1,11 @@
metadata { metadata_item {
type: array
items {
type: object type: object
properties { properties {
key { key {
type: string type: string
description: The key uniquely identifying the metadata item inside the given entity description: The key uniquely identifying the metadata item inside the given entity
} }
tyoe { type {
type: string type: string
description: The type of the metadata item description: The type of the metadata item
} }
@ -16,7 +14,6 @@ metadata {
description: The value stored in the metadata item description: The value stored in the metadata item
} }
} }
}
} }
credentials { credentials {
type: object type: object

View File

@ -92,6 +92,11 @@ _definitions {
type: object type: object
additionalProperties: true additionalProperties: true
} }
metadata {
type: array
description: "Model metadata"
items {"$ref": "#/definitions/metadata_item"}
}
} }
} }
published_task_item { published_task_item {
@ -473,8 +478,9 @@ create {
} }
"2.13": ${create."2.1"} { "2.13": ${create."2.1"} {
metadata { metadata {
type: array
description: "Model metadata" description: "Model metadata"
"$ref": "#/definitions/metadata" items {"$ref": "#/definitions/metadata_item"}
} }
} }
} }
@ -567,8 +573,9 @@ edit {
} }
"2.13": ${edit."2.1"} { "2.13": ${edit."2.1"} {
metadata { metadata {
type: array
description: "Model metadata" description: "Model metadata"
"$ref": "#/definitions/metadata" items {"$ref": "#/definitions/metadata_item"}
} }
} }
} }
@ -649,8 +656,9 @@ update {
} }
"2.13": ${update."2.1"} { "2.13": ${update."2.1"} {
metadata { metadata {
type: array
description: "Model metadata" description: "Model metadata"
"$ref": "#/definitions/metadata" items {"$ref": "#/definitions/metadata_item"}
} }
} }
} }
@ -904,8 +912,9 @@ add_or_update_metadata {
type: string type: string
} }
metadata { metadata {
type: array
description: "Metadata items to add or update" description: "Metadata items to add or update"
"$ref": "#/definitions/metadata" items {"$ref": "#/definitions/metadata_item"}
} }
} }
} }

View File

@ -79,8 +79,9 @@ _definitions {
items { "$ref": "#/definitions/entry" } items { "$ref": "#/definitions/entry" }
} }
metadata { metadata {
type: array
description: "Queue metadata" description: "Queue metadata"
"$ref": "#/definitions/metadata" items {"$ref": "#/definitions/metadata_item"}
} }
} }
} }
@ -581,8 +582,9 @@ add_or_update_metadata {
type: string type: string
} }
metadata { metadata {
type: array
description: "Metadata items to add or update" description: "Metadata items to add or update"
"$ref": "#/definitions/metadata" items {"$ref": "#/definitions/metadata_item"}
} }
} }
} }

View File

@ -149,18 +149,16 @@ class ModelsBackwardsCompatibility:
for mode, field in cls.mode_to_fields.items(): for mode, field in cls.mode_to_fields.items():
value = nested_get(fields, field) value = nested_get(fields, field)
if value: if value is None:
nested_set( continue
fields, val = [
(cls.models_field, mode),
value=[
dict( dict(
name=TaskModelNames[mode], name=TaskModelNames[mode],
model=value, model=value,
updated=datetime.utcnow(), updated=datetime.utcnow(),
) )
], ] if value else []
) nested_set(fields, (cls.models_field, mode), value=val)
nested_delete(fields, field) nested_delete(fields, field)
@ -195,7 +193,7 @@ class DockerCmdBackwardsCompatibility:
return return
docker_cmd = nested_get(fields, cls.field) docker_cmd = nested_get(fields, cls.field)
if docker_cmd: if docker_cmd is not None:
image, _, arguments = docker_cmd.partition(" ") image, _, arguments = docker_cmd.partition(" ")
nested_set(fields, ("container", "image"), value=image) nested_set(fields, ("container", "image"), value=image)
nested_set(fields, ("container", "arguments"), value=arguments) nested_set(fields, ("container", "arguments"), value=arguments)