clearml-server/apiserver/apimodels/projects.py

102 lines
3.0 KiB
Python
Raw Normal View History

2023-07-26 15:21:16 +00:00
from enum import Enum, auto
from jsonmodels import models, fields
2022-03-15 14:28:59 +00:00
from apiserver.apimodels import ListField, ActualEnumField, DictField
2021-01-05 14:28:49 +00:00
from apiserver.apimodels.organization import TagsRequest
from apiserver.database.model import EntityVisibility
2023-07-26 15:21:16 +00:00
from apiserver.utilities.stringenum import StringEnum
2021-05-03 14:42:10 +00:00
class ProjectRequest(models.Base):
project = fields.StringField(required=True)
2021-05-03 14:42:10 +00:00
class MergeRequest(ProjectRequest):
destination_project = fields.StringField()
class MoveRequest(ProjectRequest):
new_location = fields.StringField()
class DeleteRequest(ProjectRequest):
force = fields.BoolField(default=False)
delete_contents = fields.BoolField(default=False)
delete_external_artifacts = fields.BoolField(default=True)
2021-05-03 14:44:54 +00:00
class ProjectOrNoneRequest(models.Base):
project = fields.StringField()
include_subprojects = fields.BoolField(default=True)
2023-05-25 16:17:40 +00:00
class GetUniqueMetricsRequest(ProjectOrNoneRequest):
model_metrics = fields.BoolField(default=False)
class GetParamsRequest(ProjectOrNoneRequest):
page = fields.IntField(default=0)
page_size = fields.IntField(default=500)
class ProjectTagsRequest(TagsRequest):
projects = ListField(str)
2021-01-05 16:49:25 +00:00
2021-05-03 14:42:10 +00:00
class MultiProjectRequest(models.Base):
2021-05-03 14:34:40 +00:00
projects = fields.ListField(str)
2021-05-03 14:44:54 +00:00
include_subprojects = fields.BoolField(default=True)
2021-05-03 14:34:40 +00:00
2021-05-03 14:42:10 +00:00
class ProjectTaskParentsRequest(MultiProjectRequest):
tasks_state = ActualEnumField(EntityVisibility)
task_name = fields.StringField()
2021-05-03 14:34:40 +00:00
2023-07-26 15:21:16 +00:00
class EntityTypeEnum(StringEnum):
task = auto()
model = auto()
class ProjectUserNamesRequest(MultiProjectRequest):
entity = ActualEnumField(EntityTypeEnum, default=EntityTypeEnum.task)
class MultiProjectPagedRequest(MultiProjectRequest):
allow_public = fields.BoolField(default=True)
page = fields.IntField(default=0)
page_size = fields.IntField(default=500)
class ProjectHyperparamValuesRequest(MultiProjectPagedRequest):
2021-05-03 14:34:40 +00:00
section = fields.StringField(required=True)
name = fields.StringField(required=True)
pattern = fields.StringField()
2021-05-03 14:36:04 +00:00
class ProjectModelMetadataValuesRequest(MultiProjectPagedRequest):
2022-03-15 14:28:59 +00:00
key = fields.StringField(required=True)
class ProjectChildrenType(Enum):
pipeline = "pipeline"
report = "report"
dataset = "dataset"
2021-05-03 14:36:04 +00:00
class ProjectsGetRequest(models.Base):
2022-07-08 14:45:03 +00:00
include_dataset_stats = fields.BoolField(default=False)
2021-05-03 14:36:04 +00:00
include_stats = fields.BoolField(default=False)
2022-03-15 14:28:59 +00:00
include_stats_filter = DictField()
stats_with_children = fields.BoolField(default=True)
2021-05-03 14:36:04 +00:00
stats_for_state = ActualEnumField(EntityVisibility, default=EntityVisibility.active)
non_public = fields.BoolField(default=False) # legacy, use allow_public instead
2021-05-03 14:36:04 +00:00
active_users = fields.ListField(str)
check_own_contents = fields.BoolField(default=False)
2021-05-03 14:42:10 +00:00
shallow_search = fields.BoolField(default=False)
search_hidden = fields.BoolField(default=False)
allow_public = fields.BoolField(default=True)
children_type = ActualEnumField(ProjectChildrenType)
children_tags = fields.ListField(str)