AllenNeuralDynamics / aind-watchdog-service

MIT License
2 stars 0 forks source link

Improve type hinting and favor statically typed parameters for Modality and Platform #6

Closed bruno-f-cruz closed 1 month ago

bruno-f-cruz commented 2 months ago

This PR refactors the ManifestConfig class by improving the type hinting for some of the fields.

This allows easier validation (without the need for custom validators) as well as auto-completion.

bruno-f-cruz commented 1 month ago

Relevant to this problem:

https://github.com/AllenNeuralDynamics/aind-data-schema/issues/960

I think we should code our own wrapper around the aind-data-schema for now that uses the same syntax

class Modality(Enum, str):
    """Modality classes"""

    BEHAVIOR = modaloties.Modality.Behavior().name
    BEHAVIOR_VIDEOS = modaloties.Modality.BehaviorVideos().name

This solves a few problems:

  1. Type hinting for users
  2. easier runtime validation
  3. Will likely be backwards compatible for users if aind-data-schema fixes the bug

It has a few cons: Still requires a cast from our local type to the aind-data-schema-models type If the problem in aind-data-schemas is not fixed, we will need to maintain this enumerator and keep adding entries to it.

arielleleon commented 1 month ago

I will add this wrapper to another issue. Does that work?