diff --git a/benchmarks/src/environment/hq.py b/benchmarks/src/environment/hq.py index 2649c4b80..9f8be533c 100644 --- a/benchmarks/src/environment/hq.py +++ b/benchmarks/src/environment/hq.py @@ -117,7 +117,7 @@ def assign_workers(workers: List[HqWorkerConfig], nodes: List[str]) -> Dict[str, def postprocess_events(binary_path: Path, event_log_path: Path, event_log_json_path: Path, workdir: Path): with open(event_log_json_path, "w") as f: - subprocess.run([str(binary_path), "event-log", "export", str(event_log_path)], stdout=f, check=True) + subprocess.run([str(binary_path), "journal", "export", str(event_log_path)], stdout=f, check=True) export_hq_events_to_chrome(event_log_json_path, workdir / "events-chrome.json") @@ -184,7 +184,7 @@ def start_server(self): self.postprocessing_fns.append( lambda: postprocess_events(self.binary_path, event_log_path, event_log_json_path, workdir) ) - args += ["--event-log-path", str(event_log_path)] + args += ["--journal", str(event_log_path)] args = StartProcessArgs( args=args, diff --git a/crates/hyperqueue/src/bin/hq.rs b/crates/hyperqueue/src/bin/hq.rs index 581ed7c12..e314a2a0d 100644 --- a/crates/hyperqueue/src/bin/hq.rs +++ b/crates/hyperqueue/src/bin/hq.rs @@ -8,12 +8,12 @@ use cli_table::ColorChoice; use colored::Colorize; use hyperqueue::client::commands::autoalloc::command_autoalloc; -use hyperqueue::client::commands::event::command_event_log; use hyperqueue::client::commands::job::{ cancel_job, close_job, forget_job, output_job_cat, output_job_detail, output_job_list, output_job_summary, JobCancelOpts, JobCatOpts, JobCloseOpts, JobForgetOpts, JobInfoOpts, JobListOpts, JobTaskIdsOpts, }; +use hyperqueue::client::commands::journal::command_journal; use hyperqueue::client::commands::outputlog::command_reader; use hyperqueue::client::commands::server::command_server; use hyperqueue::client::commands::submit::command::{open_job, SubmitJobConfOpts}; @@ -476,7 +476,7 @@ async fn main() -> hyperqueue::Result<()> { SubCommand::Dashboard(opts) => command_dashboard_start(&gsettings, opts).await, SubCommand::OutputLog(opts) => command_reader(&gsettings, opts), SubCommand::AutoAlloc(opts) => command_autoalloc(&gsettings, opts).await, - SubCommand::EventLog(opts) => command_event_log(&gsettings, opts).await, + SubCommand::Journal(opts) => command_journal(&gsettings, opts).await, SubCommand::GenerateCompletion(opts) => generate_completion(opts), }; diff --git a/crates/hyperqueue/src/client/commands/event/mod.rs b/crates/hyperqueue/src/client/commands/journal/mod.rs similarity index 74% rename from crates/hyperqueue/src/client/commands/event/mod.rs rename to crates/hyperqueue/src/client/commands/journal/mod.rs index 167ecf16e..ae78aba21 100644 --- a/crates/hyperqueue/src/client/commands/event/mod.rs +++ b/crates/hyperqueue/src/client/commands/journal/mod.rs @@ -1,6 +1,6 @@ mod output; -use crate::client::commands::event::output::format_event; +use crate::client::commands::journal::output::format_event; use crate::client::globalsettings::GlobalSettings; use crate::common::utils::str::pluralize; use crate::server::bootstrap::get_client_session; @@ -12,37 +12,34 @@ use std::io::{BufWriter, Write}; use std::path::PathBuf; #[derive(Parser)] -pub struct EventLogOpts { - /// Manage event log files. +pub struct JournalOpts { + /// Manage events and journal data. #[clap(subcommand)] - command: EventCommand, + command: JournalCommand, } #[derive(Parser)] -enum EventCommand { - /// Export events from a log file to NDJSON (line-delimited JSON). +enum JournalCommand { + /// Export events from a journal to NDJSON (line-delimited JSON). /// Events will be exported to `stdout`, you can redirect it e.g. to a file. Export(ExportOpts), - /// Live stream events from server + /// Live stream events from the server. Stream, } #[derive(Parser)] struct ExportOpts { - /// Path to a file containing the event log. - /// The file had to be created with `hq server start --event-log-path=`. + /// Path to a journal. + /// It had to be created with `hq server start --journal=`. #[arg(value_hint = ValueHint::FilePath)] - logfile: PathBuf, + journal: PathBuf, } -pub async fn command_event_log( - gsettings: &GlobalSettings, - opts: EventLogOpts, -) -> anyhow::Result<()> { +pub async fn command_journal(gsettings: &GlobalSettings, opts: JournalOpts) -> anyhow::Result<()> { match opts.command { - EventCommand::Export(opts) => export_json(opts), - EventCommand::Stream => stream_json(gsettings).await, + JournalCommand::Export(opts) => export_json(opts), + JournalCommand::Stream => stream_json(gsettings).await, } } @@ -68,10 +65,10 @@ async fn stream_json(gsettings: &GlobalSettings) -> anyhow::Result<()> { } fn export_json(opts: ExportOpts) -> anyhow::Result<()> { - let mut file = JournalReader::open(&opts.logfile).map_err(|error| { + let mut file = JournalReader::open(&opts.journal).map_err(|error| { anyhow!( "Cannot open event log file at `{}`: {error:?}", - opts.logfile.display() + opts.journal.display() ) })?; diff --git a/crates/hyperqueue/src/client/commands/event/output.rs b/crates/hyperqueue/src/client/commands/journal/output.rs similarity index 100% rename from crates/hyperqueue/src/client/commands/event/output.rs rename to crates/hyperqueue/src/client/commands/journal/output.rs diff --git a/crates/hyperqueue/src/client/commands/mod.rs b/crates/hyperqueue/src/client/commands/mod.rs index ce8f3a900..39989991d 100644 --- a/crates/hyperqueue/src/client/commands/mod.rs +++ b/crates/hyperqueue/src/client/commands/mod.rs @@ -1,6 +1,6 @@ pub mod autoalloc; -pub mod event; pub mod job; +pub mod journal; pub mod outputlog; pub mod server; pub mod submit; diff --git a/crates/hyperqueue/src/common/cli.rs b/crates/hyperqueue/src/common/cli.rs index da67153fc..723ff637d 100644 --- a/crates/hyperqueue/src/common/cli.rs +++ b/crates/hyperqueue/src/common/cli.rs @@ -7,11 +7,11 @@ use clap_complete::Shell; use tako::WorkerId; use crate::client::commands::autoalloc::AutoAllocOpts; -use crate::client::commands::event::EventLogOpts; use crate::client::commands::job::{ JobCancelOpts, JobCatOpts, JobCloseOpts, JobForgetOpts, JobInfoOpts, JobListOpts, JobTaskIdsOpts, }; +use crate::client::commands::journal::JournalOpts; use crate::client::commands::outputlog::OutputLogOpts; use crate::client::commands::server::ServerOpts; use crate::client::commands::submit::command::SubmitJobConfOpts; @@ -203,8 +203,8 @@ pub enum SubCommand { /// Automatic allocation management #[command(name = "alloc")] AutoAlloc(AutoAllocOpts), - /// Event log management - EventLog(EventLogOpts), + /// Event and journal management + Journal(JournalOpts), /// Start the HyperQueue CLI dashboard #[cfg(feature = "dashboard")] Dashboard(DashboardOpts), diff --git a/tests/test_events.py b/tests/test_events.py index 0dbffc67d..de0703cd5 100644 --- a/tests/test_events.py +++ b/tests/test_events.py @@ -17,7 +17,7 @@ def test_worker_stream_events1(hq_env: HqEnv, tmp_path): hq_bin = get_hq_binary() out_txt = tmp_path.joinpath("out.txt") with open(out_txt, "w") as out: - p = subprocess.Popen([hq_bin, "--server-dir", hq_env.server_dir, "event-log", "stream"], stdout=out) + p = subprocess.Popen([hq_bin, "--server-dir", hq_env.server_dir, "journal", "stream"], stdout=out) time.sleep(0.6) hq_env.command(["submit", "--", "hostname"]) time.sleep(0.6) @@ -45,7 +45,7 @@ def test_worker_stream_events2(hq_env: HqEnv, tmp_path): hq_bin = get_hq_binary() out_txt = tmp_path.joinpath("out.txt") with open(out_txt, "w") as out: - p = subprocess.Popen([hq_bin, "--server-dir", hq_env.server_dir, "event-log", "stream"], stdout=out) + p = subprocess.Popen([hq_bin, "--server-dir", hq_env.server_dir, "journal", "stream"], stdout=out) time.sleep(0.6) hq_env.command(["submit", "--", "hostname"]) time.sleep(0.6) @@ -208,7 +208,7 @@ def get_events(hq_env: HqEnv, callback): process.wait(timeout=5) hq_env.processes.clear() - output = hq_env.command(["event-log", "export", log_path], ignore_stderr=True) + output = hq_env.command(["journal", "export", log_path], ignore_stderr=True) events = [] for line in output.splitlines(keepends=False): events.append(json.loads(line))