Replies: 2 comments
-
Also, it's worth highlighting that stuff like this becomes easy. You can have a library of standard worker configs, pull them in via crosscal:
_use: lib.meerkat.crosscal.4k
secondary:
order: KGIAKF
inspect:
_use: lib.meerkat.plots.cal.phaseballs, lib.meerkat.plots.cal.spectra, lib.meerkat.plots.cal.detailed
shadems:
plots:
my_extra_plots:
- some_extra_plots
- |
Beta Was this translation helpful? Give feedback.
-
Hi, OmegaConf author here. A few points:
This is something that will (hopefully) eventually be supported. Take a look at omry/omegaconf#131.
|
Beta Was this translation helpful? Give feedback.
-
There's a discussion about configs on the Stimela repo (ok, mostly a monologue, but I'm assuming @SpheMakh will reemerge from his silent holiday retreat eventually) which is spilling over into a Caracal discussion thanks to @gigjozsa's comment, so I thought I'd answer it here.
In summary, I'm playing with OmegaConf as the config file parser and schema. There is an argument to be made for moving Caracal's schemas to it as well, as it is (a) a lot more flexible than pykwalify, (b) does it via the standard (as of 3.7+) Python typing system, and is p[probably a lot more future-proof because of that.
To answer @gigjozsa's question: yes, what you refer to by "overloading" is supported, e.g.
Union[str, int]
. And fancier things, too, likeDict[str, CustomDataClass]
(i.e. a mapping where the subsections all have to follow a specific structure).It is a bit of a different way to write a schema, in fact the schema is set up within Python itself by declaring dataclasses. As an example, I have translated the first few parameters of the flag worker schema into this (by hand for now, but we can write a script to automate this eventually):
Personally, I find this a lot more readable (and writable! so much less boilerplate junk to type out...) Also a lot more future-proof and flexible. E.g. for something like
calfields
, we can define a standard enum type, that can be reused in all workers:...which makes a lot more sense, and lets the schema check even more things for us.
Note that this doesn't change the config file at all, it's just a different way to specify the schema and validate. Oh, and it does let you access the config as
conf.rewind_flags.mode
if you want, which I much prefer toconf['rewind_flags']['mode']
(just think of the carbon footprint of all those wasted quotes and brackets! But it still supports the old ways, for those that don't care about the polar bears.)One downside is that providing documentation is not so elegant. There's no way to write a documentation string right next to the field. We would either have to document them all up front in the dataclass docstring (using one of the standard styles for which automatic parsing is available):
...or else define a dict afterwards, like so:
Which is ok I guess, I just dislike that it spreads the info about each parameter into two places. On the up side, this makes the raw documentation section human-readable, unlike the current schema files...
Beta Was this translation helpful? Give feedback.
All reactions