-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserializers.py
184 lines (140 loc) · 3.84 KB
/
serializers.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
from django.contrib.auth.models import User
from rest_framework.serializers import ModelSerializer
from apps.models import AppCategories, AppInstance, Apps, AppStatus
from models.models import Metadata, Model, ModelLog, ObjectType
from projects.models import (
S3,
Environment,
Flavor,
MLFlow,
Project,
ProjectTemplate,
ReleaseName,
)
from user.models import Client, ClientRole
class MLModelSerializer(ModelSerializer):
class Meta:
model = Model
fields = (
"id",
"uid",
"name",
"description",
"model_card",
"resource",
"url",
"uploaded_at",
"project",
"status",
"version",
"object_type",
)
class ObjectTypeSerializer(ModelSerializer):
class Meta:
model = ObjectType
fields = ("id", "name", "slug")
class ModelLogSerializer(ModelSerializer):
class Meta:
model = ModelLog
fields = (
"id",
"run_id",
"trained_model",
"project",
"training_started_at",
"execution_time",
"code_version",
"current_git_repo",
"latest_git_commit",
"system_details",
"cpu_details",
"training_status",
)
class MetadataSerializer(ModelSerializer):
class Meta:
model = Metadata
fields = (
"id",
"run_id",
"trained_model",
"project",
"model_details",
"parameters",
"metrics",
)
class S3serializer(ModelSerializer):
class Meta:
model = S3
fields = ("name", "access_key", "secret_key", "host", "region")
class MLflowSerializer(ModelSerializer):
s3 = S3serializer()
class Meta:
model = MLFlow
fields = ("name", "mlflow_url", "s3")
class ProjectSerializer(ModelSerializer):
s3storage = S3serializer()
class Meta:
model = Project
fields = (
"id",
"name",
"description",
"slug",
"owner",
"authorized",
"image",
"s3storage",
"updated_at",
"created_at",
"repository",
"repository_imported",
)
class AppCategorySerializer(ModelSerializer):
class Meta:
model = AppCategories
fields = ("name",)
class AppSerializer(ModelSerializer):
category = AppCategorySerializer()
class Meta:
model = Apps
fields = ("id", "revision", "name", "category")
class AppStatusSerializer(ModelSerializer):
class Meta:
model = AppStatus
fields = ("id", "status_type")
class AppInstanceSerializer(ModelSerializer):
app = AppSerializer()
status = AppStatusSerializer(many=True)
class Meta:
model = AppInstance
fields = ("id", "name", "app", "table_field", "state", "status")
class UserSerializer(ModelSerializer):
class Meta:
model = User
fields = ["id", "username"]
class FlavorsSerializer(ModelSerializer):
class Meta:
model = Flavor
fields = "__all__"
class EnvironmentSerializer(ModelSerializer):
app = AppSerializer()
class Meta:
model = Environment
fields = "__all__"
class ReleaseNameSerializer(ModelSerializer):
app = AppInstanceSerializer()
class Meta:
model = ReleaseName
fields = "__all__"
class ProjectTemplateSerializer(ModelSerializer):
class Meta:
model = ProjectTemplate
fields = "__all__"
class ClientSerializer(ModelSerializer):
class Meta:
model = Client
fields = "__all__"
class ClientRoleSerializer(ModelSerializer):
class Meta:
model = ClientRole
fields = "__all__"