From 8024ded58f94a6ca0a1dc187ecb3e4a963ebb8fc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Orhun=20Parmaks=C4=B1z?= Date: Tue, 24 Sep 2024 15:57:20 +0300 Subject: [PATCH] Simplify crossterm imports (#2545) --- benchmark/Cargo.toml | 3 +-- benchmark/src/app.rs | 2 +- benchmark/src/event.rs | 2 +- benchmark/src/lib.rs | 14 +++++++------- 4 files changed, 10 insertions(+), 11 deletions(-) diff --git a/benchmark/Cargo.toml b/benchmark/Cargo.toml index 7d3d8b18..23885da2 100644 --- a/benchmark/Cargo.toml +++ b/benchmark/Cargo.toml @@ -16,7 +16,6 @@ path = "src/main.rs" [dependencies] average = "0.14" clap = { version = "4.4.5", features = ["derive", "env"] } -crossterm = "0.28.1" float-ord = "0.3.2" serde = {version = "1.0.188", features = ["derive"]} serde_json = "1.0" @@ -25,7 +24,7 @@ text-generation-client = { path = "../backends/client" } thiserror = "1.0.48" tokenizers = { workspace = true } tokio = { version = "1.32.0", features = ["rt", "rt-multi-thread", "parking_lot", "signal", "sync", "macros"] } -ratatui = { version = "0.28.1", default-features = false, features = ["crossterm"] } +ratatui = "0.28.1" tracing = "0.1.37" tracing-subscriber = { version = "0.3.17", features = ["json", "env-filter"] } hf-hub = { workspace = true } diff --git a/benchmark/src/app.rs b/benchmark/src/app.rs index 7e4d1181..7e3aeaf9 100644 --- a/benchmark/src/app.rs +++ b/benchmark/src/app.rs @@ -1,6 +1,6 @@ /// Inspired by https://github.com/hatoo/oha/blob/bb989ea3cd77727e7743e7daa60a19894bb5e901/src/monitor.rs use crate::generation::{Decode, Message, Prefill}; -use crossterm::event::{KeyCode, KeyEvent, KeyModifiers}; +use ratatui::crossterm::event::{KeyCode, KeyEvent, KeyModifiers}; use ratatui::layout::{Alignment, Constraint, Direction, Layout}; use ratatui::style::{Color, Modifier, Style}; use ratatui::text::{Line, Span}; diff --git a/benchmark/src/event.rs b/benchmark/src/event.rs index 07482aed..d3f10fb6 100644 --- a/benchmark/src/event.rs +++ b/benchmark/src/event.rs @@ -1,5 +1,5 @@ /// Inspired by https://github.com/orhun/rust-tui-template/blob/472aa515119d4c94903eac12d9784417281dc7f5/src/event.rs -use crossterm::event; +use ratatui::crossterm::event; use std::time::{Duration, Instant}; use tokio::sync::{broadcast, mpsc}; diff --git a/benchmark/src/lib.rs b/benchmark/src/lib.rs index 0469b6fd..03612eef 100644 --- a/benchmark/src/lib.rs +++ b/benchmark/src/lib.rs @@ -6,7 +6,7 @@ mod utils; use crate::app::App; use crate::event::Event; -use crossterm::ExecutableCommand; +use ratatui::crossterm::ExecutableCommand; use ratatui::backend::CrosstermBackend; use ratatui::Terminal; use std::io; @@ -50,9 +50,9 @@ pub async fn run( }; // Initialize terminal properties - crossterm::terminal::enable_raw_mode()?; - io::stdout().execute(crossterm::terminal::EnterAlternateScreen)?; - io::stdout().execute(crossterm::cursor::Hide)?; + ratatui::crossterm::terminal::enable_raw_mode()?; + io::stdout().execute(ratatui::crossterm::terminal::EnterAlternateScreen)?; + io::stdout().execute(ratatui::crossterm::cursor::Hide)?; // Initialize terminal let mut terminal = { @@ -128,9 +128,9 @@ pub async fn run( let _ = shutdown_guard_receiver.recv().await; // Revert terminal to original view - io::stdout().execute(crossterm::terminal::LeaveAlternateScreen)?; - crossterm::terminal::disable_raw_mode()?; - io::stdout().execute(crossterm::cursor::Show)?; + io::stdout().execute(ratatui::crossterm::terminal::LeaveAlternateScreen)?; + ratatui::crossterm::terminal::disable_raw_mode()?; + io::stdout().execute(ratatui::crossterm::cursor::Show)?; let parameters_table = table::parameters_table( tokenizer_name,