-
Notifications
You must be signed in to change notification settings - Fork 17
OTAVA-82: use ConfigArgParse to create Config #86
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
Conversation
* The default config is invalid. There is nothing in the default configuration which is required to run otava. It seems to be here as a kind of example, or pseudo documentation of configuration options. * In order to get the basic CLI to work without a real configuration, log a warning and return an 'empty' configuration. Without any tests or test groups defined, this will let all of the commands function in a no-op way.
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.
Nice! This looks even better than I expected :-) But the ConfigArgParse library never failed me, so shouldn't be surprised.
For the nested settings, I would say don't be afraid to just flatten or otherwise change the structure of the config file. To me, that was kind of the point of doing the previous release, that now we have a release that is compatible with the past, and from here we can break compatibility if it makes Otava better in some ways.
I think there was something in the yaml configuration files - maybe it was the template system and how you configured each test... Where I felt that is probably best left as it is, "yaml only". I don't see it in this patch, so maybe that's because you likewise left those out of scope for this patch?
Btw, I never used Otava with these configuration files myself. I only ever saw you do it when I was at Datastax. (At Nyrkiö we use Otava as a python library.)
otava/main.py
Outdated
from datetime import datetime, timedelta | ||
from typing import Dict, List, Optional | ||
|
||
import configargparse |
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.
Actually it is common to import configargparse as argparse
to avoid having to change the rest of the code.
Personally I quite like the nested structure of the config. IMO it's worth the custom parser.
I haven't touched how the I have an itch to separate those from the config, but that would probably be best as a separate PR. |
… dash cli flag style, fixup bigquery project_id to match config from example
@henrikingo I think this is ready for another round of review. @Gerrrr I'd appreciate your feedback too. |
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.
+1
If @Gerrrr doesn't reply soon just merge since this fixes pretty annoying behavior
I will only be able to review this PR closer to the end of next week. Since @henrikingo reviewed it, there is no need to wait for me. |
It's allowed to review also after merging. But this is fairly straightforward adoption of configargparse. Good work Sean. |
See #82.
Took a stab at this. I fear I've misunderstood the goal:
I've pushed the entire creation of the config object through ConfigArgParse. It feels a bit unwieldy, or... square peg through a round hole? So I'm not super attached to this implementation. Still, putting it up for consideration / reference.
Pros:
otava --help
:Help Output
Cons:
parse_known_args
to avoid exceptions from parts of the config we don't want to include in the CLI (tests, templates, test_groups)If we do want to pursue this implementation, I'll flesh out the unit tests more. So far I've only added enough to validate the basics.