Repository navigation
Expand file tree
/
Copy pathschemas.py
More file actions
201 lines (141 loc) · 4.3 KB
/
Copy pathschemas.py
File metadata and controls
201 lines (141 loc) · 4.3 KB
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
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
from pydantic import BaseModel, ConfigDict
from typing import List, Optional, Dict, Any, Tuple
from datetime import datetime
class PythonVersion(BaseModel):
major: int
minor: int
patch: int
class CommitBase(BaseModel):
sha: str
timestamp: datetime
message: str
author: str
python_version: PythonVersion
class CommitCreate(CommitBase):
pass
class Commit(CommitBase):
model_config = ConfigDict(from_attributes=True)
class BinaryBase(BaseModel):
id: str
name: str
flags: List[
str
] # Configure flags used to build Python (e.g., --enable-optimizations, --with-debug)
description: Optional[str] = (
None # Description of what this binary configuration does
)
color: Optional[str] = "#8b5cf6" # Hex color code
icon: Optional[str] = "server" # Lucide icon name
display_order: Optional[int] = 0 # Order for display
class BinaryCreate(BinaryBase):
pass
class Binary(BinaryBase):
model_config = ConfigDict(from_attributes=True)
class EnvironmentBase(BaseModel):
id: str
name: str
description: Optional[str] = None
class EnvironmentCreate(EnvironmentBase):
pass
class Environment(EnvironmentBase):
model_config = ConfigDict(from_attributes=True)
class RunBase(BaseModel):
run_id: str
commit_sha: str
binary_id: str
environment_id: str
python_version: PythonVersion
timestamp: datetime
class RunCreate(RunBase):
pass
class Run(RunBase):
model_config = ConfigDict(from_attributes=True)
class TopAllocatingFunction(BaseModel):
function: str
count: int
total_size: int
class BenchmarkResultJson(BaseModel):
high_watermark_bytes: int
allocation_histogram: List[Tuple[int, int]]
total_allocated_bytes: int
top_allocating_functions: List[TopAllocatingFunction]
benchmark_name: Optional[str] = None
class BenchmarkResultBase(BaseModel):
id: str
run_id: str
benchmark_name: str
result_json: BenchmarkResultJson
class BenchmarkResultCreate(BaseModel):
run_id: str
benchmark_name: str
result_json: BenchmarkResultJson
flamegraph_html: Optional[str] = None
class BenchmarkResult(BenchmarkResultBase):
model_config = ConfigDict(from_attributes=True)
# Worker upload schemas
class WorkerBenchmarkResult(BaseModel):
benchmark_name: str
stats_json: Dict[str, Any] # The memray stats JSON
flamegraph_html: str # The HTML content
class WorkerRunUpload(BaseModel):
metadata: Dict[str, Any] # The metadata.json content
benchmark_results: List[WorkerBenchmarkResult]
binary_id: str # Provided by worker
environment_id: str # Provided by worker
class DiffTableRow(BaseModel):
benchmark_name: str
metric_delta_percent: Optional[float] = None
prev_metric_value: Optional[int] = None
curr_metric_value: int
curr_commit_details: Commit
prev_commit_details: Optional[Commit] = None
metric_key: str
prev_python_version_str: Optional[str] = None
curr_python_version_str: str
curr_result_id: str
has_flamegraph: bool = False
class PythonVersionFilterOption(BaseModel):
label: str
major: int
minor: int
class TrendRequest(BaseModel):
benchmark_name: str
binary_id: str
environment_id: str
python_major: int
python_minor: int
limit: int = 50
class BatchTrendRequest(BaseModel):
trend_queries: List[TrendRequest]
class BatchTrendResponse(BaseModel):
results: Dict[str, List[dict]] # Key format: "{binary_id}:{benchmark_name}"
class BenchmarkUpload(BaseModel):
commit_sha: str
binary_id: str
environment_id: str
python_version: PythonVersion
benchmark_results: List[BenchmarkResultJson]
class AdminUserPublic(BaseModel):
id: int
github_username: str
added_by: str
added_at: datetime
is_active: bool
model_config = ConfigDict(from_attributes=True)
class MemrayFailureReport(BaseModel):
commit_sha: str
commit_timestamp: datetime
binary_id: str
environment_id: str
error_message: str
class MemrayFailurePublic(BaseModel):
id: int
commit_sha: str
binary_id: str
environment_id: str
binary_name: str
environment_name: str
error_message: str
failure_timestamp: datetime
commit_timestamp: datetime
model_config = ConfigDict(from_attributes=True)