Skip to content

Commit 4ab0289

Browse files
omesserjorgeorpinelaguschin
authored
CLI - Help message tweaking suggestions (#140)
* docs: README intro * docs: README intro (2) * Update README.md * Update README.md Co-authored-by: Jorge Orpinel <jorgeorpinel@users.noreply.github.com> * updating readme up to gto 0.1.3 * initial * update README; hide completions from CLI; update CLI help * Format headers Co-authored-by: Jorge Orpinel <jorgeorpinel@users.noreply.github.com> Co-authored-by: Alexander Guschin <1aguschin@gmail.com>
1 parent 48f5bc4 commit 4ab0289

File tree

2 files changed

+137
-125
lines changed

2 files changed

+137
-125
lines changed

README.md

Lines changed: 98 additions & 80 deletions
Original file line numberDiff line numberDiff line change
@@ -1,126 +1,150 @@
1+
# GTO
2+
13
[![Check, test and release](https://github.com/iterative/gto/actions/workflows/check-test-release.yml/badge.svg)](https://github.com/iterative/gto/actions/workflows/check-test-release.yml)
24
[![Codecov](https://codecov.io/gh/iterative/gto/branch/main/graph/badge.svg?token=NXT11717BG)](https://codecov.io/gh/iterative/gto)
35
[![PyPi](https://img.shields.io/pypi/v/gto.svg?label=pip&logo=PyPI&logoColor=white)](https://pypi.org/project/gto)
46

5-
# GTO
7+
Git Tag Ops. Turn your Git repository into an Artifact Registry:
68

7-
Git Tag Ops. Turn your Git Repo into Artifact Registry:
8-
* Register new versions of artifacts marking significant changes to them
9-
* Promote versions to signal downstream systems to act
10-
* Attach additional info about your artifact with Enrichments
11-
* Act on new versions and promotions in CI
9+
* Register new versions of artifacts marking releases/significant changes
10+
* Promote versions to ordered, named stages to track their lifecycles
11+
* GitOps: signal CI/CD automation or downstream systems to act upon these actions
12+
* Maintain and query artifact metadata / additional info with Enrichments machinery
1213

13-
To turn your repo into an artifact registry, you only need to `pip install` this package. Versioning and promotion of artifacts are done by creation of special git tags. To use the artifact registry, you also need this package only.
14+
GTO versions and promotes artifacts by creating annotated Git tags in special format.
1415

15-
The tool is created to be used both in CLI and in Python. The README will cover CLI part, but for all commands there are Python API counterparts in `gto.api` module.
16+
## Installation
1617

17-
## Versioning
18-
19-
To register new version of artifact, you can use `gto register` command. You usually use those to mark significant changes to the artifact. Running `gto register` creates a special git tag.
18+
Install GTO with pip:
2019

2120
```
22-
$ gto register simple-nn HEAD --version v1.0.0
21+
$ pip install gto
2322
```
2423

25-
This will create git tag `rf@v1.0.0`.
24+
This will install both python package with API you can use and CLI `gto` entrypoint.
2625

27-
## Promoting
26+
Installing this package is enough to get started with using any repo as an artifact registry - no need to set up neither other services, nor a DB.
2827

29-
You could also promote a specific artifact version to Stage. You can use that to signal downstream systems to act - for example, redeploy a ML model (if your artifact is a model) or update the some special file on server (if your artifact is a file).
28+
## Quick walkthrough
3029

30+
The README will cover CLI usage, but for every command there is a Python API counterpart in the [`gto.api`](/iterative/gto/blob/main/gto/api.py) module. In README we'll use this example repo: https://github.com/iterative/gto-example
31+
32+
Let's clone the example repo first:
3133
```
32-
$ gto promote simple-nn prod
34+
$ git clone git@github.com:iterative/gto-example.git
35+
$ cd gto-example
3336
```
3437

35-
This creates git tag `rf#prod-N`.
38+
### Versioning
39+
40+
To register new version of artifact, you can use `gto register` command. You usually use those to mark significant changes to the artifact. Running `gto register` creates a special git tag.
41+
42+
```
43+
$ gto register rf
44+
Created git tag 'rf@v0.0.1' that registers a new version
45+
```
46+
47+
### Promoting
48+
49+
You could also promote a specific artifact version to Stage. Stages are statuses of your artifact specifying the readiness to be used by downstream systems. You can use promotions to signal downstream systems to act via CI/CD or webhooks - for example, redeploy a ML model (if your artifact is a model) or update the some special file on server (if your artifact is a file).
50+
51+
```
52+
$ gto promote rf prod
53+
Created git tag 'rf#prod#1' that promotes 'v0.0.1'
54+
```
3655

3756
There are two notations used for git tags in promotion:
3857
- simple: `rf#prod`
3958
- incremental: `rf#prod-N`
4059

4160
Incremental is the default one and we suggest you use it when possible. The benefit of using it is that you don't have to delete git tags (with simple notation you'll need to delete them because you can't have two tags with the same name). This will keep the history of your promotions.
4261

43-
## Artifacts
62+
### Artifacts
63+
64+
So far we've seen how to register versions and promote them, but we still didn't specify `type` of artifact (dataset, model, something else) and `path` to it. For simple workflows, when we have a single artifact, we can hardcore those to CI/CD or downstream systems. But for more advanced cases we would like to codify them - and we can do that with `artifacts.yaml` file.
4465

45-
So far we registered some artifacts, but we still didn't specify nowhere `type` of this artifact (dataset, model, something else) and `path` to it.
46-
To add enrichment for artifact or remove the existing one, run `gto add` or `gto rm`:
66+
To annotate artifact, use `gto annotate`:
4767

4868
```
49-
$ gto add model simple-nn models/neural-network.pkl --virtual
69+
$ gto annotate rf --type model --path models/neural-network.pkl
5070
```
5171

5272
You could also modify `artifacts.yaml` file directly.
5373

54-
There are two types of artifacts in GTO:
74+
There are two kinds of artifacts that GTO recognizes:
5575
1. Files/folders committed to the repo. When you register a new version or promote it to stage, Git guarantees that it's immutable. You can return to your repo a year later and be able to get 100% the same artifact by providing the same version.
56-
2. `Virtual` artifacts. This could be an external path, e.g. `s3://mybucket/myfile` or a local path if the file wasn't committed (as in case with DVC). In this case GTO can't pin the current physical state of the artifact and guarantee it's immutability. If `s3://mybucket/myfile` changes, you won't have any way neither retrieve, nor understand it's different now than it was before when you registered that artifact version.
76+
2. `virtual` artifacts. This could be an external path, e.g. `s3://mybucket/myfile` or a local path if the file wasn't committed (as in case with DVC). In this case GTO can't pin the current physical state of the artifact and guarantee it's immutability. If `s3://mybucket/myfile` changes, you won't have any way neither retrieve, nor understand it's different now than it was before when you registered that artifact version.
5777

58-
In future versions, we will add enrichments (useful information other tools like DVC and MLEM can provide about the artifacts). This will allow treating files versioned with DVC and DVC PL outputs as usual artifacts instead `virtual` ones.
78+
By default GTO treats your artifact as a `vitrual` one. To make sure it's not a vitrual one, you could supply `--must_exist` flag to `gto annotate`.
79+
80+
In future versions, we will add enrichments: useful information other tools like DVC and MLEM can provide about the artifacts. This will allow treating files versioned with DVC and DVC PL outputs as usual artifacts instead `virtual` ones.
5981

6082
## Using the registry
6183

62-
Let's see what are the commands that help us use the registry. Let's clone the example repo first:
63-
```
64-
$ git clone git@github.com:iterative/gto-example.git
65-
$ cd gto-example
66-
```
84+
Let's see what are the commands that help us use the registry.
6785

6886
### Show the actual state
6987

7088
This is the actual state of the registry: all artifacts, their latest versions, and what is promoted to stages right now.
7189

7290
```
7391
$ gto show
74-
╒════════╤═══════════╤═════════════════╤════════════════════╕
75-
│ name │ version │ stage/staging │ stage/production │
76-
╞════════╪═══════════╪═════════════════╪════════════════════╡
77-
│ nn │ v0.0.1 │ v0.0.1 │ - │
78-
│ rf │ v1.2.4 │ - │ v1.2.4 │
79-
╘════════╧═══════════╧═════════════════╧════════════════════╛
92+
╒══════════════╤══════════════════╤════════════════════╤═════════════════╕
93+
│ name │ latest version │ stage/production │ stage/staging │
94+
╞══════════════╪══════════════════╪════════════════════╪═════════════════╡
95+
│ nn │ v0.0.1 │ - │ v0.0.1 │
96+
│ rf │ v1.0.1 │ v1.0.0 │ v1.0.1 │
97+
│ features-dvc │ - │ - │ - │
98+
╘══════════════╧══════════════════╧════════════════════╧═════════════════╛
8099
```
81100

82-
Use `--all-branches` or `--all-commits` to read `artifacts.yaml` from more commits than just HEAD.
101+
Here we'll see both artifacts that have git tags created for them (i.e. artifacts with registered or promoted versions) and artifacts that were annotated in `artifacts.yaml`. Use `--all-branches` or `--all-commits` to read `artifacts.yaml` from more commits than just HEAD.
83102

84103
Add artifact name to print versions of that artifact:
85104

86105
```
87106
$ gto show rf
88-
╒════════════╤════════╤════════════╤═════════════════════╤═══════════════════╤═════════════════╤══════════════╤═══════════════
89-
│ artifact │ name │ stage │ created_at │ author │ commit_hexsha │ discovered │ enrichments
90-
╞════════════╪════════╪════════════╪═════════════════════╪═══════════════════╪═════════════════╪══════════════╪═══════════════
91-
│ rf │ v1.2.3 │ production │ 2022-04-11 21:51:56 │ Alexander Guschin │ d1d9736 │ False │ ['gto']
92-
│ rf │ v1.2.4production │ 2022-04-11 21:51:57 │ Alexander Guschin │ 16b7b77 │ False │ ['gto']
93-
╘════════════╧════════╧════════════╧═════════════════════╧═══════════════════╧═════════════════╧══════════════╧═══════════════
107+
╒════════════╤════════╤════════════╤═════════════════════╤═══════════════════╤════════════════╕
108+
│ artifact │ name │ stage │ creation_date │ author │ commit_hexsha │
109+
╞════════════╪════════╪════════════╪═════════════════════╪═══════════════════╪════════════════╡
110+
│ rf │ v1.0.0 │ production │ 2022-04-18 18:49:36 │ Alexander Guschin │ 0e87447
111+
│ rf │ v1.0.1staging │ 2022-04-18 18:50:41 │ Alexander Guschin │ ff5d58e
112+
╘════════════╧════════╧════════════╧═════════════════════╧═══════════════════╧════════════════╛
94113
```
95114

96115
### See the history of an artifact
97116

98-
`gto history` will print all registered versions of the artifact and all versions promoted to environments. This will help you to understand what was happening with the artifact.
117+
`gto history` will print a journal of events happened with your artifact. This will help you to understand what was happening and audit changes.
99118

100119
```
101120
$ gto history rf
102121
╒═════════════════════╤════════╤══════════════╤═══════════╤════════════╤══════════╤═══════════════════╕
103122
│ timestamp │ name │ event │ version │ stage │ commit │ author │
104123
╞═════════════════════╪════════╪══════════════╪═══════════╪════════════╪══════════╪═══════════════════╡
105-
│ 2022-04-11 21:51:56 │ rf │ commit │ - │ - │ d1d9736 │ Alexander Guschin │
106-
│ 2022-04-11 21:51:56 │ rf │ registration │ v1.2.3 │ - │ d1d9736 │ Alexander Guschin │
107-
│ 2022-04-11 21:51:57 │ rf │ commit │ - │ - │ 16b7b77 │ Alexander Guschin │
108-
│ 2022-04-11 21:51:57 │ rf │ registration │ v1.2.4 │ - │ 16b7b77 │ Alexander Guschin │
109-
│ 2022-04-11 21:51:57 │ rf │ promotion │ v1.2.3 │ production │ d1d9736 │ Alexander Guschin │
110-
│ 2022-04-11 21:51:58 │ rf │ promotion │ v1.2.4 │ staging │ 16b7b77 │ Alexander Guschin │
111-
│ 2022-04-11 21:51:59 │ rf │ promotion │ v1.2.4 │ production │ 16b7b77 │ Alexander Guschin │
112-
│ 2022-04-11 21:52:01 │ rf │ promotion │ v1.2.3 │ production │ d1d9736 │ Alexander Guschin │
124+
│ 2022-04-18 18:49:34 │ rf │ commit │ - │ - │ 0e87447 │ Alexander Guschin │
125+
│ 2022-04-18 18:49:36 │ rf │ registration │ v1.0.0 │ - │ 0e87447 │ Alexander Guschin │
126+
│ 2022-04-18 18:50:38 │ rf │ commit │ - │ - │ ff5d58e │ Alexander Guschin │
127+
│ 2022-04-18 18:50:41 │ rf │ registration │ v1.0.1 │ - │ ff5d58e │ Alexander Guschin │
128+
│ 2022-04-18 18:51:45 │ rf │ promotion │ v1.0.0 │ production │ 0e87447 │ Alexander Guschin │
129+
│ 2022-04-18 18:52:48 │ rf │ promotion │ v1.0.1 │ staging │ ff5d58e │ Alexander Guschin │
113130
╘═════════════════════╧════════╧══════════════╧═══════════╧════════════╧══════════╧═══════════════════╛
114131
```
115132

116-
## Act on new versions and promotions in CI
133+
### Act on new versions and promotions in CI
134+
135+
To act upon created git tags, you can create simple CI workflow. With GH actions it can look like this:
136+
```
137+
name: Act on git tags that register versions / promote "rf" actifact
138+
on:
139+
push:
140+
tags:
141+
- "rf*"
142+
```
117143

118-
When CI is triggered, you can use the triggering git reference to determine the version of the artifact that was registered or promoted. In GH Actions you can use the `GITHUB_REF` environment variable to determine the version (check out GH Actions workflow in the example repo). You can also do that locally:
144+
When CI is triggered, you can use the git reference to determine the version of the artifact that was registered or promoted. In GH Actions you can use the `GITHUB_REF` environment variable to determine the version (check out GH Actions workflow in the example repo). You can parse tags manually or use `gto check-ref`. You can check out how it works locally:
119145

120146
```
121147
$ gto check-ref rf@v1.0.1
122-
WARNING:root:Provided ref doesn't exist or it is not a tag that promotes to an environment
123-
env: {}
124148
version:
125149
rf:
126150
artifact: rf
@@ -138,58 +162,52 @@ To get the latest artifact version, it's path and git reference, run:
138162
```
139163
$ gto latest rf
140164
v1.0.1
141-
$ gto latest rf --path
142-
models/random-forest.pkl
143165
$ gto latest rf --ref
144-
9fbb8664a4a48575ee5d422e177174f20e460b94
166+
rf@v1.0.1
145167
```
146168

147169
To get the version that is currently promoted to environment, run:
148170

149171
```
150172
$ gto which rf production
151173
v1.0.0
152-
$ gto which rf production --path
153-
models/random-forest.pkl
154174
$ gto which rf production --ref
155-
5eaf15a9fbb8664a4a48575ee5d422e177174f20e460b94
175+
rf#production#2
156176
```
157177

158-
To download artifacts that are stored with DVC or outside of repo, e.g. in `s3://` or in DVC cache, you'll need DVC or aws CLI.
178+
To get details about those artifacts from `artifacts.yaml`, use `gto describe`:
179+
```
180+
$ gto describe rf
181+
{
182+
"type": "model",
183+
"path": "models/random-forest.pkl",
184+
"virtual": false
185+
}
186+
```
159187

160188
## Configuration
161189

162190
You can write configuration in `.gto` file in the root of your repo or use environment variables like this (note the `GTO_` prefix):
163191
```shell
164-
GTO_EMOJIS=true gto show
192+
GTO_EMOJIS=false gto show
165193
```
166194

167-
The default config written to `.gto` file will look like this (comments are there to help clarify the settings meaning and valid values):
195+
The example config written to `.gto` file could look like this:
168196
```
169-
type_allowed: [] # list of allowed types
170-
stage_allowed: [] # list of allowed Stages to promote to
197+
type_allowed: [model, dataset] # list of allowed types
198+
stage_allowed: [dev, stage, prod] # list of allowed Stages
171199
```
172200

173-
If a list/dict should allow something but it's empty, that means that all values are allowed.
174-
175-
## Trying it out
176-
177-
### See example repo
178-
179-
Check out the example repo:
180-
https://github.com/iterative/gto-example
181-
read README in it and try it out
182-
183-
### To try out the latest version
201+
## Trying out the latest version
184202

185-
#### 1. Clone this repository
203+
### 1. Clone this repository
186204

187205
```bash
188206
git clone git@github.com:iterative/gto.git
189207
cd gto
190208
```
191209

192-
#### 2. Create virtual environment named `venv`
210+
### 2. Create virtual environment named `venv`
193211
```bash
194212
python3 -m venv venv
195213
source venv/bin/activate
@@ -200,7 +218,7 @@ Install python libraries
200218
pip install --upgrade pip setuptools wheel ".[tests]"
201219
```
202220

203-
#### 3. Run
221+
### 3. Run
204222

205223
```bash
206224
pytest --basetemp=pytest-cache

0 commit comments

Comments
 (0)