-
Notifications
You must be signed in to change notification settings - Fork 0
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
ENG-833: Create config file for additional configuration options. #138
base: main
Are you sure you want to change the base?
ENG-833: Create config file for additional configuration options. #138
Conversation
- Added a new configuration mode - via a TOML file. - Added a config directory with sample `config.toml.example` file. - Added `core` and `extra` sections in the TOML config file. - The order of priority (CLI > ENV > TOML > DEFAULTS) is maintained. - Converted the existing `Config` to use `clap` builder mode. - Change `BLOCK_CACHE_SIZE` to `BLOCK_CACHE_COUNT` to make it uniform. - Changed `BLOCK_TXN_COUNT` env to `BLOCK_TXNS_COUNT` to make it uniform. - Added missing help for `BLOCK_CACHE_COUNT`. - Added error type for configuration errors. - Renamed `Command` in config to `PolybaseCommand` to avoid confusion. - Updated uses in `main.rs`.`
ENG-833 Create config file for additional configuration options
ProblemCurrently we use Requirements
|
Keeping the PR open here while I work on the failing tests and clippy fixes, plus thorough testing to ensure existing behaviour is maintained. |
- fixed Clippy issues.
- Fixes failing api tests: changed `restrict-namespaces to flag instead of an option.`
Tests fixed. Will test thoroughly tomorrow. |
- Fixed incorrect path for TOML config file - moved to `root_dir/config/config.toml` - Removed `root_dir` option from TOML config (due to the above constraint)
Fixed basic bug in config file location, tested. Ready for review. |
One of the things I wanted to avoid, was having the clap/toml in two places, as that means you have to update to places for every config change. Is there any way around that? |
(Assuming you are referring to the duplication of the I did explore that as well while experimenting. I saw a few issues unifying the config into a single one: The biggest potential change would be the API. Basically, all of the possible options would have to become NOTE: This may be possible if we simply read the contents of the TOML file as raw |
- Changed the toml config logic to use the common `Config` struct. - Added better validation and error-handling for TOML.
I made a few changes in my local branch:
However, from the usage perspective, if we make changes to the "core" (i.e., current) set of configurations, we will still need to make code changes in the toml config as well, but the changes to the Ideally, it would have been nice to be able to extend clap's (derive mode) from:
to something like:
but unfortunately |
- Fixed Clippy warnings.
Yeah, we could write our own directive macro that runs on top, something like this: #[toml(path = "log_level", default_value="INFO")]
#[arg(value_enum, long, env = "LOG_LEVEL", default_value = "INFO")] // new `toml` attribute
pub log_level: LogLevel, Or another option could be to implement our own directive macro, that converts the struct into some code that generates clap code + toml code in one: #[our_macro(value_enum, long, env = "LOG_LEVEL", toml = "log_level", default_value = "INFO")]
pub log_level: LogLevel, You might be able to get chat-gpt to help you with this (you have to be persistent with it, and keep asking for more detail): https://sharegpt.com/c/6yFeUnt This might be quite complex to code though, so maybe do some initial investigations and report back. |
Changes:
Config
API is maintained as is (with the change toCommand
).config.toml.example
file.core
andextra
sections in the TOML config file. Onlycore
is used for now; also using static keys (struct)for TOML instead of as HashMap (say) for better type checking.
Config
to useclap
builder mode.BLOCK_CACHE_SIZE
toBLOCK_CACHE_COUNT
to make it uniform.BLOCK_TXN_COUNT
env toBLOCK_TXNS_COUNT
to make it uniform.BLOCK_CACHE_COUNT
.Command
in config toPolybaseCommand
to avoid confusion.main.rs
.`Status: Open for review.