Skip to content

Commit

Permalink
Scratch folder for temporary data moves when using profiles (#112)
Browse files Browse the repository at this point in the history
  • Loading branch information
MrHedmad authored Nov 21, 2024
2 parents f19682e + 5683785 commit 1a77dcf
Show file tree
Hide file tree
Showing 8 changed files with 213 additions and 72 deletions.
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,15 @@ the top. Non pre-release versions sometimes have an associated name.
### Added
- Added the `--dry-run` option to `kerblam data clean` to only show the files
that will be deleted without actually doing anything to them.
- When using a profile, specifying `"_"` as target will simply temporarily hide
the file for the duration of the workflow.
For example `"test.txt" = "_"` will temporarily remove the `"test.txt"` file
from its original position (it will be moved to `.kerblam/scratch`).

### Changed
- The way that profiles are handled was changed.
Now, the original files are moved to `.kerblam/scratch/` during the workflow,
instead of remaining in the original directory (and being renamed `.original`).

## [v1.1.1] - 2024-10-14

Expand Down
67 changes: 67 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ flate2 = "1.0.28"
homedir = "0.2.1"
indicatif = "^0.17"
log = "^0.4"
rand = "0.8.5"
reqwest = { version = "^0.11", default-features = false, features = ["json", "blocking", "rustls-tls"] }
serde = { version = "^1.0", features = ["derive"] }
serde_json = "1.0.115"
Expand Down
8 changes: 4 additions & 4 deletions docs/src/manual/run.md
Original file line number Diff line number Diff line change
Expand Up @@ -89,12 +89,12 @@ kerblam run process_csv --profile alternate
> by default `data/in`.
Under the hood, Kerblam! will:
- Rename `input.csv` to `input.csv.original`;
- Move `input.csv` to a temporary directory in the root of the project named `.kerblam/scratch`,
adding a very small salt string to its name (to avoid potential name collisions);
- Move `different_input.csv` to `input.csv`;
- Run the analysis as normal;
- When the run ends (it finishes, it crashes or you kill it), Kerblam! will undo both actions:
it moves `different_input.csv` back to its original place and
renames `input.csv.original` back to `input.csv`.
- When the run ends (it finishes, it crashes or you kill it), Kerblam! will restore the original state:
it moves both `different_input.csv` and `input.csv.<salt>` back to their original places.

This effectively causes the workflow to run with different input data.

Expand Down
4 changes: 4 additions & 0 deletions src/commands/new.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ use crate::VERSION;
pub fn create_kerblam_project(dir: &PathBuf) -> Result<()> {
let dirs_to_create: Vec<&str> = vec![
"",
"./.kerblam",
"./data/in",
"./data/out",
"./src/workflows",
Expand Down Expand Up @@ -35,6 +36,9 @@ pub fn create_kerblam_project(dir: &PathBuf) -> Result<()> {
let mut commands_to_run: Vec<(&str, Vec<String>)> = vec![];
commands_to_run.push(("git", vec![String::from("init")]));
let mut gitignore_content: Vec<String> = vec![];
// We always ignore the .kerblam directory
gitignore_content.push(".kerblam".to_string());

// Ask for user input
// I defined `dirs_to_create` before so that if we ever have to add to them
// dynamically we can do so here.
Expand Down
4 changes: 2 additions & 2 deletions src/execution.rs
Original file line number Diff line number Diff line change
Expand Up @@ -441,11 +441,11 @@ impl FileMover {
}
}

pub fn get_from(self) -> PathBuf {
pub fn get_from(&self) -> PathBuf {
self.from.clone()
}
#[allow(dead_code)]
pub fn get_to(self) -> PathBuf {
pub fn get_to(&self) -> PathBuf {
self.to.clone()
}
}
Expand Down
Loading

0 comments on commit 1a77dcf

Please sign in to comment.