From 40f392e8c4397d8ac5d5b5bb523ac09205347a10 Mon Sep 17 00:00:00 2001 From: "Joshua A. Anderson" Date: Tue, 13 Aug 2024 13:14:02 -0400 Subject: [PATCH 1/4] clean all by default Also allow users to pass multiple cache types on the command line. --- src/cli/clean.rs | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 deletions(-) diff --git a/src/cli/clean.rs b/src/cli/clean.rs index 48b2cfe..187706c 100644 --- a/src/cli/clean.rs +++ b/src/cli/clean.rs @@ -17,7 +17,7 @@ use row::{ #[derive(Args, Debug)] pub struct Arguments { #[command(flatten)] - selection: Selection, + selection: Option, /// Force removal of the completed and/or submitted cache when there are submitted jobs. #[arg(long, display_order = 0)] @@ -25,7 +25,7 @@ pub struct Arguments { } #[derive(Args, Debug)] -#[group(required = true, multiple = false)] +#[group(multiple = true)] #[allow(clippy::struct_excessive_bools)] pub struct Selection { /// Remove the directory cache. @@ -39,10 +39,6 @@ pub struct Selection { /// Remove the completed cache. #[arg(long, display_order = 0)] completed: bool, - - /// Remove all caches. - #[arg(long, display_order = 0)] - all: bool, } /// Remove row cache files. @@ -57,19 +53,19 @@ pub fn clean( // Delete all existing completion staging files. project.close(multi_progress)?; - let selection = &args.selection; + let selection = args.selection.as_ref().unwrap_or(&Selection {directory: true, submitted: true, completed: true}); let num_submitted = project.state().num_submitted(); if num_submitted > 0 { - let force_needed = selection.completed || selection.submitted || selection.all; + let force_needed = selection.completed || selection.submitted; if force_needed { warn!("There are {num_submitted} directories with submitted jobs."); } - if selection.submitted || selection.all { + if selection.submitted { warn!("The submitted cache is not recoverable. Row may resubmit running jobs."); } - if selection.completed || selection.all { + if selection.completed { warn!("These jobs may add to the completed cache after it is cleaned."); } if force_needed && !args.force { @@ -80,7 +76,7 @@ pub fn clean( let data_directory = project.workflow().root.join(DATA_DIRECTORY_NAME); - if selection.submitted || selection.all { + if selection.submitted { let path = data_directory.join(SUBMITTED_CACHE_FILE_NAME); info!("Removing '{}'.", path.display()); if let Err(error) = fs::remove_file(&path) { @@ -90,7 +86,7 @@ pub fn clean( } } } - if selection.completed || selection.all { + if selection.completed { let path = data_directory.join(COMPLETED_CACHE_FILE_NAME); info!("Removing '{}'.", path.display()); if let Err(error) = fs::remove_file(&path) { @@ -100,7 +96,7 @@ pub fn clean( } } } - if selection.directory || selection.all { + if selection.directory { let path = data_directory.join(DIRECTORY_CACHE_FILE_NAME); info!("Removing '{}'.", path.display()); if let Err(error) = fs::remove_file(&path) { From d6ac8226f517a9824959f7bd0aefeee7357e4a87 Mon Sep 17 00:00:00 2001 From: "Joshua A. Anderson" Date: Tue, 13 Aug 2024 13:14:15 -0400 Subject: [PATCH 2/4] Update documentation. --- doc/src/row/clean.md | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/doc/src/row/clean.md b/doc/src/row/clean.md index 83744bc..50c0a39 100644 --- a/doc/src/row/clean.md +++ b/doc/src/row/clean.md @@ -2,18 +2,17 @@ Usage ```bash -row clean [OPTIONS] <--directory|--submitted|--completed|--all> +row clean [OPTIONS] ``` `row clean` safely removes cache files generated by **row**. The [cache concepts page](../guide/concepts/cache.md) describes cases where you might need to clean the cache. -## `[OPTIONS]` - -### `--all` +By default, `row clean` removes all cache files. Pass one or more of the options to +remove only selected caches. -Remove all caches. +## `[OPTIONS]` ### `--completed` From a99de2bf4affb6d25fbe21636ed9f6b52f41ee61 Mon Sep 17 00:00:00 2001 From: "Joshua A. Anderson" Date: Thu, 15 Aug 2024 13:18:40 -0400 Subject: [PATCH 3/4] Update change log. --- doc/src/release-notes.md | 1 + 1 file changed, 1 insertion(+) diff --git a/doc/src/release-notes.md b/doc/src/release-notes.md index 09e5db7..a12612b 100644 --- a/doc/src/release-notes.md +++ b/doc/src/release-notes.md @@ -14,6 +14,7 @@ * Improve the verbose output from `submit`. * `show status` hides actions with 0 directories by default. Pass `--all` to show all actions. +* `clean` now cleans all caches by default. *Fixed:* From 4cf081ad297a97e84dade5aad8db3961b2f58792 Mon Sep 17 00:00:00 2001 From: "Joshua A. Anderson" Date: Tue, 13 Aug 2024 13:25:28 -0400 Subject: [PATCH 4/4] pre-commit --- src/cli/clean.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/cli/clean.rs b/src/cli/clean.rs index 187706c..8684e9e 100644 --- a/src/cli/clean.rs +++ b/src/cli/clean.rs @@ -53,7 +53,11 @@ pub fn clean( // Delete all existing completion staging files. project.close(multi_progress)?; - let selection = args.selection.as_ref().unwrap_or(&Selection {directory: true, submitted: true, completed: true}); + let selection = args.selection.as_ref().unwrap_or(&Selection { + directory: true, + submitted: true, + completed: true, + }); let num_submitted = project.state().num_submitted(); if num_submitted > 0 {