Skip to content
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(client): implement ClientOperationCfg to control any client oper… #2657

Open
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

RolandSherwin
Copy link
Member

No description provided.

@RolandSherwin RolandSherwin force-pushed the uploader_metrics branch 3 times, most recently from 9be3586 to 33b97f4 Compare January 23, 2025 18:57
@RolandSherwin RolandSherwin force-pushed the uploader_metrics branch 2 times, most recently from 30e7793 to 1b159fe Compare January 29, 2025 15:46
Copy link
Member

@grumbach grumbach left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good work! Couple of areas where I have doubts and questions.

ant-cli/src/commands/file.rs Show resolved Hide resolved
autonomi/src/client/config.rs Show resolved Hide resolved
autonomi/src/client/data_types/chunk.rs Outdated Show resolved Hide resolved
autonomi/src/client/data_types/graph.rs Outdated Show resolved Hide resolved
autonomi/src/client/data_types/pointer.rs Show resolved Hide resolved
@grumbach grumbach self-requested a review January 31, 2025 02:28
Comment on lines -696 to -711
// loud mode: print a celebratory message to console
#[cfg(feature = "loud")]
{
println!("🌟🌟🌟🌟🌟🌟🌟🌟🌟🌟 RECEIVED REWARD 🌟🌟🌟🌟🌟🌟🌟🌟🌟🌟");
println!(
"Total payment of {reward_amount:?} atto tokens accepted for record {pretty_key}"
);
println!("🌟🌟🌟🌟🌟🌟🌟🌟🌟🌟🌟🌟🌟🌟🌟🌟🌟🌟🌟🌟🌟🌟🌟🌟🌟🌟🌟🌟🌟🌟🌟🌟🌟");
}

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wait this is useful, please keep it

Comment on lines +77 to +81
if json {
download_output.print_json();
} else {
download_output.print();
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can't this be part of client config so we don't need to carry around a json bool?

@@ -23,7 +23,6 @@ name = "put_and_dir_upload"
default = []
external-signer = ["ant-evm/external-signer"]
extension-module = ["pyo3/extension-module"]
loud = []
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This feature is very useful for local testing for us, I think we should keep it around. Most users will never us it but that's fine, it's off by default.

Comment on lines -164 to -169
#[cfg(feature = "loud")]
println!(
"Uploading public archive referencing {} files",
archive.map().len()
);

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Although I agree it's not the prettiest way to do it, it's an excellent UX for CLI. Until we find another way I think we need to keep it

Comment on lines -105 to -106
#[cfg(feature = "loud")]
println!("Upload completed in {:?}", start.elapsed());
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here

Comment on lines -131 to -132
#[cfg(feature = "loud")]
println!("Uploading file: {path:?}");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here

Comment on lines -323 to +337
.expect("receiver should not close");
.expect("Could not send TimedOutWithIncompatibleProtocol, receiver should not close");
} else {
sender
.send(Err(ConnectError::TimedOut))
.expect("receiver should not close");
.expect("Could not send TimedOut, receiver should not close");
}
}
}
event = event_receiver.recv() => {
let event = event.expect("receiver should not close");
let event = event.expect("Could not receiver Network event, receiver should not close");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Although this originates not in this PR, I suggest we BAN expect altogether as they do fail sometimes!

@@ -27,7 +27,7 @@ ant-bootstrap = { path = "../ant-bootstrap", version = "0.1.4" }
ant-build-info = { path = "../ant-build-info", version = "0.1.23" }
ant-logging = { path = "../ant-logging", version = "0.2.45" }
ant-protocol = { path = "../ant-protocol", version = "0.3.3" }
autonomi = { path = "../autonomi", version = "0.3.5", features = [ "loud" ] }
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This feature although I agree not the most elegant way to do it, made the UX great. Removing it will result in a frustrating user experience while waiting for uploads.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also not a proponent of removing this. Users on the forum are already showing a lack of understanding what's happening when using the CLI.

Comment on lines -369 to -371
#[cfg(feature = "loud")]
println!("Estimated network size: {estimated_network_size:?}");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This too is very useful for local tests

Comment on lines -245 to -248
#[cfg(feature = "loud")]
println!("New peer added to routing table: {added_peer:?}, now we have #{n_peers} connected peers");

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This too

Comment on lines 438 to 302
#[cfg(feature = "loud")]
{
println!("Multiaddr not supported : {addr:?}");
println!("If this was your bootstrap peer, restart your node with a supported multiaddr");
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This as well

@@ -27,7 +27,7 @@ ant-bootstrap = { path = "../ant-bootstrap", version = "0.1.4" }
ant-build-info = { path = "../ant-build-info", version = "0.1.23" }
ant-logging = { path = "../ant-logging", version = "0.2.45" }
ant-protocol = { path = "../ant-protocol", version = "0.3.3" }
autonomi = { path = "../autonomi", version = "0.3.5", features = [ "loud" ] }
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also not a proponent of removing this. Users on the forum are already showing a lack of understanding what's happening when using the CLI.

.await
.wrap_err("Failed to fetch data from address")?;
.map_err(|err| {
error!("Failed to fetch archive from address: {private_address:?}");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use inspect_err to report errors.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We actually map the error to a different type here, so it should be fine for the logging to go in here I think.

std::fs::write(path, bytes)?;
progress_bar.clone().inc(1);
std::fs::create_dir_all(parent).map_err(|err| {
error!("Failed to create parent directories for {path:?}: {err}");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use inspect_err

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as above, we actually map the error to a different type here, so it should be fine for the logging to go in here.

(err.into(), all_errs.clone())
})?;
std::fs::write(&path, bytes).map_err(|err| {
error!("Failed to write file {path:?}: {err}");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use inspect_err

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as above.

.wrap_err("Failed to fetch data from address")?;
) -> Result<(), (DownloadError, Vec<(String, String)>)> {
let archive = client.archive_get_public(address).await.map_err(|err| {
error!("Failed to fetch archive from address: {address:?}");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use inspect_err.

std::fs::write(path, bytes)?;
progress_bar.clone().inc(1);
std::fs::create_dir_all(parent).map_err(|err| {
error!("Failed to create parent directories for {path:?}: {err}");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use inspect_err.

(err.into(), all_errs.clone())
})?;
std::fs::write(&path, bytes).map_err(|err| {
error!("Failed to write file {path:?}: {err}");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use inspect_err.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants