Skip to content

Commit

Permalink
Add write_default_config to Component as well.
Browse files Browse the repository at this point in the history
  • Loading branch information
ccossou committed Nov 24, 2023
1 parent 8ea1cc0 commit 265ba7b
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions ctapipe/core/component.py
Original file line number Diff line number Diff line change
Expand Up @@ -285,3 +285,19 @@ def _get_default_config(cls):
:return:
"""
return config_writer.get_default_config(cls)

@classmethod
def write_default_config(cls, outname=None):
"""return the current configuration as a dict (e.g. the values
of all traits, even if they were not set during configuration)
"""

if outname is None:
outname = f"{cls.__name__}.yml"

conf = cls._get_default_config()

conf_repr = config_writer.trait_dict_to_yaml(conf)

with open(outname, "w") as obj:
obj.write(conf_repr)

0 comments on commit 265ba7b

Please sign in to comment.