forked from bitcoin-dev-project/sim-ln
-
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
feat: add simulation config #1
Closed
Extheoisah
wants to merge
7
commits into
bitcoin-dev-project-fresheyes-staging-main-166
from
enigbe-fresheyes-staging-feat-add-simulation-config-166
Closed
feat: add simulation config #1
Extheoisah
wants to merge
7
commits into
bitcoin-dev-project-fresheyes-staging-main-166
from
enigbe-fresheyes-staging-feat-add-simulation-config-166
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- loads config options from a file and overwrites with CLI args - adds configurable log interval -change configuration file type by doing the ffg: replacing conf.json with conf.ini, updating SimulationConfig::load(...) to read the new .ini file, implementing cli_overwrite!(...) macro to reduce LOC when overwriting config values with CLI arguments
- Implements a Cli::from_config_file(...) method to load configuration options from either a default or user-provided (via command line argument) config file - Merges the Cli-s generated from the config file and the parsed command line arguments taking into account the following precedence (command line args > configuration options > default value) - deletes config.rs and the former implementation that loads configuration options into a Simulation- Config struct
- The latter allows dynamic, programmatic updates to the log level at runtime. - The replace was necessary to capture and log command line arguments and configuration options which may or may not contain specification of the log levels after parsing
- additionally reduces the LOC by implementing the overwrite_field!(...) macro and from_config_field(...) generic function. - makes the requirement of a configuration file optional, defaulting to default Cli values if no config file is provided
An author commented here with:
|
An author commented here with:
|
@@ -0,0 +1,10 @@ | |||
[simln.conf] | |||
data_dir = "." |
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.
An author commented here with:
- comment link
https://github.com/bitcoin-dev-project/sim-ln/pull/166#discussion_r1486404657
at 2024/02/12, 16:08:13 UTC.
pub const ACTIVITY_MULTIPLIER: f64 = 2.0; | ||
|
||
/// Default batch size to flush result data to disk | ||
const DEFAULT_PRINT_BATCH_SIZE: u32 = 500; |
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.
2 authors commented here with:
- comment link
https://github.com/bitcoin-dev-project/sim-ln/pull/166#discussion_r1486738554
at 2024/02/12, 20:30:47 UTC - comment link
https://github.com/bitcoin-dev-project/sim-ln/pull/166#discussion_r1519710853
at 2024/03/11, 13:23:17 UTC.
Extheoisah
deleted the
enigbe-fresheyes-staging-feat-add-simulation-config-166
branch
March 18, 2024 18:52
Extheoisah
restored the
enigbe-fresheyes-staging-feat-add-simulation-config-166
branch
March 18, 2024 19:30
Extheoisah
deleted the
enigbe-fresheyes-staging-feat-add-simulation-config-166
branch
March 18, 2024 19:39
Extheoisah
restored the
enigbe-fresheyes-staging-feat-add-simulation-config-166
branch
March 18, 2024 19:41
Extheoisah
deleted the
enigbe-fresheyes-staging-feat-add-simulation-config-166
branch
March 18, 2024 19:46
Extheoisah
restored the
enigbe-fresheyes-staging-feat-add-simulation-config-166
branch
March 18, 2024 19:57
Extheoisah
deleted the
enigbe-fresheyes-staging-feat-add-simulation-config-166
branch
March 21, 2024 09:44
Extheoisah
restored the
enigbe-fresheyes-staging-feat-add-simulation-config-166
branch
March 21, 2024 09:52
Extheoisah
deleted the
enigbe-fresheyes-staging-feat-add-simulation-config-166
branch
March 21, 2024 13:04
Extheoisah
restored the
enigbe-fresheyes-staging-feat-add-simulation-config-166
branch
March 21, 2024 13:06
Extheoisah
deleted the
enigbe-fresheyes-staging-feat-add-simulation-config-166
branch
March 27, 2024 13:08
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
##
What this PR does -Adds aLoads config values from an optionalSimulationConfig
struct thatINI
file and overwrites these values if corresponding command line arguments are passed - The config file contains custom values for the simulationini [simln.conf] data_dir = "." sim_file = "sim.json" total_time= print_batch_size = 500 log_level = "info" expected_pmt_amt = 3800000 capacity_multiplier = 2 no_results = false log_interval = 60
- Makes configurable thelog_interval
after which results are logged##
Related Issue(s) - Resolves#157
##
Update - This PR has changed to consider a standard way of handling configuration files as well as command line arguments. It currently introduces functionality to create and parse theCli
from an optionally-provided config file, to merge thisCli
with that parsed from command line arguments, and to grant precedence to the options/values in the latter. - Secondly, this PR also replaces the logging crate fromsimple_logger
toflexi_logger
.flexi_logger
allows dynamic update of log levels after initialization and was required to deal with the issue described here. - Finally, documentation was updated to reflect the introduction and use of a config file. Note: There are some changes to unrelated files because of the requirement to wrap maximum width of code and comments at 120 column spaces. Thought to include them regardless following conversation from#164
on maintaining width.