Commit 0bc8cc2
authored
Add
Add a catalog item field for holding arbitrary
provider-specific data. As an example, use this
field for reserved GCP A4 instances.
Below is a comparison of different field types
that could be used for this field in both gpuhunt
and dstack. This commit suggests using typed
dicts.
JSON string (parsing into a Pydantic model on the
provider/backend side)
Cons:
- Inefficient, inconvenient, and error-prone for
writing - unnecessary serialization and
deserialization when updating an attribute of an
already serialized object.
- Possibility of incorrect usage (writing non-JSON
data).
`dict` / `TypedDict`
Cons:
- No validation, which means potential errors
occur at attribute access time rather than at
model loading time.
Pydantic models with a `type` discriminator
Cons:
- Extra difficulties maintaining backward
compatibility, as the models are passed from
gpuhunt to dstack server, from server to client,
and from client to server, all with validation.
- Duplication of backend type in the
backend-specific field and in other fields of
the offer or catalog (e.g.,
`InstanceOffer.backend` and
`InstanceOffer.backend_data.type`).
- Discriminators require declaring all possible
discriminator values, which in the future will
hinder the transition to a more modular
architecture with backend plugins.
- Backward compatibility issues when a new
discriminator value (a new backend) is
introduced.
Pydantic models + custom deserialization logic
(e.g., custom `InstanceOffer` deserializer that
determines the `InstanceOffer.backend_data` model
based on InstanceOffer.backend)
Cons:
- Extra difficulties maintaining backward
compatibility as the models are passed from
gpuhunt to dstack server, from server to client,
and from client to server, all with validation.
- The need to duplicate deserialization logic in
all model that hold the backend-specific field -
at least in RawCatalogItem and `InstanceOffer`.CatalogItem.provider_data + reserved GCP A4 (#184)1 parent 95122e6 commit 0bc8cc2
3 files changed
Lines changed: 76 additions & 25 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
| 2 | + | |
2 | 3 | | |
3 | 4 | | |
4 | 5 | | |
| |||
9 | 10 | | |
10 | 11 | | |
11 | 12 | | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
12 | 24 | | |
13 | 25 | | |
14 | 26 | | |
| |||
73 | 85 | | |
74 | 86 | | |
75 | 87 | | |
| 88 | + | |
76 | 89 | | |
77 | 90 | | |
78 | 91 | | |
| |||
121 | 134 | | |
122 | 135 | | |
123 | 136 | | |
| 137 | + | |
124 | 138 | | |
125 | 139 | | |
126 | 140 | | |
127 | 141 | | |
128 | 142 | | |
129 | 143 | | |
| 144 | + | |
130 | 145 | | |
131 | 146 | | |
132 | 147 | | |
| |||
153 | 168 | | |
154 | 169 | | |
155 | 170 | | |
| 171 | + | |
| 172 | + | |
156 | 173 | | |
157 | 174 | | |
158 | 175 | | |
| |||
169 | 186 | | |
170 | 187 | | |
171 | 188 | | |
| 189 | + | |
172 | 190 | | |
173 | 191 | | |
174 | 192 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
| 2 | + | |
2 | 3 | | |
3 | 4 | | |
4 | 5 | | |
| |||
7 | 8 | | |
8 | 9 | | |
9 | 10 | | |
10 | | - | |
| 11 | + | |
11 | 12 | | |
12 | 13 | | |
13 | 14 | | |
14 | 15 | | |
15 | 16 | | |
16 | 17 | | |
17 | 18 | | |
| 19 | + | |
18 | 20 | | |
19 | 21 | | |
20 | 22 | | |
| |||
243 | 245 | | |
244 | 246 | | |
245 | 247 | | |
246 | | - | |
247 | | - | |
| 248 | + | |
| 249 | + | |
248 | 250 | | |
249 | 251 | | |
250 | 252 | | |
251 | 253 | | |
252 | 254 | | |
253 | | - | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
254 | 259 | | |
255 | 260 | | |
256 | 261 | | |
| |||
307 | 312 | | |
308 | 313 | | |
309 | 314 | | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
310 | 318 | | |
311 | 319 | | |
312 | 320 | | |
| |||
320 | 328 | | |
321 | 329 | | |
322 | 330 | | |
323 | | - | |
324 | | - | |
| 331 | + | |
| 332 | + | |
| 333 | + | |
| 334 | + | |
| 335 | + | |
| 336 | + | |
| 337 | + | |
| 338 | + | |
| 339 | + | |
| 340 | + | |
| 341 | + | |
| 342 | + | |
325 | 343 | | |
326 | 344 | | |
327 | 345 | | |
328 | 346 | | |
329 | | - | |
330 | | - | |
331 | | - | |
332 | | - | |
333 | | - | |
| 347 | + | |
| 348 | + | |
| 349 | + | |
| 350 | + | |
| 351 | + | |
334 | 352 | | |
335 | 353 | | |
336 | 354 | | |
| |||
395 | 413 | | |
396 | 414 | | |
397 | 415 | | |
398 | | - | |
| 416 | + | |
| 417 | + | |
| 418 | + | |
399 | 419 | | |
400 | 420 | | |
401 | 421 | | |
| |||
413 | 433 | | |
414 | 434 | | |
415 | 435 | | |
416 | | - | |
417 | | - | |
| 436 | + | |
| 437 | + | |
| 438 | + | |
| 439 | + | |
| 440 | + | |
| 441 | + | |
| 442 | + | |
418 | 443 | | |
419 | | - | |
| 444 | + | |
420 | 445 | | |
421 | | - | |
| 446 | + | |
| 447 | + | |
| 448 | + | |
422 | 449 | | |
423 | 450 | | |
424 | 451 | | |
425 | 452 | | |
426 | | - | |
| 453 | + | |
427 | 454 | | |
428 | 455 | | |
429 | | - | |
430 | | - | |
| 456 | + | |
| 457 | + | |
431 | 458 | | |
432 | 459 | | |
433 | 460 | | |
434 | | - | |
| 461 | + | |
435 | 462 | | |
436 | | - | |
437 | | - | |
| 463 | + | |
| 464 | + | |
438 | 465 | | |
439 | | - | |
| 466 | + | |
440 | 467 | | |
441 | | - | |
| 468 | + | |
442 | 469 | | |
443 | | - | |
| 470 | + | |
| 471 | + | |
| 472 | + | |
444 | 473 | | |
445 | 474 | | |
446 | 475 | | |
| |||
454 | 483 | | |
455 | 484 | | |
456 | 485 | | |
| 486 | + | |
| 487 | + | |
457 | 488 | | |
458 | 489 | | |
459 | 490 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
151 | 151 | | |
152 | 152 | | |
153 | 153 | | |
| 154 | + | |
154 | 155 | | |
155 | 156 | | |
156 | 157 | | |
| |||
167 | 168 | | |
168 | 169 | | |
169 | 170 | | |
| 171 | + | |
170 | 172 | | |
171 | 173 | | |
0 commit comments