Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

♻️ REFACTOR: use pydantic instead of __init__ constructor #10

Merged
merged 2 commits into from
Apr 22, 2023

Commits on Apr 22, 2023

  1. Configuration menu
    Copy the full SHA
    5302078 View commit details
    Browse the repository at this point in the history
  2. ‼️ Redesign controllers as pydantic BaseModels

    Breaking behaviour: In case no `Group` with `group_label` exists,
    submission controllers created the specified group upon instantiation.
    This means is the user simply had a typo in the label upon instatiation
    of the controller, a new (useless) group was created. Here we adapt
    this behaviour to check for the groups existence instead.
    
    This is done by converting the controller classes into `pydantic`
    `BaseModel`s and using a `validator`. Using `BaseModel` has a few added
    benefits:
    
    1. Much cleaner constructor specification, that is inherited by sub
       classes. This becomes especially appreciable for more complex submission
       controllers.
    2. Automatic validation on all constructor inputs.
    3. Adds type hinting to all constructor inputs, which makes the classes
       much more user friendly and facilitates development.
    4. `pydantic` `BaseModel`s come with built-in JSON serialization
       support, which makes it easier to store and recreate submission
       controllers from JSON files. If we want to set up reproducable HTC
       infrastructure, this may come in handy.
    mbercx committed Apr 22, 2023
    Configuration menu
    Copy the full SHA
    8cc3f3c View commit details
    Browse the repository at this point in the history