repository
zeus.optimizer.batch_size.server.batch_size_state.repository
Repository for batch size states(Trial, Gaussian Ts arm state).
BatchSizeStateRepository
Bases: DatabaseRepository
Repository for handling batch size related operations.
Source code in zeus/optimizer/batch_size/server/batch_size_state/repository.py
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 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 |
|
__init__
__init__(session)
Source code in zeus/optimizer/batch_size/server/batch_size_state/repository.py
38 39 40 41 42 |
|
get_next_trial_number
async
get_next_trial_number(job_id)
Get next trial number of a given job. Trial number starts from 1 and increase by 1 at a time.
Source code in zeus/optimizer/batch_size/server/batch_size_state/repository.py
44 45 46 47 48 49 50 51 52 53 54 |
|
get_trial_results_of_bs
async
get_trial_results_of_bs(batch_size, window_size)
Load window size amount of results for a given batch size. If window size <= 0, load all of them.
From all trials, we filter succeeded one since failed/dispatched ones doesn't have a valid result.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
batch_size |
BatchSizeBase
|
The batch size object. |
required |
window_size |
int
|
The size of the measurement window. |
required |
Returns:
Name | Type | Description |
---|---|---|
TrialResultsPerBs |
TrialResultsPerBs
|
trial results for the given batch size. |
Source code in zeus/optimizer/batch_size/server/batch_size_state/repository.py
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 |
|
get_arms
async
get_arms(job_id)
Retrieve Gaussian Thompson Sampling arms for a given job.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
job_id |
str
|
The ID of the job. |
required |
Returns:
Type | Description |
---|---|
list[GaussianTsArmState]
|
List[GaussianTsArmStateModel]: List of Gaussian Thompson Sampling arms. These arms are all "good" arms (converged during pruning stage). |
list[GaussianTsArmState]
|
Refer to |
Source code in zeus/optimizer/batch_size/server/batch_size_state/repository.py
91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 |
|
get_arm
async
get_arm(bs)
Retrieve Gaussian Thompson Sampling arm for a given job id and batch size.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
bs |
BatchSizeBase
|
The batch size object. |
required |
Returns:
Type | Description |
---|---|
GaussianTsArmState | None
|
Optional[GaussianTsArmStateModel]: Gaussian Thompson Sampling arm if found, else None. |
GaussianTsArmState | None
|
Refer to |
Source code in zeus/optimizer/batch_size/server/batch_size_state/repository.py
107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 |
|
get_trial
async
get_trial(trial)
Get a corresponding trial.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
trial |
ReadTrial
|
job_id, batch_size, trial_number. |
required |
Returns:
Type | Description |
---|---|
Trial | None
|
Found Trial. If none found, return None. |
Source code in zeus/optimizer/batch_size/server/batch_size_state/repository.py
129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 |
|
get_trial_from_session
get_trial_from_session(trial)
Fetch a trial from the session.
Source code in zeus/optimizer/batch_size/server/batch_size_state/repository.py
152 153 154 155 156 157 158 159 160 161 |
|
create_trial
create_trial(trial)
Create a trial in db.
Refer to CreateTrial
[zeus.optimizer.batch_size.server.batch_size_state.models.CreateTrial] for attributes.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
trial |
CreateTrial
|
The trial to add. |
required |
Source code in zeus/optimizer/batch_size/server/batch_size_state/repository.py
163 164 165 166 167 168 169 170 171 |
|
updated_current_trial
updated_current_trial(updated_trial)
Update trial in the database (report the result of trial).
Parameters:
Name | Type | Description | Default |
---|---|---|---|
updated_trial |
UpdateTrial
|
The updated trial. Refer to |
required |
Source code in zeus/optimizer/batch_size/server/batch_size_state/repository.py
173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 |
|
create_arms
create_arms(new_arms)
Create Gaussian Thompson Sampling arms in the database.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
new_arms |
List[GaussianTsArmStateModel]
|
List of new arms to create.
Refer to |
required |
Source code in zeus/optimizer/batch_size/server/batch_size_state/repository.py
195 196 197 198 199 200 201 202 |
|
update_arm_state
update_arm_state(updated_mab_state)
Update Gaussian Thompson Sampling arm state in db.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
updated_mab_state |
GaussianTsArmStateModel
|
The updated arm state.
Refer to |
required |
Source code in zeus/optimizer/batch_size/server/batch_size_state/repository.py
204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 |
|
get_explorations_of_job
async
get_explorations_of_job(job_id)
Retrieve succeeded or ongoing explorations for a given job.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
job_id |
str
|
ID of the job |
required |
Returns:
Name | Type | Description |
---|---|---|
ExplorationsPerJob |
ExplorationsPerJob
|
Explorations for the given batch size. |
ExplorationsPerJob
|
Refer to |
Source code in zeus/optimizer/batch_size/server/batch_size_state/repository.py
227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 |
|