-
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
build: make log level depend on input #313
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #313 +/- ##
==========================================
+ Coverage 70.59% 71.03% +0.43%
==========================================
Files 38 38
Lines 2095 2154 +59
Branches 2095 2154 +59
==========================================
+ Hits 1479 1530 +51
- Misses 546 558 +12
+ Partials 70 66 -4 ☔ View full report in Codecov by Sentry. |
23ffcf5
to
56575fd
Compare
Benchmark movements: |
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.
python side PR
Reviewable status: 0 of 7 files reviewed, all discussions resolved (waiting on @dorimedini-starkware)
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.
Reviewable status: 0 of 7 files reviewed, 1 unresolved discussion (waiting on @dorimedini-starkware)
crates/committer/src/block_committer/input.rs
line 70 at r1 (raw file):
40 => LevelFilter::Error, _ => panic!("Unexpected log level."), };
@dorimedini-starkware, do you know a better way to do that?
Code quote:
pub fn new(warn_on_trivial_modifications: bool, python_logger_level: usize) -> Self {
let log_level = match python_logger_level {
10 => LevelFilter::Debug,
20 => LevelFilter::Info,
30 => LevelFilter::Warn,
40 => LevelFilter::Error,
_ => panic!("Unexpected log level."),
};
56575fd
to
a4006c4
Compare
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.
Reviewed 6 of 7 files at r1, 1 of 1 files at r2, all commit messages.
Reviewable status: all files reviewed, 4 unresolved discussions (waiting on @nimrod-starkware)
crates/committer/src/block_committer/input.rs
line 70 at r1 (raw file):
Previously, nimrod-starkware wrote…
@dorimedini-starkware, do you know a better way to do that?
- what about NOTSET and CRITICAL python levels? if you can set it in python, it should be accepted here.
- since you use "magic numbers" in the test below, I would even suggest you add a
PythonLogLevel
enum, and add to/from conversions forusize
. You can also add conversion toLevelFilter
, to end up with something like this:
pub fn new(warn_on_trivial_modifications: bool, python_logger_level: PythonLogLevel)
Self {
warn_on_trivial_modifications,
log_level: python_logger_level.into(),
}
}
and to construct a ConfigImpl
from python input (for example):
ConfigImpl::new(warn_on_trivial, python_level_usize.into());
and in tests, use the enum explicitly so it's clear to the reader:
config: ConfigImpl::new(true, PythonLogLevel::Debug),
crates/committer/src/block_committer/input.rs
line 69 at r2 (raw file):
30 => LevelFilter::Warn, 40 => LevelFilter::Error, _ => panic!("Unexpected log level."),
I wouldn't want to ever panic due to bad logger settings... worst case log a warning/error and set the level to DEBUG
Code quote:
_ => panic!("Unexpected log level."),
crates/committer/src/patricia_merkle_tree/original_skeleton_tree/skeleton_forest_test.rs
line 168 at r2 (raw file):
contracts_trie_root_hash: HashOutput(Felt::from(861_u128 + 248_u128)), classes_trie_root_hash: HashOutput(Felt::from(155_u128 + 248_u128)), config: ConfigImpl::new(true, 10),
see above
Code quote:
10
crates/committer/src/patricia_merkle_tree/original_skeleton_tree/skeleton_forest_test.rs
line 290 at r2 (raw file):
&input.state_diff.actual_classes_updates(), &forest_sorted_indices, &ConfigImpl::new(false, 20),
see above
Code quote:
20
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.
Reviewable status: all files reviewed, 4 unresolved discussions (waiting on @dorimedini-starkware)
crates/committer/src/block_committer/input.rs
line 70 at r1 (raw file):
Previously, dorimedini-starkware wrote…
- what about NOTSET and CRITICAL python levels? if you can set it in python, it should be accepted here.
- since you use "magic numbers" in the test below, I would even suggest you add a
PythonLogLevel
enum, and add to/from conversions forusize
. You can also add conversion toLevelFilter
, to end up with something like this:pub fn new(warn_on_trivial_modifications: bool, python_logger_level: PythonLogLevel) Self { warn_on_trivial_modifications, log_level: python_logger_level.into(), } }
and to construct a
ConfigImpl
from python input (for example):ConfigImpl::new(warn_on_trivial, python_level_usize.into());
and in tests, use the enum explicitly so it's clear to the reader:
config: ConfigImpl::new(true, PythonLogLevel::Debug),
I changed RawConfigImpl
to:
pub(crate) struct RawConfigImpl {
warn_on_trivial_modifications: bool,
log_level: PythonLogLevel,
}
where
#[derive(Deserialize_repr, Debug, Serialize)]
#[repr(usize)]
/// Describes a log level https://docs.python.org/3/library/logging.html#logging-levels
pub(crate) enum PythonLogLevel {
NotSet = 0,
Debug = 10,
Info = 20,
Warning = 30,
Error = 40,
Critical = 50,
}
and added impl From<RawConfigImpl> for ConfigImpl
crates/committer/src/block_committer/input.rs
line 69 at r2 (raw file):
Previously, dorimedini-starkware wrote…
I wouldn't want to ever panic due to bad logger settings... worst case log a warning/error and set the level to DEBUG
Done.
crates/committer/src/patricia_merkle_tree/original_skeleton_tree/skeleton_forest_test.rs
line 168 at r2 (raw file):
Previously, dorimedini-starkware wrote…
see above
Done.
crates/committer/src/patricia_merkle_tree/original_skeleton_tree/skeleton_forest_test.rs
line 290 at r2 (raw file):
Previously, dorimedini-starkware wrote…
see above
Done.
a4006c4
to
fcaf1d1
Compare
Benchmark movements: |
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.
Reviewed 7 of 7 files at r3, all commit messages.
Reviewable status: all files reviewed, 2 unresolved discussions (waiting on @nimrod-starkware)
crates/committer/src/block_committer/input.rs
line 66 at r3 (raw file):
} } }
we do we not like this...? I see no reason to protect these members...
out of scope (requires changing all ::new
and all getter method usages) but good to keep in mind,
non-blocking
Suggestion:
#[derive(Debug, Eq, PartialEq)]
pub struct ConfigImpl {
pub warn_on_trivial_modifications: bool,
pub log_level: LevelFilter,
}
crates/committer_cli/src/parse_input/raw_input.rs
line 41 at r3 (raw file):
Error = 40, Critical = 50, }
what will happen if you send 7
and try to deserialize?
we don't want to panic in this case
Code quote:
#[repr(usize)]
/// Describes a log level https://docs.python.org/3/library/logging.html#logging-levels
pub(crate) enum PythonLogLevel {
NotSet = 0,
Debug = 10,
Info = 20,
Warning = 30,
Error = 40,
Critical = 50,
}
fcaf1d1
to
181d629
Compare
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.
Reviewable status: 8 of 10 files reviewed, 2 unresolved discussions (waiting on @dorimedini-starkware)
crates/committer_cli/src/parse_input/raw_input.rs
line 41 at r3 (raw file):
Previously, dorimedini-starkware wrote…
what will happen if you send
7
and try to deserialize?
we don't want to panic in this case
Now, it will not panic; if an unknown variant is given, it will be set to the Debug
level by default.
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.
Reviewable status: 8 of 10 files reviewed, 2 unresolved discussions (waiting on @dorimedini-starkware)
crates/committer/src/block_committer/input.rs
line 66 at r3 (raw file):
Previously, dorimedini-starkware wrote…
we do we not like this...? I see no reason to protect these members...
out of scope (requires changing all::new
and all getter method usages) but good to keep in mind,
non-blocking
The getters are for the Config
trait...
But I agree there is no need to keep those fields private..
Benchmark movements: full_committer_flow performance regressed! |
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.
Reviewed 2 of 2 files at r4, all commit messages.
Reviewable status:complete! all files reviewed, all discussions resolved (waiting on @nimrod-starkware)
This change is![Reviewable](https://camo.githubusercontent.com/1541c4039185914e83657d3683ec25920c672c6c5c7ab4240ee7bff601adec0b/68747470733a2f2f72657669657761626c652e696f2f7265766965775f627574746f6e2e737667)