Background
During the Pydantic v2 upgrade in PR #1338, a discussion arose about whether the CompressionTaskResult class needs to inherit from pydantic.BaseModel.
Currently, the class has a validator for the status field:
@field_validator("status")
@classmethod
def valid_status(cls, field):
supported_status = [CompressionTaskStatus.SUCCEEDED, CompressionTaskStatus.FAILED]
if field not in supported_status:
raise ValueError(f'must be one of the following {"|" .join(supported_status)}')
return field
However, since CompressionTaskResult is not user-facing, it might be possible to:
- Remove the pydantic.BaseModel inheritance
- Type the
status field directly as CompressionTaskStatus instead of int
- Remove the validator entirely
Requirements
- Thorough validation is required to ensure no regression is caused by lifting the checks/typing
- Investigate all usage patterns of
CompressionTaskResult throughout the codebase
- Ensure that direct typing provides the same safety guarantees as the current validator
- Consider impact on serialization/deserialization if the class is used in that context
Context
Acceptance Criteria
Background
During the Pydantic v2 upgrade in PR #1338, a discussion arose about whether the
CompressionTaskResultclass needs to inherit frompydantic.BaseModel.Currently, the class has a validator for the
statusfield:However, since
CompressionTaskResultis not user-facing, it might be possible to:statusfield directly asCompressionTaskStatusinstead ofintRequirements
CompressionTaskResultthroughout the codebaseContext
components/job-orchestration/job_orchestration/scheduler/scheduler_data.pyAcceptance Criteria
CompressionTaskResultin the codebase