Skip to content

Commit 2267fa8

Browse files
committed
Restore erronously removed docs.
Restores the part of the docs that was removed by mistake.
1 parent df7f437 commit 2267fa8

File tree

1 file changed

+168
-14
lines changed

1 file changed

+168
-14
lines changed

docs/how-to-guides.md

Lines changed: 168 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,21 @@ Whether you're working with an existing ModelKit's Kitfile,
1111
or starting from nothing, the `kitops` package can help you
1212
get this done.
1313

14+
### Installation
15+
1416
Install the `kitops` package from PYPI into your project's environment
1517
with the following command
1618

1719
```sh
1820
pip install kitops
1921
```
2022

23+
### Creating a Kitfile
24+
25+
There are two main ways to work with Kitfiles: creating from scratch or loading an existing one.
26+
27+
#### Loading an Existing Kitfile
28+
2129
Inside of your code you can now import the `Kitfile`
2230
class from the `kitops.modelkit.kitfile` module:
2331

@@ -38,6 +46,8 @@ print(my_kitfile.to_yaml())
3846
# located at: /path/to/Kitfile
3947
```
4048

49+
#### Creating a New Kitfile
50+
4151
You can also create an empty Kitfile from scratch:
4252

4353
```python
@@ -53,21 +63,165 @@ Regardless of how you created the Kitfile, you can update its contents
5363
like you would do with any other python dictionary:
5464

5565
```python
56-
my_kitfile.manifestVersion = "3.0"
57-
my_kitfile.package = {
58-
"name": "Another-Package",
59-
"version": "3.0.0",
60-
"description": "Another description",
61-
"authors": ["Someone"]
66+
from kitops.modelkit.kitfile import Kitfile
67+
68+
# Create new Kitfile
69+
kitfile = Kitfile()
70+
71+
# Set basic metadata
72+
kitfile.manifestVersion = "1.0"
73+
kitfile.package = {
74+
"name": "sample-kitfile",
75+
"version": "1.0",
76+
"description": "Sample kitfile for PyKitOps demonstration"
6277
}
63-
print(my_kitfile.to_yaml())
78+
79+
# Configure model information
80+
kitfile.model = {
81+
"name": "sample-model",
82+
"path": "model/model.pkl",
83+
"license": "Apache 2.0",
84+
"version": "1.0",
85+
"description": "Sample Model"
86+
}
87+
88+
# Add code files
89+
kitfile.code = [
90+
{
91+
"path": "demo.py",
92+
"description": "Sample model to demonstrate PyKitOps SDK",
93+
"license": "Apache 2.0"
94+
},
95+
{
96+
"path": "requirements.txt",
97+
"description": "Python dependencies"
98+
}
99+
]
100+
101+
# Add datasets
102+
kitfile.datasets = [
103+
{
104+
"name": "dataset",
105+
"path": "data/sample.csv",
106+
"description": "full dataset",
107+
"license": "Apache 2.0"
108+
}
109+
]
110+
111+
# Add documentation
112+
kitfile.docs = [
113+
{"path": "docs/README.md"},
114+
{"path": "docs/LICENSE"}
115+
]
64116

65117
# OUTPUT:
66-
# manifestVersion: '3.0'
67-
# package:
68-
# name: Another-Package
69-
# version: 3.0.0
70-
# description: Another description
71-
# authors:
72-
# - Someone
118+
# manifestVersion: '1.0'
119+
# package:
120+
# name: sample-kitfile
121+
# version: '1.0'
122+
# description: Sample kitfile for PyKitOps demonstration
123+
# code:
124+
# - path: demo.py
125+
# description: Sample model to demonstrate PyKitOps SDK
126+
# license: Apache 2.0
127+
# - path: requirements.txt
128+
# description: Python dependencies
129+
# datasets:
130+
# - name: dataset
131+
# path: data/sample.csv
132+
# description: full dataset
133+
# license: Apache 2.0
134+
# docs:
135+
# - path: docs/README.md
136+
# - path: docs/LICENSE
137+
# model:
138+
# name: sample-model
139+
# path: model/model.pkl
140+
# license: Apache 2.0
141+
# version: '1.0'
142+
# description: Sample Model
73143
```
144+
145+
### Pushing to Jozu Hub
146+
147+
Once you've created your Kitfile, you can push it to Jozu Hub using the ModelKitManager. Here's how:
148+
149+
```python
150+
from kitops.modelkit.manager import ModelKitManager
151+
152+
# Configure the ModelKit manager
153+
modelkit_tag = "jozu.ml/yourname/reponame:latest"
154+
manager = ModelKitManager(
155+
working_directory=".",
156+
modelkit_tag=modelkit_tag
157+
)
158+
159+
# Assign your Kitfile
160+
manager.kitfile = kitfile
161+
162+
# Pack and push to Jozu Hub
163+
manager.pack_and_push_modelkit(save_kitfile=True)
164+
```
165+
166+
### Complete Example
167+
168+
Here's a complete script that creates a Kitfile and pushes it to Jozu Hub:
169+
170+
```python
171+
import os
172+
from kitops.modelkit.kitfile import Kitfile
173+
from kitops.modelkit.manager import ModelKitManager
174+
175+
if __name__ == "__main__":
176+
# Create the Kitfile
177+
kitfile = Kitfile()
178+
kitfile.manifestVersion = "1.0"
179+
kitfile.package = {
180+
"name": "sample-kitfile",
181+
"version": "1.0",
182+
"description": "Sample kitfile for PyKitOps demonstration"
183+
}
184+
185+
kitfile.model = {
186+
"name": "sample-model",
187+
"path": "model/model.pkl",
188+
"license": "Apache 2.0",
189+
"version": "1.0",
190+
"description": "Sample Model"
191+
}
192+
193+
kitfile.code = [
194+
{
195+
"path": "demo.py",
196+
"description": "Sample model to demonstrate PyKitOps SDK",
197+
"license": "Apache 2.0"
198+
},
199+
{
200+
"path": "requirements.txt",
201+
"description": "Python dependencies"
202+
}
203+
]
204+
205+
kitfile.datasets = [
206+
{
207+
"name": "dataset",
208+
"path": "data/sample.csv",
209+
"description": "full dataset",
210+
"license": "Apache 2.0"
211+
}
212+
]
213+
214+
kitfile.docs = [
215+
{"path": "docs/README.md"},
216+
{"path": "docs/LICENSE"}
217+
]
218+
219+
# Push to Jozu Hub
220+
modelkit_tag = "jozu.ml/yourname/reponame:latest"
221+
manager = ModelKitManager(
222+
working_directory=".",
223+
modelkit_tag=modelkit_tag
224+
)
225+
manager.kitfile = kitfile
226+
manager.pack_and_push_modelkit(save_kitfile=True)
227+
```

0 commit comments

Comments
 (0)