-
Notifications
You must be signed in to change notification settings - Fork 94
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
Improve parsec validate #2609
Improve parsec validate #2609
Conversation
This seems generally sensible. (I'm not sure that on-demand loading of config files is much of an advantage in our context - suite configs are the only big ones, and they're always "demanded" more or less immediately, no? - but that's not really an objection). Do you have a use case in mind for dumping and loading parsed config files, or is this mainly about simplification (which I think I agree your change does quite nicely). |
Quick answers: The change is mainly about simplification, although I was looking at ways to improve the data structure of the configuration objects and the data structure of their specifications. On singleton. We have already eliminated the On loading/dumping. I am really talking about the specification data structure, instead of the configuration here. It may be good to be able to load the specification on demand - to reduce the memory footprint of loading the |
26f43a3
to
4655716
Compare
7ae1885
to
621b874
Compare
lib/parsec/validate.py
Outdated
raise IllegalValueError('boolean', keys, value) | ||
|
||
@classmethod | ||
def _coerce_cycle_point(cls, value, keys): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are we able to use the cylc.cycling.iso8601.SuiteSpecifics.iso8601_parsers[0]
instance of TimePointParser
rather than creating a new one here or is that not available at this stage?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is not yet available at this stage, and will introduce a circular dependency between parsec and cylc libraries. Having said, I'll take a look to see whether it is possible to do it the other way round or not.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(Having looked at it, it may be more trouble than it is worth.)
4fdb388
to
82417a9
Compare
8b01f94
to
7ecc46a
Compare
7ecc46a
to
78d9148
Compare
(We should get this one in once you've resolved the current conflicts) |
Quite difficult conflicts, but I think I've got something working. There will be some renames and relocations of classes. (I'm on a course today and tomorrow. I'll reassess this as soon as I'm back on Friday.) |
78d9148
to
e10a0b3
Compare
This is good enough again. (Conflict resolved. Tests pass.) I have done some relocation and renames to ensure that the
|
e10a0b3
to
c66774d
Compare
543b3be
to
854cd2f
Compare
854cd2f
to
936602e
Compare
936602e
to
c718a85
Compare
6d06a98
to
061b13b
Compare
3d37445
to
c2191cb
Compare
c2191cb
to
7bd6b04
Compare
Conflicts resolved. Should be ready to review again. |
ac73439
to
35d51f1
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is going to seem like an anticlimax after the long wait, but ... I'm happy with this change, and haven't found any further issues with it 💥
@oliver-sanders please sanity check. |
Single validator with simple dispatch table for coercers. Cleaner specs that reflect actual usages for type, default, options.
Relocate dependency on wallclock module. Rename subprocess context classes.
SubProcContext and SubFuncContext now in their own module. * cylc.subprocctx * cylc.mp_pool renamed cylc.subprocpool New CylcConfigValidator subclass of ParsecValidator in its own module. The wallclock module is moved back to cylc.wallclock namespace.
35d51f1
to
4ca487b
Compare
Resolved conflict by rebasing. |
@oliver-sanders please prioritise review of this one. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm broadly OK with this change, I can't find any way to break it and am running out of ways to test it.
I think it's time to put it in and see what happens!
|
||
def __init__(self): | ||
ParsecValidator.__init__(self) | ||
self.coercers.update({ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
review postscript: if we made self.coercers
a class attribute then validate could be a class method saving us having to create validator objects.
(I have kept this branch in my own space for a while now. I am raising this PR for initial discussion. Happy to drop if not popular.)
Cleaner
SPEC
data structures:validator
objects, so the data structure can easily be dumped out (or even loaded in). Each list looks like[value_type, default, allowed_2, allowed_3, ...]
which should be enough to represent the essentials, where:value_type
: is the compulsory value type of the setting, and defined only using constants fromparsec.validate.ParsecValidator
.default
: is the optional default value. Default isNone
if this is not defined.allowed_2, ...
: are the only other allowed values of this setting, if specified.Other changes:
parsec.validate.ParsecValidator
.parsec.config
andparsec.validate
, and betweenparsec.*
andcylc.cfgspec.*
.cylc.cfgspec.*
modules no longer export the singleton configuration objects - so configuration files should only be loaded on demand at run time, instead of at compile time.