-
-
Notifications
You must be signed in to change notification settings - Fork 0
fix(ml-cellar): change materialize command into download command #21
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 2 commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,83 @@ | ||
| use std::path::PathBuf; | ||
| use std::process::{Command, Stdio}; | ||
|
|
||
| /// Materializes (downloads) all Git LFS files in the repository. | ||
| /// This function executes `git lfs pull` to download the actual contents of all | ||
| /// Git LFS files. Use this when you need to work with all models and large files locally. | ||
| /// After cloning a repository with `GIT_LFS_SKIP_SMUDGE=1`, this command converts | ||
| /// all LFS pointers to their actual file contents. | ||
| /// | ||
| /// # Panics | ||
| /// | ||
| /// Exits the process with code 1 if: | ||
| /// - Git or Git LFS is not installed | ||
| /// - The `git lfs pull` command fails | ||
| /// | ||
| pub fn download_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() => { | ||
| log::info!("git lfs pull done"); | ||
| } | ||
| Ok(s) => { | ||
| log::error!("git lfs pull failed: {s}\nPlease check by git lfs pull command manually."); | ||
| std::process::exit(1); | ||
| } | ||
| Err(e) => { | ||
| log::error!( | ||
| "failed to execute git: {e}\nPlease check by git lfs pull command manually." | ||
| ); | ||
| std::process::exit(1); | ||
| } | ||
| } | ||
| } | ||
|
|
||
| /// Materializes (downloads) a specific Git LFS file or directory. | ||
| /// This function executes `git lfs pull -I <path>` to selectively download | ||
| /// the actual contents of Git LFS files matching the specified path pattern. | ||
| /// Use this for selective downloading when you only need specific models or files. | ||
| /// | ||
| /// # Arguments | ||
| /// | ||
| /// - `path` - Path to a file or directory to materialize. Can include wildcards. | ||
| /// | ||
| /// # Panics | ||
| /// | ||
| /// Exits the process with code 1 if: | ||
| /// - Git or Git LFS is not installed | ||
| /// - The `git lfs pull -I` command fails | ||
| /// | ||
| pub fn download(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() => { | ||
| log::info!("git lfs pull -I {} done", path.display()); | ||
| } | ||
| Ok(s) => { | ||
| log::error!("git lfs pull failed: {s}\nPlease check by git lfs pull command manually."); | ||
| std::process::exit(1); | ||
| } | ||
| Err(e) => { | ||
| log::error!( | ||
| "failed to execute git: {e}\nPlease check by git lfs pull command manually." | ||
| ); | ||
| std::process::exit(1); | ||
| } | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.