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
Configuration handling for Gammapy #401
Comments
ctapipe.configuration is basically just a subclass of argparse that allows the ablity to read/write to FITS headers, so at this point it is nothing fancy. We have a requirement that we must be able to keep the "provenance data", one part of which is list of all commands and options that are used to create an output file, so this basic functionality helps there. That data can grow very large if a file as at the end of a processing chain, but it's very useful to be able to read it back from headers, and later do things like diffing it to see the differences in options. The idea is that given an output file, one can track back what was done to produce it. What we use as a configuraiton format is more flexible - yaml is fine for a user-facing script, but we will probably (optionally) use a database table as the input. |
Also, I agree that validation is one of the most important features. We use argparse for that reason, since it has a way to give default values and check types. However, I've also used Ideally I wish there was a system that works a bit like |
@kosack - Thanks for your comments! I've also used configobj and validate in the past, e.g. in enrico. It's nice, but not as flexible / popular as YAML or even JSON.
This is exactly what schema or jsonschema do, they work with specs as Python dicts (and callback functions for more complex validation), no? And python-anyconfig has the multiple backend thing worked out, no? Of course it's possible to implement this with any format / based on any of these packages, but if we manage to pick the same solution here, I think that could be nice, mostly in terms of getting a critical mass of devs that know how it works in detail and can help write schemas / validation tools (it's hard to find people with the skills / interest to work on this). |
Just a note: @bkhelifi and I have a strong preference to add a config-file driven analysis interface at least for the most common types of simple analyses. Something similar to what @joleroi had implemented for spectral analysis a while ago: It looks like there is something available in ctapipe: |
we're just testing it now, so it's not totally stable. Currently we are directly using the ipython config system, which is based on |
I've written some classes for configuration management in fermipy. It's nothing as sophisticated as Since this functionality isn't really fermi specific I'd be interested in folding what's currently in fermipy into some common configuration modules that could live in gammapy (or elsewhere). Note that I don't have any particular attachment to the implementation in fermipy so I'd have no problem switching to something closer to |
|
@Bultako started implementing config-driven high-level interface for Gammapy (see #2219 and #2323). @Bultako - Please look over the discussion above, with links and info to other config systems and Fermipy. I'd suggest we keep this issue open for a few more weeks, and use it to discuss our |
@Bultako and I explored solutions to improve Gammapy here: https://github.com/cdeil/gammapy-config/ Discussed with everyone at the Gammapy coding sprint in Granada just now. Decisions:
|
@Bultako implemented a new Gammapy config handling in #2621 using pydantic. So I'm closing this old issue now. Further improvements / suggestions as new PRs and issues with specific suggestions, please. |
In Gammapy we've started to use YAML configuration files and @joleroi has added a few utility functions in gammapy.utils.scripts, namely
read_yaml
,write_yaml
andrecursive_update_dict
.I'd like to propose we go for a more full-featured solution with milestone 0.5 that provides the option to specify and validate schemas and to a large degree use an existing package instead of rolling our own.
It's not clear yet what other features we need / want, e.g. do we want to have the option to override config options via command line parameters? Do we want to support other file formats than YAML for configs, e.g. JSON or FITS or INI? Do we want dot access, i.e.
config.spam.ham
instead ofconfig['spam']['ham']
?This is something where it might be possible to work on one solution with the
ctapipe
devs or to learn from what they're doing in ctapipe.configuration, so @kosack, if you have any thoughts / suggestions here, please comment.I've looked around a bit at existing Python config packages that support YAML:
For schema validation, those might be options:
I want to work on this, but probably won't have time for a while.
So @joleroi or anyone else, if you'd like to start using one of the existing packages in Gammapy so that we get experience, please go ahead.
If I were to do it, I'd probably try
python-anyconfig
first, because it seems to make it supports everything we need (I think):The text was updated successfully, but these errors were encountered: