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

Improved configuration parsing #758

Open
sarthakpati opened this issue Dec 20, 2023 · 15 comments · May be fixed by #976
Open

Improved configuration parsing #758

sarthakpati opened this issue Dec 20, 2023 · 15 comments · May be fixed by #976
Assignees
Labels
enhancement New feature or request

Comments

@sarthakpati
Copy link
Collaborator

sarthakpati commented Dec 20, 2023

Is your feature request related to a problem? Please describe.
Currently, the configuration parsing is done by a single submodule [ref], which is creates issues with maintenance as more functionality is introduced.

Describe the solution you'd like
Using a configuration validation mechanism that is more standardized would make the developer and user experience much better. Some examples are (and this is by no means an exhaustive list):

Package Documentation Example
Cerberus https://docs.python-cerberus.org/ https://stackoverflow.com/a/46626418
PyDantic https://docs.pydantic.dev/latest/ https://stackoverflow.com/a/61021183
Marshmallow https://marshmallow.readthedocs.io/en/stable/ https://stackoverflow.com/a/63739747

Describe alternatives you've considered
N.A.

Additional context
It would make sense to eventually move GaNDLF's various functionalities to something like Hydra, and this could potentially be a good starting point.

@sarthakpati sarthakpati added the enhancement New feature or request label Dec 20, 2023
@vedik2002
Copy link

Hi @sarthakpati can you please assign this issue to me.

@sarthakpati
Copy link
Collaborator Author

Thanks, done.

Copy link
Contributor

github-actions bot commented Mar 7, 2024

Stale issue message

Copy link
Contributor

github-actions bot commented May 9, 2024

Stale issue message

@sarthakpati
Copy link
Collaborator Author

Hi @vedik2002, are you still working on this?

Copy link
Contributor

Stale issue message

@sarthakpati
Copy link
Collaborator Author

Hey @vedik2002 are you still working on this?

@vedik2002
Copy link

Hi @sarthakpati can please remove me from this issue.

@sarthakpati
Copy link
Collaborator Author

Here are a few viable alternatives to our current configuration management system:

  1. Data Classes:

    • dataclasses module [ref] provides a decorator and functions for automatically adding special methods to user-defined classes. This can make your code cleaner and more efficient when dealing with a large number of parameters.
    from dataclasses import dataclass
    
    @dataclass
    class Parameters:
        param1: int
        param2: float
        param3: str
  2. Named Tuples:

    • collections.namedtuple module [ref] can be used to create tuple subclasses with named fields. This can be faster than dictionaries for certain operations.
    from collections import namedtuple
    
    Parameters = namedtuple('Parameters', ['param1', 'param2', 'param3'])
    params = Parameters(param1=1, param2=2.0, param3='three')

Did you have something else in mind, @VukW?

@VukW
Copy link
Contributor

VukW commented Sep 1, 2024

I'd prefer to stick to pydantic models (BaseModel, BaseSettings) as they actually give the same experience and simplicity as dataclass but with additional handy tools like custom fields validation, runtime type checking, etc

@sarthakpati
Copy link
Collaborator Author

@VukW
Copy link
Contributor

VukW commented Sep 4, 2024

@sarthakpati yes, exactly

@sarthakpati
Copy link
Collaborator Author

Cool, thanks. 👍🏽

@VukW VukW self-assigned this Sep 4, 2024
Copy link
Contributor

github-actions bot commented Nov 3, 2024

Stale issue message

@benmalef
Copy link
Contributor

benmalef commented Nov 6, 2024

Hi @sarthakpati could you please assign this issue to me.

@benmalef benmalef linked a pull request Nov 22, 2024 that will close this issue
11 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants