dstack icon indicating copy to clipboard operation
dstack copied to clipboard

Remove duplication in run configuration models and schemas

Open jvstme opened this issue 2 months ago • 1 comments

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).

jvstme avatar Apr 12 '24 12:04 jvstme