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

allow YAML and TOML config files and multiple configs #1856

Merged
merged 42 commits into from
Apr 14, 2022
Merged
Changes from 1 commit
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
5ac3756
support loading config files from a YAML file
kosack Mar 22, 2022
ea3cb4b
a sample YAML version of the config
kosack Mar 22, 2022
f23996a
Modify one test to use YAML
kosack Mar 22, 2022
c9e18c1
add yaml example to quickstart
kosack Mar 22, 2022
b586267
just overload the original load_config()
kosack Mar 22, 2022
96404ee
fixed typo
kosack Mar 22, 2022
0083774
add TOML support
kosack Mar 22, 2022
6355946
try to import tomli first and fall back to toml
kosack Mar 22, 2022
458e90a
remove self from super
kosack Mar 22, 2022
fd500ed
fix import
kosack Mar 22, 2022
bae4ba0
added example TOML file and test
kosack Mar 22, 2022
754d3a5
reverted to simpler TOML
kosack Mar 22, 2022
356235c
fix typo in test
kosack Mar 22, 2022
52c7afb
use tomli, fix test and example file
kosack Mar 22, 2022
fe74d71
allow multiple config files, fixes #1732
kosack Mar 22, 2022
bd95bb6
removed unreachable code
kosack Mar 22, 2022
6c3d004
add config files to provenance tracker
kosack Mar 23, 2022
7f6cee9
updated help string for config_file
kosack Mar 23, 2022
0693b05
mention format in config help
kosack Mar 23, 2022
90e5e9d
removed accidental commit
kosack Mar 23, 2022
a97d3db
Merge branch 'master' of https://github.com/cta-observatory/ctapipe i…
kosack Mar 31, 2022
7391540
Merge branch 'master' of https://github.com/cta-observatory/ctapipe i…
kosack Apr 11, 2022
3cbe035
a better config file with lots of explanation
kosack Apr 11, 2022
8430338
updated config
kosack Apr 11, 2022
14cb0fd
updated configurations
kosack Apr 11, 2022
b51be12
better test for YAML and TOML files
kosack Apr 11, 2022
0bfa2fc
reformatting
kosack Apr 11, 2022
cd51134
add test for multiple configs
kosack Apr 11, 2022
7933565
clean up tests
kosack Apr 11, 2022
47c6ee2
fix typo and add detail
kosack Apr 11, 2022
9db64f4
fix some codacy warnings
kosack Apr 11, 2022
d8cf6b3
change Tool.config_file -> config_files since list
kosack Apr 11, 2022
5a052e0
fix incorrect f-string (now a log statement)
kosack Apr 12, 2022
bb4a1cc
Merge branch 'master' of https://github.com/cta-observatory/ctapipe i…
kosack Apr 13, 2022
9401400
update to reflect the new ShowerProcessor
kosack Apr 13, 2022
9383ff0
added FlashCam config
kosack Apr 13, 2022
9ff8651
turn off all output by default in base config
kosack Apr 13, 2022
f4c89b4
fixed test
kosack Apr 13, 2022
376be7a
added other write options, just for discoverability
kosack Apr 13, 2022
1ff1b9d
move ctapipe.tools.test.resources to ctapipe.resources
kosack Apr 13, 2022
cf84524
require pyyaml and remove HAS_YAML
kosack Apr 13, 2022
ca66dba
fixed sentence that ended too soon
kosack Apr 13, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions ctapipe/core/tool.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,13 @@
HAS_YAML = False
pass # no support for YAML

try:
import toml
kosack marked this conversation as resolved.
Show resolved Hide resolved

HAS_TOML = True
except ImportError:
HAS_TOML = False

from traitlets import default
from traitlets.config import Application, Config, Configurable

Expand Down Expand Up @@ -220,6 +227,10 @@ def load_config_file(self, path: Union[str, pathlib.Path]):
with open(path, "r") as infile:
config = Config(yaml.safe_load(infile))
self.update_config(config)
kosack marked this conversation as resolved.
Show resolved Hide resolved
elif path.suffix == ".toml" and HAS_TOML:
with open(path, "r") as infile:
config = Config(toml.load(infile))
self.update_config(config)
else:
# fall back to traitlets.config.Application's implementation
super(self).load_config_file(str(path))
kosack marked this conversation as resolved.
Show resolved Hide resolved
Expand Down