astrogilda / tsbootstrap

tsbootstrap: generate bootstrapped time series samples in Python
https://tsbootstrap.readthedocs.io/en/latest/
MIT License
70 stars 5 forks source link

Pydantic for config #102

Open astrogilda opened 8 months ago

astrogilda commented 8 months ago

Is your feature request related to a problem? Please describe.

Yes, the current method for validating input parameters in our codebase is manual. There are a lot of cumbersome checks spread throughout our code. This not only makes the codebase harder to maintain but also increases the risk of bugs and inconsistencies in our data validation logic.

Describe the solution you'd like I propose integrating Pydantic for robust and efficient input parameter validation. Pydantic is a data validation and settings management library that uses Python type annotations to validate data. By defining data models using Pydantic, we can ensure that our input parameters are automatically validated against the specified types and constraints, providing a clear and concise way to enforce data integrity.

Describe alternatives you've considered

  1. Continue using manual validation: This approach is time-consuming and error-prone, as it requires writing and maintaining numerous checks throughout the codebase.
  2. Use other validation libraries like Marshmallow or Cerberus: While these libraries are also powerful, Pydantic's use of Python type annotations makes it more intuitive and seamless to integrate with our existing code, especially considering the increasing adoption of type hints in modern Python development.

Additional context Add any other context or screenshots about the feature request here.

fkiraly commented 8 months ago

where exactly would you localize the checks?

astrogilda commented 8 months ago

In the config classes

On Fri, Mar 8, 2024, 8:54 AM Franz Király @.***> wrote:

where exactly would you localize the checks?

— Reply to this email directly, view it on GitHub https://github.com/astrogilda/tsbootstrap/issues/102#issuecomment-1985839199, or unsubscribe https://github.com/notifications/unsubscribe-auth/AFTOOHVH36T3OMETGVE2ECLYXHGJTAVCNFSM6AAAAABELBPYJCVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTSOBVHAZTSMJZHE . You are receiving this because you authored the thread.Message ID: @.***>

fkiraly commented 8 months ago

Hm, my instinct goes more in the direction of merging config classes and bootstrap classes, but integrating some validation routines.

Might be worth experimenting with some options using one of the classes, later on.