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

provide config settings from command line when running create_dataset script #146

Closed
valedan opened this issue Mar 29, 2023 · 2 comments
Closed
Assignees

Comments

@valedan
Copy link
Contributor

valedan commented Mar 29, 2023

No description provided.

@mivanit mivanit self-assigned this Apr 7, 2023
@mivanit
Copy link
Member

mivanit commented Apr 7, 2023

I've implemented something akin to this in muutils, and I'll be adding this to training and other scripts soon. the general outline of how this works:

from muutils.json_serialize import SerializableDataclass, serializable_dataclass
from muutils.dictmagic import kwargs_to_nested_dict

@serializable_dataclass
class YourConfigClass(SerializableDataclass):
   your_field: int
   # ..............

def main(
    cfg_name: str = "default",
    whatever_other_things_you_want: Any = "stuff",
    **kwargs,
):
    cfg_kwargs: dict = kwargs_to_nested_dict(kwargs, sep=".", strip_prefix="cfg.")
    cfg: YourConfigClass = NAMED_CONFIGS[cfg_name]
    cfg.update_from_nested_dict(cfg_kwargs)

   do_your_thing(cfg)

note that dotlist_to_nested_dict and update_from_nested_dict are present in 0.3.7, the current published version, but kwargs_to_nested_dict will be coming sometime today or tmro in 0.3.8

@mivanit
Copy link
Member

mivanit commented Jun 16, 2023

added in #177 iirc

@mivanit mivanit closed this as completed Jun 16, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants