2020-08-10 05:37:41 +00:00
|
|
|
from enum import auto
|
2020-07-06 18:54:25 +00:00
|
|
|
from typing import Sequence, Optional
|
2019-09-24 18:34:35 +00:00
|
|
|
|
2020-03-01 16:00:07 +00:00
|
|
|
from jsonmodels import validators
|
|
|
|
from jsonmodels.fields import StringField, BoolField
|
2019-09-24 18:34:35 +00:00
|
|
|
from jsonmodels.models import Base
|
2020-08-10 05:30:40 +00:00
|
|
|
from jsonmodels.validators import Length, Min, Max
|
2019-09-24 18:34:35 +00:00
|
|
|
|
2021-01-05 14:28:49 +00:00
|
|
|
from apiserver.apimodels import ListField, IntField, ActualEnumField
|
|
|
|
from apiserver.bll.event.event_metrics import EventType
|
|
|
|
from apiserver.bll.event.scalar_key import ScalarKeyEnum
|
2021-01-05 14:44:31 +00:00
|
|
|
from apiserver.config_repo import config
|
2021-01-05 14:28:49 +00:00
|
|
|
from apiserver.utilities.stringenum import StringEnum
|
2019-09-24 18:34:35 +00:00
|
|
|
|
|
|
|
|
|
|
|
class HistogramRequestBase(Base):
|
2020-08-10 05:30:40 +00:00
|
|
|
samples: int = IntField(default=6000, validators=[Min(1), Max(6000)])
|
2019-09-24 18:34:35 +00:00
|
|
|
key: ScalarKeyEnum = ActualEnumField(ScalarKeyEnum, default=ScalarKeyEnum.iter)
|
|
|
|
|
|
|
|
|
|
|
|
class ScalarMetricsIterHistogramRequest(HistogramRequestBase):
|
|
|
|
task: str = StringField(required=True)
|
|
|
|
|
|
|
|
|
|
|
|
class MultiTaskScalarMetricsIterHistogramRequest(HistogramRequestBase):
|
2020-03-01 16:00:07 +00:00
|
|
|
tasks: Sequence[str] = ListField(
|
2020-08-23 12:30:32 +00:00
|
|
|
items_types=str,
|
|
|
|
validators=[
|
|
|
|
Length(
|
|
|
|
minimum_value=1,
|
|
|
|
maximum_value=config.get(
|
|
|
|
"services.tasks.multi_task_histogram_limit", 10
|
|
|
|
),
|
|
|
|
)
|
|
|
|
],
|
2020-03-01 16:00:07 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
class TaskMetric(Base):
|
|
|
|
task: str = StringField(required=True)
|
|
|
|
metric: str = StringField(required=True)
|
|
|
|
|
|
|
|
|
|
|
|
class DebugImagesRequest(Base):
|
|
|
|
metrics: Sequence[TaskMetric] = ListField(
|
|
|
|
items_types=TaskMetric, validators=[Length(minimum_value=1)]
|
|
|
|
)
|
|
|
|
iters: int = IntField(default=1, validators=validators.Min(1))
|
|
|
|
navigate_earlier: bool = BoolField(default=True)
|
|
|
|
refresh: bool = BoolField(default=False)
|
|
|
|
scroll_id: str = StringField()
|
|
|
|
|
|
|
|
|
2021-01-05 15:42:05 +00:00
|
|
|
class TaskMetricVariant(Base):
|
|
|
|
task: str = StringField(required=True)
|
|
|
|
metric: str = StringField(required=True)
|
|
|
|
variant: str = StringField(required=True)
|
|
|
|
|
|
|
|
|
|
|
|
class DebugImageIterationsRequest(TaskMetricVariant):
|
|
|
|
pass
|
|
|
|
|
|
|
|
|
|
|
|
class DebugImageEventRequest(TaskMetricVariant):
|
|
|
|
iteration: Optional[int] = IntField()
|
|
|
|
|
|
|
|
|
2020-08-10 05:37:41 +00:00
|
|
|
class LogOrderEnum(StringEnum):
|
|
|
|
asc = auto()
|
|
|
|
desc = auto()
|
|
|
|
|
|
|
|
|
2020-06-01 08:27:36 +00:00
|
|
|
class LogEventsRequest(Base):
|
|
|
|
task: str = StringField(required=True)
|
|
|
|
batch_size: int = IntField(default=500)
|
|
|
|
navigate_earlier: bool = BoolField(default=True)
|
2020-07-06 18:54:25 +00:00
|
|
|
from_timestamp: Optional[int] = IntField()
|
2020-08-10 05:37:41 +00:00
|
|
|
order: Optional[str] = ActualEnumField(LogOrderEnum)
|
2020-06-01 08:27:36 +00:00
|
|
|
|
|
|
|
|
2020-03-01 16:00:07 +00:00
|
|
|
class IterationEvents(Base):
|
|
|
|
iter: int = IntField()
|
|
|
|
events: Sequence[dict] = ListField(items_types=dict)
|
|
|
|
|
|
|
|
|
|
|
|
class MetricEvents(Base):
|
|
|
|
task: str = StringField()
|
|
|
|
metric: str = StringField()
|
|
|
|
iterations: Sequence[IterationEvents] = ListField(items_types=IterationEvents)
|
|
|
|
|
|
|
|
|
|
|
|
class DebugImageResponse(Base):
|
|
|
|
metrics: Sequence[MetricEvents] = ListField(items_types=MetricEvents)
|
|
|
|
scroll_id: str = StringField()
|
|
|
|
|
|
|
|
|
|
|
|
class TaskMetricsRequest(Base):
|
|
|
|
tasks: Sequence[str] = ListField(
|
|
|
|
items_types=str, validators=[Length(minimum_value=1)]
|
|
|
|
)
|
|
|
|
event_type: EventType = ActualEnumField(EventType, required=True)
|