clearml-server/server/apimodels/tasks.py

117 lines
2.7 KiB
Python
Raw Normal View History

2019-06-10 21:24:35 +00:00
import six
from jsonmodels import models
2019-12-29 07:03:19 +00:00
from jsonmodels.fields import StringField, BoolField, IntField, EmbeddedField
2019-06-10 21:24:35 +00:00
from jsonmodels.validators import Enum
from apimodels import DictField, ListField
from apimodels.base import UpdateResponse
from database.model.task.task import TaskType
from database.utils import get_options
2019-12-29 07:03:19 +00:00
class ArtifactTypeData(models.Base):
preview = StringField()
content_type = StringField()
data_hash = StringField()
class Artifact(models.Base):
key = StringField(required=True)
type = StringField(required=True)
mode = StringField(validators=Enum("input", "output"), default="output")
uri = StringField()
hash = StringField()
content_size = IntField()
timestamp = IntField()
type_data = EmbeddedField(ArtifactTypeData)
display_data = ListField([list])
2019-06-10 21:24:35 +00:00
class StartedResponse(UpdateResponse):
started = IntField()
class EnqueueResponse(UpdateResponse):
queued = IntField()
class DequeueResponse(UpdateResponse):
dequeued = IntField()
2019-06-10 21:24:35 +00:00
class ResetResponse(UpdateResponse):
deleted_indices = ListField(items_types=six.string_types)
dequeued = DictField()
2019-06-10 21:24:35 +00:00
frames = DictField()
events = DictField()
model_deleted = IntField()
class TaskRequest(models.Base):
task = StringField(required=True)
class UpdateRequest(TaskRequest):
status_reason = StringField(default="")
status_message = StringField(default="")
force = BoolField(default=False)
class EnqueueRequest(UpdateRequest):
queue = StringField()
2019-06-10 21:24:35 +00:00
class DeleteRequest(UpdateRequest):
move_to_trash = BoolField(default=True)
class SetRequirementsRequest(TaskRequest):
requirements = DictField(required=True)
class PublishRequest(UpdateRequest):
publish_model = BoolField(default=True)
class PublishResponse(UpdateResponse):
pass
class TaskData(models.Base):
"""
This is a partial description of task can be updated incrementally
"""
class CreateRequest(TaskData):
name = StringField(required=True)
type = StringField(required=True, validators=Enum(*get_options(TaskType)))
2019-07-08 21:00:13 +00:00
class PingRequest(TaskRequest):
pass
2019-12-29 07:03:19 +00:00
class GetTypesRequest(models.Base):
projects = ListField(items_types=[str])
2019-12-29 07:03:19 +00:00
class CloneRequest(TaskRequest):
new_task_name = StringField()
new_task_comment = StringField()
new_task_tags = ListField([str])
new_task_system_tags = ListField([str])
new_task_parent = StringField()
new_task_project = StringField()
execution_overrides = DictField()
validate_references = BoolField(default=False)
2019-12-29 07:03:19 +00:00
class AddOrUpdateArtifactsRequest(TaskRequest):
artifacts = ListField([Artifact], required=True)
class AddOrUpdateArtifactsResponse(models.Base):
added = ListField([str])
updated = ListField([str])