Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 3 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -259,19 +259,13 @@ ml-cellar clone {your_ml_registry}
- Materialize all files.

```sh
ml-cellar get-all
ml-cellar materialize-all
```

- Materialize a specific directory.
- Materialize a specific directory or file.

```sh
ml-cellar get {path to a directory}
```

- Materialize a specific file.

```sh
ml-cellar get {path to a file}
ml-cellar materialize {path to a directory or a file}
```

## Reference
Expand Down
14 changes: 14 additions & 0 deletions src/bin/ml-cellar/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ use std::path::PathBuf;
mod check;
mod clone;
mod init;
mod materialize;
mod rack;

#[derive(Parser, Debug)]
Expand Down Expand Up @@ -35,6 +36,13 @@ enum Commands {
/// Path to the artifacts
path: PathBuf,
},
/// Materialize all files managed by Git LFS
MaterializeAll {},
/// Materialize a file managed by Git LFS
Materialize {
/// Path to the file
path: PathBuf,
},
}
fn main() {
let cli = Cli::parse();
Expand All @@ -51,5 +59,11 @@ fn main() {
Commands::Check { path } => {
check::check(path);
}
Commands::MaterializeAll {} => {
materialize::materialize_all();
}
Commands::Materialize { path } => {
materialize::materialize(path);
}
}
}
52 changes: 52 additions & 0 deletions src/bin/ml-cellar/materialize.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
use std::path::PathBuf;
use std::process::{Command, Stdio};

pub fn materialize_all() {
let status = Command::new("git")
.arg("lfs")
.arg("pull")
.stdin(Stdio::null())
.stdout(Stdio::null())
.stderr(Stdio::null())
.status();

match status {
Ok(s) if s.success() => {
println!("git lfs pull done");
}
Ok(s) => {
eprintln!("git lfs pull failed: {s}");
std::process::exit(1);
}
Err(e) => {
eprintln!("failed to execute git: {e}");
std::process::exit(1);
}
}
}

pub fn materialize(path: PathBuf) {
let status = Command::new("git")
.arg("lfs")
.arg("pull")
.arg("-I")
.arg(path.to_str().unwrap())
.stdin(Stdio::null())
.stdout(Stdio::null())
.stderr(Stdio::null())
.status();

match status {
Ok(s) if s.success() => {
println!("git lfs pull -I {} done", path.display());
}
Ok(s) => {
eprintln!("git lfs pull failed: {s}");
std::process::exit(1);
}
Err(e) => {
eprintln!("failed to execute git: {e}");
std::process::exit(1);
}
}
}