Change model input_size field to string

This commit is contained in:
clearml 2024-12-05 22:33:52 +02:00
parent 97b9bbc4a9
commit 8b8d8d6e6f
3 changed files with 16 additions and 6 deletions

View File

@ -1,4 +1,5 @@
from enum import Enum
from numbers import Number
from typing import Union, Type, Iterable, Mapping
import jsonmodels.errors
@ -96,6 +97,15 @@ class ScalarField(fields.BaseField):
types = (str, int, float, bool)
class SafeStringField(fields.StringField):
"""String field that can also accept numbers as input"""
def parse_value(self, value):
if isinstance(value, Number):
value = str(value)
return super().parse_value(value)
class DictField(fields.BaseField):
types = (dict,)

View File

@ -13,7 +13,7 @@ from jsonmodels.fields import (
from jsonmodels import validators
from jsonmodels.validators import Min
from apiserver.apimodels import ListField, JsonSerializableMixin
from apiserver.apimodels import ListField, JsonSerializableMixin, SafeStringField
from apiserver.apimodels import ActualEnumField
from apiserver.config_repo import config
from .workers import MachineStats
@ -36,7 +36,7 @@ class ServingModel(Base):
model_version = StringField()
preprocess_artifact = StringField()
input_type = StringField()
input_size = IntField()
input_size = SafeStringField()
tags = ListField(str)
system_tags = ListField(str)
reference: Sequence[ReferenceItem] = ListField(ReferenceItem)

View File

@ -58,8 +58,8 @@ _definitions {
description: Input type
}
input_size {
type: integer
description: Input size in bytes
type: string
description: Input size
}
reference: ${_definitions.reference}
}
@ -178,8 +178,8 @@ _definitions {
description: Input type
}
input_size {
type: integer
description: Input size in bytes
type: string
description: Input size
}
}
}