-
Notifications
You must be signed in to change notification settings - Fork 19
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: show loading progress #197
base: main
Are you sure you want to change the base?
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.
This is a good start, thanks!
Left some suggestions on how to improve it further.
src/backend.rs
Outdated
match self { | ||
LoadingStep::LoadingConfiguration => 0.0, | ||
LoadingStep::ReadingConfiguration => 5.0, | ||
LoadingStep::ConfigurationReadSuccessfully { | ||
configuration_exists: _, | ||
} => 10.0, | ||
LoadingStep::CheckingConfiguration => 15.0, | ||
LoadingStep::ConfigurationIsValid => 20.0, | ||
LoadingStep::DecodingChainSpecification => 25.0, | ||
LoadingStep::DecodedChainSpecificationSuccessfully => 30.0, | ||
LoadingStep::CheckingNodePath => 35.0, | ||
LoadingStep::CreatingNodePath => 40.0, | ||
LoadingStep::NodePathReady => 45.0, | ||
LoadingStep::PreparingNetworkingStack => 50.0, | ||
LoadingStep::ReadingNetworkKeypair => 55.0, | ||
LoadingStep::GeneratingNetworkKeypair => 60.0, | ||
LoadingStep::WritingNetworkKeypair => 65.0, | ||
LoadingStep::InstantiatingNetworkingStack => 70.0, | ||
LoadingStep::NetworkingStackCreatedSuccessfully => 75.0, | ||
LoadingStep::CreatingConsensusNode => 85.0, | ||
LoadingStep::ConsensusNodeCreatedSuccessfully => 90.0, | ||
LoadingStep::CreatingFarmer => 95.0, | ||
LoadingStep::FarmerCreatedSuccessfully => 100.0, | ||
LoadingStep::WipingFarm { | ||
farm_index: _, | ||
path: _, | ||
} => 0.0, | ||
LoadingStep::WipingFarmSuccessfully => 50.0, | ||
LoadingStep::WipingNode { path: _ } => 80.0, | ||
LoadingStep::WipingNodeSuccessfully => 100.0, |
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.
Naively you'd think this would work, but it is far from accurate. Different steps take different amount of time and thus progress with fixed 5% between steps is not accurate.
Also it doesn't account for the fact that there could be multiple steps in node creation and it definitely doesn't account for how many farms there are. If you have one farm and 20 it will take vastly different amount of time to complete that step. I see that you take that into consideration below, but it is still 5% for all farms in total.
This is why #133 says to do estimation first and scale everything accordingly to show realistic progress.
src/frontend/loading.rs
Outdated
gtk::ProgressBar { | ||
#[watch] | ||
set_fraction: model.progress, | ||
set_show_text: true, | ||
}, |
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 may have not been super clear, but the goal wasn't necessarily to remove the spinner.
While it is probably fine to do the way you did it, I was thinking about high-level steps shown with spinner and detailed steps below progress bar.
High level step would be "Creating farmer" and low-level would be creation and benchmarking of individual farms under that farmer.
Like title and subtitle if it makes sense.
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.
at first i want to implement a spinner like this
GTK does not have native support.
and i am not think its a better idea to use title and subtitle. Implementing a complex solution may not provide much greater help. I think using a progress bar is more suitable, implementing a spinner with a similar effect as shown above could work as well. this will more friendly for both small farm and big farm.
for a more accurate for each farm, maybe need move LoadingStep type to backend, or add a notify in backend/farmer.rs file. but benchmarking need more deep change in farmer.
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.
That is too complex for this purpose, not worth it.
I think simply adding title with main step above progress bar and making text below progress bar describing smaller inner steps will be sufficient.
For benchmarking we will indeed have to modify a farmer since it doesn't expose that information at the moment.
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.
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.
Yes, exactly!
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.
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.
Makes sense overall, though more farms does mean we will spend more time there, so if node fraction is decreased proportionally it'll make things more realistic, but I'm fine with it either way for initial version.
e16b2e5
to
056d09d
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.
Thanks for making progress here and feel free to re-request review, there is a button on GitHub for this so I get a notification when you think PR is ready for review
@@ -201,6 +226,7 @@ pub enum BackendNotification { | |||
#[allow(dead_code)] |
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.
This and above TODO should be removed by this PR
} | ||
LoadingStep::DecodedChainSpecificationSuccessfully => { | ||
"Decoded chain specification successfully".to_string() | ||
"Decoding chain specification".to_string() |
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.
This change needs to be reverted
- LoadingStep::FarmerCreatedSuccessfully.percentage()) | ||
/ (disk_farms.len() as f32); | ||
|
||
let notifications = Arc::new(farmer::Notifications::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.
Please don't do this, this is not not notifications are supposed to work. There are already subscriptions for existing notifications, just follow that pattern instead of breaking abstractions.
@@ -616,7 +642,8 @@ async fn load_configuration( | |||
notifications_sender | |||
.send(BackendNotification::Loading { | |||
step: LoadingStep::LoadingConfiguration, | |||
progress: 0.0, | |||
progress: LoadingStep::LoadingConfiguration.percentage(), | |||
message: "loading configuration ...".to_string(), |
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 see all of these messages were copied from another file, but why did you remove capitalization everywhere?:
message: "loading configuration ...".to_string(), | |
message: "Loading configuration ...".to_string(), |
WipingNode { | ||
path: PathBuf, | ||
}, | ||
WipingFarm, |
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 don't think it is the right change to remove properties from this enum variant. In fact I think more variants should have more properties here!
Instead of sending message
to the frontend, you should send LoadingStep
such that there is enough information for frontend to render the message (kind of like it was before). Backend should not be responsible to rendering user-facing messages for frontend, there is a separation of responsibilities here.
step
should contain all the information necessary. Moreover, since you have decided to add percentage
as a field on this enum, progress
field is not necessary either, step.progress()
can be called by UI to render progress accordingly.
@@ -668,10 +668,18 @@ impl App { | |||
fn process_backend_notification(&mut self, notification: BackendNotification) { | |||
match notification { | |||
// TODO: Render progress |
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.
Again, once you implement rendering of progress, remove corresponding TODOs
Resolves #133. change spinner to progressbar.