Skip to content

Commit c6a9579

Browse files
authored
feat(ml-cellar): add clone (#12)
Signed-off-by: scepter914 <scepter914@gmail.com>
1 parent 531805f commit c6a9579

4 files changed

Lines changed: 67 additions & 23 deletions

File tree

README.md

Lines changed: 31 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,10 @@ As a result, existing MLOps software has primarily targeted companies that can a
1313
- Feature
1414
- [ ] [Custom Transfer Agent](docs/docs_custom_transfer_agent.md)
1515

16+
## Related resource
17+
18+
- [ml-cellar-example](https://github.com/scepter914/ml-cellar-example): An example of ML model registry by `ml-cellar`.
19+
1620
## GitHub Git LFS usage & billing notice
1721

1822
This repository uses Git LFS (Large File Storage) to manage large files.
@@ -35,7 +39,7 @@ If you want to see example of the usage of `ml-cellar` as minimum MLOps, please
3539
### 1. Install
3640

3741
- Install GitLFS
38-
- See [the official document](https://github.com/git-lfs/git-lfs/wiki/Installation)
42+
- See [the official document](https://github.com/git-lfs/git-lfs/wiki/Installation).
3943

4044
```sh
4145
curl -s https://packagecloud.io/install/repositories/github/git-lfs/script.deb.sh | sudo bash
@@ -51,7 +55,7 @@ git lfs install
5155
curl https://sh.rustup.rs -sSf | sh
5256
```
5357

54-
- Install `ml-cellar`
58+
- Install `ml-cellar`.
5559

5660
```sh
5761
cargo install ml-cellar
@@ -72,9 +76,9 @@ cargo install --path .
7276

7377
### 2. Setup repository
7478

75-
Let's open the cellar for AI models
79+
Let's open the cellar for AI models.
7680

77-
- Start `ml-cellar`
81+
- Start `ml-cellar`.
7882

7983
```sh
8084
mkdir {your_ml_registry}
@@ -135,13 +139,13 @@ The rack consists of the following directory structure:
135139
In this directory, we call the ML model like `vit-l 1.1` for "Large size of Vision Transformer, version 1.1".
136140
It is like vintage wine called by "Dom Pérignon Vintage 2010".
137141

138-
- Make rack
142+
- Make rack.
139143

140144
```sh
141145
ml-cellar rack {path}
142146
```
143147

144-
- If you run `ml-cellar rack {my_algorithm}`, then you can see as below
148+
- If you run `ml-cellar rack {my_algorithm}`, then you can see as below.
145149
- Without `ml-cellar rack {my_algorithm}` command, you can make rack by making directory and `config.toml` manually.
146150

147151
```yaml
@@ -152,8 +156,8 @@ ml-cellar rack {path}
152156
- template.md
153157
```
154158

155-
- Edit config.toml
156-
- Add required files to save ML registry
159+
- Edit config.toml.
160+
- Add required files to save ML registry.
157161
- If you allow to save any kind of file, you set `"*"` for optional files.
158162

159163
```toml
@@ -162,28 +166,28 @@ required_files = ["config.yaml", "logs/"]
162166
optional_files = ["*"]
163167
```
164168

165-
- Edit README.md
169+
- Edit README.md.
166170
- When developing ML models as a team, or providing ML models to various projects, a cellar isn’t opened for just one person.
167171
- Just as with wine, where you introduce its flavor and the foods it pairs well with, let’s write a description of the ML model for users.
168172

169173
### 5. (Option) Set up projects for MLOps
170174

171-
- Start fine-tuning for projects from base model
175+
- Start fine-tuning for projects from base model.
172176

173177
If you use fixed dataset and focus on algorithm development like Kaggle competition or research usage, the simple ML cellar is fine to share various experimental results using single rack.
174178

175179
However, if you are an engineer and you have many projects you want to fine-tuning for, I recommend to use "project-based model registry".
176-
Please see [the document for project-based model registry](docs/project_based_model_registry.md)
180+
Please see [the document for project-based model registry](docs/project_based_model_registry.md).
177181

178-
- Setup template.md and result.json for MLOps
182+
- Setup template.md and result.json for MLOps.
179183

180184
If you want to setup template.md and result.json for MLOps, then please see [the document for template.md](docs/docs_template.md).
181185

182186
### 6. Commit ML model
183187

184-
Let's actually stock AI models on the racks
188+
Let's actually stock AI models on the racks.
185189

186-
- Make branch and switch the branch
190+
- Make branch and switch the branch.
187191

188192
```sh
189193
git sw -c feat/my_algorithm/0.1
@@ -210,7 +214,7 @@ git sw -c feat/my_algorithm/0.1
210214
ml-cellar check {path}
211215
```
212216

213-
- In this example, please run this command
217+
- In this example, please run this command.
214218

215219
```sh
216220
cd {your_ml_registry}
@@ -224,13 +228,17 @@ git add {path}
224228
git commit -m "{commit message}"
225229
```
226230

227-
- Push the files
231+
- Push the files.
228232

229233
```sh
230234
ml-cellar push
231235
```
232236

233-
- Make PR and review
237+
- Make PR and review.
238+
- You can see examples of review as below.
239+
- https://github.com/scepter914/ml-cellar-example/pull/2
240+
- https://github.com/scepter914/ml-cellar-example/pull/3
241+
- https://github.com/scepter914/ml-cellar-example/pull/4
234242
- After PR merged and if you want to pull the repository, run pull command.
235243

236244
```sh
@@ -239,28 +247,28 @@ ml-cellar pull
239247

240248
### 7. Use `ml-cellar` as model serve
241249

242-
A wine cellar is a storage facility, but it's also a facility for serving
250+
A wine cellar is a storage facility, but it's also a facility for serving.
243251

244-
- Clone repository
245-
- At this point, there are only Git LFS references, and the actual files do not exist
252+
- Clone repository.
253+
- At this point, there are only Git LFS references, and the actual files do not exist.
246254

247255
```sh
248256
ml-cellar clone {your_ml_registry}
249257
```
250258

251-
- Materialize all files
259+
- Materialize all files.
252260

253261
```sh
254262
ml-cellar get-all
255263
```
256264

257-
- Materialize a specific directory
265+
- Materialize a specific directory.
258266

259267
```sh
260268
ml-cellar get {path to a directory}
261269
```
262270

263-
- Materialize a specific file
271+
- Materialize a specific file.
264272

265273
```sh
266274
ml-cellar get {path to a file}

src/bin/ml-cellar/clone.rs

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
use std::process::{Command, Stdio};
2+
3+
pub fn clone(repository: String) {
4+
let status = Command::new("git")
5+
.env("GIT_LFS_SKIP_SMUDGE", "1")
6+
.arg("clone")
7+
.arg(repository)
8+
.stdin(Stdio::null())
9+
.stdout(Stdio::null())
10+
.stderr(Stdio::null())
11+
.status();
12+
13+
match status {
14+
Ok(s) if s.success() => {
15+
println!("git clone done");
16+
}
17+
Ok(s) => {
18+
eprintln!("git clone failed: {s}");
19+
std::process::exit(1);
20+
}
21+
Err(e) => {
22+
eprintln!("failed to execute git: {e}");
23+
std::process::exit(1);
24+
}
25+
}
26+
}

src/bin/ml-cellar/main.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ use clap::{Parser, Subcommand};
22
use std::path::PathBuf;
33

44
mod check;
5+
mod clone;
56
mod init;
67
mod rack;
78

@@ -18,6 +19,11 @@ struct Cli {
1819
enum Commands {
1920
/// Initialize a new repository
2021
Init {},
22+
/// Clone an existing repository
23+
Clone {
24+
/// Repository (URL or path)
25+
repository: String,
26+
},
2127
/// Create a new rack at the specified path
2228
/// "Rack" is a collection of ML models and related files.
2329
Rack {
@@ -36,6 +42,9 @@ fn main() {
3642
Commands::Init {} => {
3743
init::init();
3844
}
45+
Commands::Clone { repository } => {
46+
clone::clone(repository);
47+
}
3948
Commands::Rack { path } => {
4049
rack::rack(path);
4150
}

tests/fixtures/test_registry/test_check_for_version/config.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ optional_files = ["*.png"]
99
[project]
1010
project = ["base", "pretrained", "projectA"]
1111
version_yyyymmdd = ["pretrained"]
12+
version_x = []
1213
version_x_y = ["base"]
1314
version_x_y_z = ["projectA"]
1415

0 commit comments

Comments
 (0)