Repository navigation
Expand file tree
/
Copy pathschemas.py
More file actions
171 lines (119 loc) · 3.57 KB
/
Copy pathschemas.py
File metadata and controls
171 lines (119 loc) · 3.57 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
from pydantic import BaseModel
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):
class Config:
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):
class Config:
from_attributes = True
class EnvironmentBase(BaseModel):
id: str
name: str
description: Optional[str] = None
class EnvironmentCreate(EnvironmentBase):
pass
class Environment(EnvironmentBase):
class Config:
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):
class Config:
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):
class Config:
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
class PythonVersionFilterOption(BaseModel):
label: str
major: int
minor: int
class TrendRequest(BaseModel):
benchmark_name: str
binary_id: str
environment_id: str
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]