Skip to content

Commit

Permalink
Refactor project structure and update dependencies
Browse files Browse the repository at this point in the history
This commit refactors the project structure by renaming several packages and
modules to improve clarity and consistency. It also updates various
dependencies to their latest versions, ensuring compatibility and taking
advantage of new features and improvements. The changes include:

- Renaming packages and modules for better clarity
- Updating dependencies in Cargo.toml files
- Modifying import paths to reflect new package names
- Adjusting CSS styles for improved UI consistency
- Enhancing benchmark selection logic in the frontend
- Adding new components for server stats display
  • Loading branch information
hubcio committed Feb 3, 2025
1 parent 7870d3f commit 12708fe
Show file tree
Hide file tree
Showing 46 changed files with 1,007 additions and 535 deletions.
243 changes: 140 additions & 103 deletions Cargo.lock

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
[workspace]
members = ["frontend", "runner", "server"]
members = ["frontend", "runner", "server", "shared"]
resolver = "2"

[workspace.package]
version = "0.2.3"
version = "0.2.4"
edition = "2021"
license = "Apache-2.0"

[workspace.dependencies]
iggy-benchmark-report = { git = "https://github.com/iggy-rs/iggy.git", version = "0.1.2" }
iggy-bench-report = { git = "https://github.com/iggy-rs/iggy.git", version = "0.2.0" }
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ All endpoints return JSON responses (except artifacts which returns a ZIP file)
Allows to run and collect performance results for multiple gitrefs back:

```bash
cargo run --bin iggy-dashboard-bench-runner -- --directory ~/rust/iggy --count 10 --gitref master --skip-master-check
cargo run --bin iggy-bench-runner -- --directory ~/rust/iggy --count 10 --gitref master --skip-master-check
out --output-dir performance_results
```

Expand Down
6 changes: 3 additions & 3 deletions frontend/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
[package]
name = "iggy-benchmarks-dashboard-frontend"
name = "iggy-bench-dashboard-frontend"
license = "Apache-2.0"
version.workspace = true
edition.workspace = true

[dependencies]
charming = { version = "0.4.0", features = ["wasm"] }
gloo = "0.11"
iggy-benchmark-report = { workspace = true }
iggy-bench-report = { workspace = true }
js-sys = "0.3"
shared = { path = "../shared" }
iggy-bench-dashboard-shared = { path = "../shared" }
thiserror = "2.0"
wasm-bindgen = "0.2"
web-sys = { version = "0.3", features = [
Expand Down
75 changes: 72 additions & 3 deletions frontend/assets/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,9 @@ body {
}

.sidebar {
min-width: var(--sidebar-min-width);
width: fit-content;
max-width: var(--sidebar-max-width);
width: 500px;
min-width: unset;
max-width: unset;
background-color: var(--color-sidebar);
padding: var(--spacing-xl);
border-right: 1px solid var(--color-border);
Expand Down Expand Up @@ -1022,3 +1022,72 @@ body.dark .footer .gitref {
background-color: var(--color-dark-active);
border-color: var(--color-dark-border);
}

.server-stats-button {
display: flex;
align-items: center;
justify-content: center;
width: var(--button-size);
height: var(--button-size);
border: 1px solid var(--color-border);
border-radius: var(--border-radius);
background: none;
color: var(--color-text);
cursor: pointer;
transition: all 0.2s ease;
padding: 0;
margin: 0 var(--spacing-xs);
}

.server-stats-button:hover:not(:disabled) {
background-color: var(--color-hover);
border-color: var(--color-text-secondary);
}

.server-stats-button:disabled {
opacity: 0.5;
cursor: not-allowed;
}

.dark .server-stats-button {
color: var(--color-dark-text);
border-color: var(--color-dark-border);
}

.dark .server-stats-button:hover:not(:disabled) {
background-color: var(--color-dark-hover);
border-color: var(--color-dark-text-secondary);
}

.dark .server-stats-button:disabled {
opacity: 0.5;
cursor: not-allowed;
}

/* Position server stats tooltip to match benchmark info tooltip */
.server-stats-position {
right: 2px !important;
left: auto !important;
top: calc(100% + var(--spacing-md)) !important;
transform: none !important;
}

/* Adjust arrow for server stats tooltip */
.server-stats-position:before {
left: auto !important;
right: var(--spacing-md) !important;
top: -8px !important;
transform: rotate(45deg) !important;
}

.server-stats-position:after {
left: auto !important;
right: var(--spacing-md) !important;
top: -7px !important;
transform: rotate(45deg) !important;
}

/* Position containers */
.info-container {
position: relative;
}
42 changes: 21 additions & 21 deletions frontend/src/api/mod.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
use crate::config::get_api_base_url;
use crate::error::{IggyDashboardError, Result};
use crate::error::{IggyBenchDashboardError, Result};
use gloo::console::log;
use gloo::net::http::Request;
use iggy_benchmark_report::hardware::BenchmarkHardware;
use iggy_benchmark_report::report::BenchmarkReport;
use shared::BenchmarkReportLight;
use iggy_bench_dashboard_shared::BenchmarkReportLight;
use iggy_bench_report::hardware::BenchmarkHardware;
use iggy_bench_report::report::BenchmarkReport;
use std::sync::atomic::{AtomicBool, Ordering};
use uuid::Uuid;
use web_sys::window;
Expand All @@ -22,10 +22,10 @@ async fn check_server_health() -> Result<()> {
let resp = Request::get(&url)
.send()
.await
.map_err(|e| IggyDashboardError::HealthCheck(format!("Network error: {}", e)))?;
.map_err(|e| IggyBenchDashboardError::HealthCheck(format!("Network error: {}", e)))?;

if !resp.ok() {
return Err(IggyDashboardError::HealthCheck(format!(
return Err(IggyBenchDashboardError::HealthCheck(format!(
"Server returned {}",
resp.status()
)));
Expand All @@ -43,18 +43,18 @@ pub async fn fetch_hardware_configurations() -> Result<Vec<BenchmarkHardware>> {
let resp = Request::get(&url)
.send()
.await
.map_err(|e| IggyDashboardError::Network(e.to_string()))?;
.map_err(|e| IggyBenchDashboardError::Network(e.to_string()))?;

if !resp.ok() {
return Err(IggyDashboardError::Server(format!(
return Err(IggyBenchDashboardError::Server(format!(
"Failed to fetch hardware configurations: {}",
resp.status()
)));
}

resp.json()
.await
.map_err(|e| IggyDashboardError::Parse(e.to_string()))
.map_err(|e| IggyBenchDashboardError::Parse(e.to_string()))
}

pub async fn fetch_gitrefs_for_hardware(hardware: &str) -> Result<Vec<String>> {
Expand All @@ -65,18 +65,18 @@ pub async fn fetch_gitrefs_for_hardware(hardware: &str) -> Result<Vec<String>> {
let resp = Request::get(&url)
.send()
.await
.map_err(|e| IggyDashboardError::Network(e.to_string()))?;
.map_err(|e| IggyBenchDashboardError::Network(e.to_string()))?;

if !resp.ok() {
return Err(IggyDashboardError::Server(format!(
return Err(IggyBenchDashboardError::Server(format!(
"Failed to fetch git refs: {}",
resp.status()
)));
}

resp.json()
.await
.map_err(|e| IggyDashboardError::Parse(e.to_string()))
.map_err(|e| IggyBenchDashboardError::Parse(e.to_string()))
}

pub async fn fetch_benchmarks_for_hardware_and_gitref(
Expand All @@ -95,18 +95,18 @@ pub async fn fetch_benchmarks_for_hardware_and_gitref(
let resp = Request::get(&url)
.send()
.await
.map_err(|e| IggyDashboardError::Network(e.to_string()))?;
.map_err(|e| IggyBenchDashboardError::Network(e.to_string()))?;

if !resp.ok() {
return Err(IggyDashboardError::Server(format!(
return Err(IggyBenchDashboardError::Server(format!(
"Failed to fetch benchmarks: {}",
resp.status()
)));
}

resp.json()
.await
.map_err(|e| IggyDashboardError::Parse(e.to_string()))
.map_err(|e| IggyBenchDashboardError::Parse(e.to_string()))
}

pub async fn fetch_benchmark_report_full(uuid: &Uuid) -> Result<BenchmarkReport> {
Expand All @@ -117,18 +117,18 @@ pub async fn fetch_benchmark_report_full(uuid: &Uuid) -> Result<BenchmarkReport>
let resp = Request::get(&url)
.send()
.await
.map_err(|e| IggyDashboardError::Network(e.to_string()))?;
.map_err(|e| IggyBenchDashboardError::Network(e.to_string()))?;

if !resp.ok() {
return Err(IggyDashboardError::Server(format!(
return Err(IggyBenchDashboardError::Server(format!(
"Failed to fetch benchmark report: {}",
resp.status()
)));
}

resp.json()
.await
.map_err(|e| IggyDashboardError::Parse(e.to_string()))
.map_err(|e| IggyBenchDashboardError::Parse(e.to_string()))
}

pub async fn fetch_benchmark_trend(
Expand All @@ -147,18 +147,18 @@ pub async fn fetch_benchmark_trend(
let resp = Request::get(&url)
.send()
.await
.map_err(|e| IggyDashboardError::Network(e.to_string()))?;
.map_err(|e| IggyBenchDashboardError::Network(e.to_string()))?;

if !resp.ok() {
return Err(IggyDashboardError::Server(format!(
return Err(IggyBenchDashboardError::Server(format!(
"Failed to fetch benchmark trend: {}",
resp.status()
)));
}

resp.json()
.await
.map_err(|e| IggyDashboardError::Parse(e.to_string()))
.map_err(|e| IggyBenchDashboardError::Parse(e.to_string()))
}

pub fn download_test_artifacts(uuid: &Uuid) {
Expand Down
62 changes: 19 additions & 43 deletions frontend/src/components/app_content.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,6 @@ fn use_load_gitrefs(
.emit(GitrefAction::SetGitrefs(vers.clone()));

if !vers.is_empty() {
// Always use the first version when switching hardware
// since benchmarks are hardware-specific
let selected_gitref = vers[0].clone();
log!("Using first available version for new hardware");

Expand All @@ -76,17 +74,18 @@ fn use_load_gitrefs(
selected_gitref.clone(),
)));

// Always fetch benchmarks for new hardware
match api::fetch_benchmarks_for_hardware_and_gitref(
&hardware,
&selected_gitref,
)
.await
{
Ok(benchmarks) => {
benchmark_ctx
.dispatch
.emit(BenchmarkAction::SetBenchmarksForGitref(benchmarks));
benchmark_ctx.dispatch.emit(
BenchmarkAction::SetBenchmarksForGitref(
benchmarks, hardware,
),
);
}
Err(e) => log!(format!("Error fetching benchmarks: {}", e)),
}
Expand All @@ -105,32 +104,27 @@ fn use_load_benchmarks(
benchmark_ctx: BenchmarkContext,
hardware: Option<String>,
gitref: Option<String>,
is_hardware_changing: bool,
) {
use_effect_with(
(hardware.clone(), gitref.clone(), is_hardware_changing),
move |(hardware, gitref, is_hardware_changing)| {
(hardware.clone(), gitref.clone()),
move |(hardware, gitref)| {
let benchmark_ctx = benchmark_ctx.clone();
let hardware = hardware.clone();
let gitref = gitref.clone();

// Only load benchmarks when gitref changes explicitly (not during hardware change)
// because of god damn race conditions.
if !is_hardware_changing {
if let (Some(hardware), Some(gitref)) = (hardware, gitref) {
yew::platform::spawn_local(async move {
match api::fetch_benchmarks_for_hardware_and_gitref(&hardware, &gitref)
.await
{
Ok(benchmarks) => {
benchmark_ctx
.dispatch
.emit(BenchmarkAction::SetBenchmarksForGitref(benchmarks));
}
Err(e) => log!(format!("Error fetching benchmarks: {}", e)),
if let (Some(hardware), Some(gitref)) = (hardware, gitref) {
yew::platform::spawn_local(async move {
match api::fetch_benchmarks_for_hardware_and_gitref(&hardware, &gitref).await {
Ok(benchmarks) => {
benchmark_ctx
.dispatch
.emit(BenchmarkAction::SetBenchmarksForGitref(
benchmarks, hardware,
));
}
});
}
Err(e) => log!(format!("Error fetching benchmarks: {}", e)),
}
});
}
|| ()
},
Expand All @@ -143,7 +137,6 @@ pub fn app_content(props: &AppContentProps) -> Html {
let gitref_ctx = use_gitref();
let benchmark_ctx = use_benchmark();
let view_mode_ctx = use_view_mode();
let is_hardware_changing = use_state(|| false);

// Get theme context
let theme_ctx = use_context::<(bool, Callback<()>)>().expect("Theme context not found");
Expand All @@ -161,33 +154,16 @@ pub fn app_content(props: &AppContentProps) -> Html {
// Initialize data loading hooks
use_init_hardware(hardware_ctx.clone());

{
let is_hardware_changing = is_hardware_changing.clone();
use_effect_with(hardware_ctx.state.selected_hardware.clone(), move |_| {
is_hardware_changing.set(true);
|| ()
});
}

use_load_gitrefs(
gitref_ctx.clone(),
benchmark_ctx.clone(),
hardware_ctx.state.selected_hardware.clone(),
);

{
let is_hardware_changing = is_hardware_changing.clone();
use_effect_with(gitref_ctx.state.selected_gitref.clone(), move |_| {
is_hardware_changing.set(false);
|| ()
});
}

use_load_benchmarks(
benchmark_ctx.clone(),
hardware_ctx.state.selected_hardware.clone(),
gitref_ctx.state.selected_gitref.clone(),
*is_hardware_changing,
);

html! {
Expand Down
Loading

0 comments on commit 12708fe

Please sign in to comment.