-
Notifications
You must be signed in to change notification settings - Fork 122
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
Make quantity field human readable #891
Make quantity field human readable #891
Conversation
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.
Thanks!
Reviewable status: 0 of 1 LGTMs obtained, and pending CI: Bazel Dev / ubuntu-22.04, Publish image, Publish nativelink-worker-lre-cc, Remote / large-ubuntu-22.04, asan / ubuntu-22.04, docker-compose-compiles-nativelink (20.04), docker-compose-compiles-nativelink (22.04), integration-tests (20.04), integration-tests (22.04), macos-13, pre-commit-checks, ubuntu-22.04, and 1 discussions need to be resolved
nativelink-config/src/serde_utils.rs
line 54 at r1 (raw file):
fn visit_str<E: de::Error>(self, mut v: &str) -> Result<Self::Value, E> { println!("We're supposed to be here {}", v); match v.chars().last().unwrap() {
I think we should make a new functions for these, like: convert_duration_with_shellexpand
and convert_data_size_with_shellexpand
bd18969
to
07f285e
Compare
Hi @allada, |
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.
We don't have a test for this, but it'd be trivial to make one.
Pretty much it'd be to take this function (but change it so it passes in a string):
nativelink/src/bin/nativelink.rs
Line 808 in c1d0402
async fn get_config() -> Result<CasConfig, Box<dyn std::error::Error>> { |
And put it into nativelink-config
, then a config like this should properly populate:
{
"global": {
"default_digest_size_health_check": "5mb"
}
}
Reviewable status: 0 of 1 LGTMs obtained, and pending CI: Bazel Dev / ubuntu-22.04, Publish image, Publish nativelink-worker-lre-cc, Remote / large-ubuntu-22.04, asan / ubuntu-22.04, docker-compose-compiles-nativelink (20.04), docker-compose-compiles-nativelink (22.04), integration-tests (20.04), integration-tests (22.04), macos-13, pre-commit-checks, ubuntu-22.04, and 1 discussions need to be resolved
I am currently trying to get
I am not too sure what this means since it looks fine to my human eye. Maybe I forgot to update some settings? |
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.
You need to run the formatter:
https://github.com/TraceMachina/nativelink/blob/main/CONTRIBUTING.md#fixing-rust-formatting
Looks great though! Maybe 1 test would be useful, but not required. I don't think we test the other fields here, so only do it if you want to learn how to write a new test.
Reviewed 2 of 3 files at r1, 4 of 4 files at r2, all commit messages.
Reviewable status: 0 of 1 LGTMs obtained, and pending CI: Bazel Dev / ubuntu-22.04, Publish image, Publish nativelink-worker-lre-cc, Remote / large-ubuntu-22.04, asan / ubuntu-22.04, docker-compose-compiles-nativelink (20.04), docker-compose-compiles-nativelink (22.04), integration-tests (20.04), integration-tests (22.04), macos-13, pre-commit-checks, ubuntu-22.04, and 4 discussions need to be resolved
-- commits
line 2 at r2:
nit: Please expand this comment out a bit more to explain what's being added.
nativelink-config/src/serde_utils.rs
line 172 at r2 (raw file):
fn visit_str<E: de::Error>(self, v: &str) -> Result<Self::Value, E> { let byte_size = Byte::parse_str(v, true).map_err(de::Error::custom);
nit: put question mark here instead of the line below.
nativelink-config/src/serde_utils.rs
line 174 at r2 (raw file):
let byte_size = Byte::parse_str(v, true).map_err(de::Error::custom); let byte_size_str = byte_size?.as_u64().to_string(); (*shellexpand::env(&byte_size_str).map_err(de::Error::custom)?)
This should be flipped around. Have it parse it from the shellexpand
, then have it convert the Byte::parse_str
. This will allow users to use environmental variables that contain things like 5mb
and it'll expand properly.
nativelink-config/src/serde_utils.rs
line 213 at r2 (raw file):
let duration = parse_duration(v).map_err(de::Error::custom); let duration_str = duration?.as_secs().to_string(); (*shellexpand::env(&duration_str).map_err(de::Error::custom)?)
nit: ditto from above.
cd9d91c
to
050f837
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 2 of 2 files at r3, all commit messages.
Reviewable status: 0 of 1 LGTMs obtained, and pending CI: Bazel Dev / ubuntu-22.04, Publish image, Publish nativelink-worker-lre-cc, Remote / large-ubuntu-22.04, asan / ubuntu-22.04, docker-compose-compiles-nativelink (20.04), docker-compose-compiles-nativelink (22.04), integration-tests (20.04), integration-tests (22.04), macos-13, ubuntu-22.04, and 3 discussions need to be resolved
nativelink-config/src/serde_utils.rs
line 174 at r3 (raw file):
let expanded = (*shellexpand::env(v).map_err(de::Error::custom)?).to_string(); let byte_size = Byte::parse_str(expanded, true).map_err(de::Error::custom)?; let byte_size_str = byte_size.as_u64().to_string();
Just convert this to a u128
then convert it directory into Self::Value
.
nativelink-config/src/serde_utils.rs
line 212 at r3 (raw file):
let expanded = (*shellexpand::env(v).map_err(de::Error::custom)?).to_string(); let duration = parse_duration(&expanded).map_err(de::Error::custom)?; let duration_str = duration.as_secs().to_string();
ditto, don't add .to_string()
The most convenient solution I came up with was:
What do you think? Also for the duration section, casting it seconds yields a |
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.
Either is fine. It appears internally to that library it uses u128, which is why I suggested u128.
Reviewable status: 0 of 1 LGTMs obtained, and pending CI: Bazel Dev / ubuntu-22.04, Publish image, Publish nativelink-worker-lre-cc, Remote / large-ubuntu-22.04, asan / ubuntu-22.04, docker-compose-compiles-nativelink (20.04), docker-compose-compiles-nativelink (22.04), integration-tests (20.04), integration-tests (22.04), macos-13, ubuntu-22.04, and 3 discussions need to be resolved
5ff4bef
to
a30503b
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 1 of 4 files at r4.
Reviewable status: 0 of 1 LGTMs obtained, and pending CI: Bazel Dev / ubuntu-22.04, Publish image, Publish nativelink-worker-lre-cc, Remote / large-ubuntu-22.04, asan / ubuntu-22.04, docker-compose-compiles-nativelink (20.04), docker-compose-compiles-nativelink (22.04), integration-tests (20.04), integration-tests (22.04), macos-13, ubuntu-22.04, and 3 discussions need to be resolved
nativelink-config/tests/deserialization_test.rs
line 1 at r4 (raw file):
use nativelink_config::serde_utils::{
nit: Please add copyright header.
nativelink-config/tests/deserialization_test.rs
line 6 at r4 (raw file):
#[cfg(test)] mod tests {
nit: To simplify this test a bit, can I suggest instead just write dummy configs in the test with the annotations (like in the config rust files), then convert json5-string to the structs then just ensure the structs match a ground truth?
a30503b
to
f33f0d2
Compare
I'm currently missing a test case for duration values. I haven't found any config files that could make use of duration units from here. Any idea on where I could get one? |
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 would instead just make the struct definition in the test file itself and decorate a few fields to test it. I would not test the config directly, that will create complex dependency issues.
Reviewable status: 0 of 1 LGTMs obtained, and pending CI: Bazel Dev / ubuntu-22.04, Publish image, Publish nativelink-worker-lre-cc, Remote / large-ubuntu-22.04, asan / ubuntu-22.04, docker-compose-compiles-nativelink (20.04), docker-compose-compiles-nativelink (22.04), integration-tests (20.04), integration-tests (22.04), macos-13, ubuntu-22.04, and 3 discussions need to be resolved
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 3 of 4 files at r2, 2 of 4 files at r4, 2 of 3 files at r5, all commit messages.
Reviewable status: 0 of 1 LGTMs obtained, and pending CI: Bazel Dev / ubuntu-22.04, Publish image, Publish nativelink-worker-lre-cc, Remote / large-ubuntu-22.04, asan / ubuntu-22.04, docker-compose-compiles-nativelink (20.04), docker-compose-compiles-nativelink (22.04), integration-tests (20.04), integration-tests (22.04), macos-13, ubuntu-22.04, and 3 discussions need to be resolved
7997f4e
to
a33e511
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.
Awesome! Thanks for the changes!
Reviewed 2 of 2 files at r6, all commit messages.
Reviewable status: 1 of 1 LGTMs obtained, and pending CI: Bazel Dev / ubuntu-22.04, Publish image, Publish nativelink-worker-lre-cc, Remote / large-ubuntu-22.04, asan / ubuntu-22.04, docker-compose-compiles-nativelink (20.04), docker-compose-compiles-nativelink (22.04), integration-tests (20.04), integration-tests (22.04), macos-13, ubuntu-22.04
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: 1 of 1 LGTMs obtained, and pending CI: Bazel Dev / ubuntu-22.04, Publish image, Publish nativelink-worker-lre-cc, Remote / large-ubuntu-22.04, asan / ubuntu-22.04, docker-compose-compiles-nativelink (20.04), docker-compose-compiles-nativelink (22.04), integration-tests (20.04), integration-tests (22.04), macos-13, ubuntu-22.04, and 1 discussions need to be resolved
a discussion (no related file):
It looks like there's some strange errors when building with bazel. Let me know if you need help figuring them out.
That's odd 🤔 FYI. I am using nix OS for dev. |
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.
Are you building with bazel or cargo? I suggest trying with bazel.
Reviewable status: 1 of 1 LGTMs obtained, and pending CI: Bazel Dev / ubuntu-22.04, Publish image, Publish nativelink-worker-lre-cc, Remote / large-ubuntu-22.04, asan / ubuntu-22.04, docker-compose-compiles-nativelink (20.04), docker-compose-compiles-nativelink (22.04), integration-tests (20.04), integration-tests (22.04), macos-13, ubuntu-22.04, and 1 discussions need to be resolved
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.
@matdexir I believe the Bazel errors are because the Cargo lockfile wasn't regenerated. Bazel reads the lockfile at
Line 53 in 64ed20a
cargo_lockfile = "//:Cargo.lock", |
To re-sync the Cargo.toml files with the lockfile, trycargo generate-lockfile
.
Reviewable status: 1 of 1 LGTMs obtained, and pending CI: Bazel Dev / ubuntu-22.04, Publish image, Publish nativelink-worker-lre-cc, Remote / large-ubuntu-22.04, asan / ubuntu-22.04, docker-compose-compiles-nativelink (20.04), docker-compose-compiles-nativelink (22.04), integration-tests (20.04), integration-tests (22.04), macos-13, ubuntu-22.04, and 1 discussions need to be resolved
a33e511
to
5812149
Compare
@matdexir do you need a hand further here? |
5812149
to
cab911e
Compare
Add support for human readable quantity field in the different json config, i.e, 10KB -> 10000. This implementation still allows for the field being pure unsigned integers, so, it can be seen as offering an alternative configuration.
cab911e
to
0611fcc
Compare
I think that it should be fixed now. I also have updated it to match the latest release. Let me know if the issue still lingers NOTE: Currently |
looks like you need to rebase @matdexir |
Already did |
7b87729
to
5d6afb6
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: 2 of 1 LGTMs obtained, and pending CI: Cargo Dev / macos-13, Remote / large-ubuntu-22.04, and 1 discussions need to be resolved
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.
Dismissed @allada from a discussion.
Reviewable status: complete! 2 of 1 LGTMs obtained
The bazel errors have subsided after a few updates to deps.
Add support for human readable quantity field in the different json config, i.e, 10KB -> 10000. This implementation still allows for the field being pure unsigned integers, so, it can be seen as offering an alternative configuration. Co-authored-by: Marcus Eagan <[email protected]>
Description
Allows for human readable quantity field in the different json config, i.e, 10KB -> 10000.
This implementation still allows for the field being pure unsigned integers, so, it can be seen as offering an alternative configuration
Fixes #862
Type of change
Please delete options that aren't relevant.
not work as expected)
How Has This Been Tested?
I tested it on a stripped version of basic_cas.json which allows for writing human readable units rather than large integer values.
Checklist
bazel test //...
passes locallygit amend
see some docsThis change is