Company
Date Published
Author
Val Brodsky
Word count
940
Language
-
Hacker News points
None

Summary

The Labelbox Python SDK allows users to automate tasks and integrate Labelbox into custom workflows, leveraging Pydantic for data modeling, validation, and serialization in its interaction with the GraphQL API. Initially utilizing Pydantic v1, the SDK implemented dual support for Pydantic v1 and v2 to maintain compatibility with users as Pydantic v2 introduced performance and feature enhancements. However, the team eventually opted to migrate fully to Pydantic v2 to streamline development and reduce maintenance costs, despite challenges posed by the complexity of the existing codebase and reliance on older Pydantic features. The migration involved updating model configurations, handling optional fields, adapting validators, updating serialization methods, and addressing discriminated unions, ultimately resulting in a more concise and readable codebase. Key lessons from this migration highlighted the importance of careful planning, a robust test suite, and focusing on core migration patterns to manage complexity effectively.