dstack
dstack copied to clipboard
Remove duplication in run configuration models and schemas
Some models used for run configurations have duplicates. See GPUSpec
and GPUSpecSchema
, DiskSpec
and DiskSpecSchema
, etc. The *Schema
models are needed to generate a more permissive JSON schema, see this comment. E.g. they replace Range
with Union[Range, int, str]
, because ranges can parse ints and strs too. #1055 also introduced additional duplication of range parsing logic to avoid creating a new *Schema
model.
We might want to look for ways to reduce duplication. Maybe Range
could replace its own JSON schema wherever it's used by implementing __get_pydantic_json_schema__
(Pydantic v2) or __modify_schema__
(Pydantic v1).