-
Notifications
You must be signed in to change notification settings - Fork 4
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
Add config validation CLI #191
Conversation
Codecov Report
@@ Coverage Diff @@
## main #191 +/- ##
==========================================
- Coverage 85.19% 85.19% -0.01%
==========================================
Files 27 27
Lines 1385 1391 +6
==========================================
+ Hits 1180 1185 +5
- Misses 205 206 +1
|
This is a bit of a hack since the validation occurs in Perhaps this issue will go away once we are able to port benchcab to other machines? |
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.
So there is a way that this can be improved using a "parse and dispatch" strategy. Whereby you don't need to run a conditional to work out which subcommand to use.
I basically set the desired command as a default on the sub parser and then pop it to call when dispatching.
benchcab/benchcab.py
Outdated
@@ -290,6 +290,9 @@ def main(self): | |||
if self.args.subcommand == "run": | |||
self.run() | |||
|
|||
if self.args.subcommand == "validate_config": | |||
pass # handle validation in __init__ method |
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.
As per yesterdays meeting, there is a validate_config method now present in config.py.
Line 32 in 42e66b6
def validate_config(config: dict) -> bool: |
Returns True if valid and raises an exception if not.
It would be worthwhile wrapping this in a local method to return something useful for the user in either case.
The parse and dispatch strategy looks like a good option. I've made a new issue for this (see #196) as it is a bit out of the scope of this PR and a bit more involved. |
e86cc77
to
505bc50
Compare
I am wondering if it is time to introduce click. It's quite a bit of work so probably not necessary right away but it should remove the needs for either conditionals or a parse and dispatch strategy. |
Fixes #186