clearml-server/apiserver/database/model/model.py

76 lines
2.7 KiB
Python
Raw Normal View History

from mongoengine import Document, StringField, DateTimeField, BooleanField
2019-06-10 21:24:35 +00:00
from database import Database, strict
from database.fields import StrippedStringField, SafeDictField, SafeSortedListField
2019-06-10 21:24:35 +00:00
from database.model import DbModelMixin
from database.model.base import GetMixin
2019-06-10 21:24:35 +00:00
from database.model.model_labels import ModelLabels
from database.model.company import Company
from database.model.project import Project
from database.model.task.task import Task
from database.model.user import User
class Model(DbModelMixin, Document):
meta = {
2020-04-01 16:20:53 +00:00
"db_alias": Database.backend,
"strict": strict,
"indexes": [
"parent",
"project",
"task",
2020-07-06 18:50:43 +00:00
("company", "framework"),
2020-04-01 16:20:53 +00:00
("company", "name"),
("company", "user"),
2019-06-10 21:24:35 +00:00
{
2020-04-01 16:20:53 +00:00
"name": "%s.model.main_text_index" % Database.backend,
"fields": ["$name", "$id", "$comment", "$parent", "$task", "$project"],
"default_language": "english",
"weights": {
"name": 10,
"id": 10,
"comment": 10,
"parent": 5,
"task": 3,
"project": 3,
},
},
2019-06-10 21:24:35 +00:00
],
}
get_all_query_options = GetMixin.QueryParameterOptions(
pattern_fields=("name", "comment"),
fields=("ready",),
list_fields=(
"tags",
"system_tags",
"framework",
"uri",
"id",
"user",
"project",
"task",
"parent",
),
)
2019-06-10 21:24:35 +00:00
id = StringField(primary_key=True)
name = StrippedStringField(user_set_allowed=True, min_length=3)
2020-04-01 16:20:53 +00:00
parent = StringField(reference_field="Model", required=False)
2019-06-10 21:24:35 +00:00
user = StringField(required=True, reference_field=User)
company = StringField(required=True, reference_field=Company)
project = StringField(reference_field=Project, user_set_allowed=True)
created = DateTimeField(required=True, user_set_allowed=True)
task = StringField(reference_field=Task)
comment = StringField(user_set_allowed=True)
tags = SafeSortedListField(StringField(required=True), user_set_allowed=True)
system_tags = SafeSortedListField(StringField(required=True), user_set_allowed=True)
2020-04-01 16:20:53 +00:00
uri = StrippedStringField(default="", user_set_allowed=True)
2019-06-10 21:24:35 +00:00
framework = StringField()
design = SafeDictField()
labels = ModelLabels()
ready = BooleanField(required=True)
2020-04-01 16:20:53 +00:00
ui_cache = SafeDictField(
default=dict, user_set_allowed=True, exclude_by_default=True
)
company_origin = StringField(exclude_by_default=True)