-
Notifications
You must be signed in to change notification settings - Fork 4
feat: Setting configuration with JSON string #166
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
base: main
Are you sure you want to change the base?
Conversation
…e FIREWHEEL config.
I like that it will not require a user to have to pass the whole block to set one element. Do we need to consider whether there is ever a need to remove key-value pairs from the configuration? (In which case, this removes the method of just omitting it from the JSON as an option to accomplish that). Maybe we just say that a FIREWHEEL config should have all the settings defined, and so we don't support removing a field. Not sure that's best, because I don't know how a user would say "go back to the default" (other than checking the docs and manually setting it to that value, which seems like an unfriendly thing to do). If we do establish that expectation, it's probably worth being aware that the |
argparse.ArgumentTypeError: If the input string is not a valid JSON. | ||
""" | ||
try: | ||
return json.loads(json_string.replace("'", "")) |
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 not sure what the rationale behind this replacement is (I assume somewhere the command line passes unwanted single-quotes).
Since it's applied to the entire string, do we need to make a note somewhere that single quotes are not permitted in any of the config values? I don't know why a user would ever add a single quote to any of the values we offer right now, but if they did (or we add a config value where they might), I think this will silently just remove it...
Looks good to me other than the comments above. To be "that guy", do we need/want a test or two? |
While I don't like adding another dependency, this would "only" be the case for the CI, and won't impact end users. Additionally, this would be a wholly optional thing for users. Another benefit to this approach is less code maintenance that we have to write, which is always a positive. On the other hand, I'm going to play with |
This PR adds the ability for users to take in a properly formatted JSON string and set the FIREWHEEL configuration.
This JSON string will set/replace a subset of the configuration and any keys or sub-keys (or sub-sub-keys) not present will not be impacted or overwritten.
The string must include the top-level config key as well as any sub-keys needing modifications.
For example, to change the value for the config key
logging.level
from DEBUG to INFO, here is how that would not look:Before Config
After Config