ModelKitManager class
You can import the ModelKitManager class from kitops.modelkit.manager:
from kitops.modelkit.manager import ModelKitManager
A class to represent a modelkit manager. This class manages the user credentials and modelkit reference. Attributes: user_credentials (UserCredentials): The user credentials. modelkit_reference (ModelKitReference): The modelkit reference. Methods: init(): Initializes the ModelKitManager instance. working_directory: Gets or sets the working directory. user_credentials: Gets or sets the user credentials. modelkit_reference: Gets or sets the modelkit reference.
Source code in kitops/modelkit/manager.py
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 | |
kitfile: Kitfile
property
writable
modelkit_reference: ModelKitReference
property
writable
Gets the modelkit reference.
Returns:
| Name | Type | Description |
|---|---|---|
ModelKitReference |
ModelKitReference
|
The modelkit reference. |
user_credentials
property
writable
Gets the user credentials.
Returns:
working_directory: str
property
writable
Gets the working directory.
Returns:
| Name | Type | Description |
|---|---|---|
str |
str
|
The working directory. |
__init__(working_directory=os.getcwd(), user_credentials=None, modelkit_reference=None, modelkit_tag=None)
Initializes the ModelKitManager instance.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
working_directory
|
str
|
The working directory. Defaults to os.getcwd(). This is the directory used by the ModelKitManager to work with the given ModelKit or used to create a new ModelKit. The ModelKit's Kitfile is also read from and saved to this directory. If the given directory does not exist, it will be created, if possible; otherwise, an error will be raised. |
getcwd()
|
user_credentials
|
Optional[UserCredentials]
|
The user credentials. Defaults to None. If None, the user credentials are loaded from environment variables. |
None
|
modelkit_reference
|
Optional[ModelKitReference]
|
The modelkit reference. Defaults to None. If None, the modelkit reference is created from the modelkit tag. |
None
|
modelkit_tag
|
Optional[str]
|
The modelkit tag to parse into a ModelKitReference. Defaults to None. If None, an empty ModelKitReference is created. |
None
|
Examples:
>>> manager = ModelKitManager()
>>> manager.working_directory
<WorkingDirectory>
>>> manager.user_credentials
<UserCredentials>
>>> manager.modelkit_reference
<ModelKitReference>
Source code in kitops/modelkit/manager.py
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 | |
pack_and_push_modelkit(save_kitfile=False)
Packs the ModelKit from the working directory and pushes it to the registry.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
save_kitfile
|
bool
|
If True, the Kitfile will be saved to the working directory before the Kitfile is packed and pushed. Defaults to False. |
False
|
Returns:
| Type | Description |
|---|---|
None
|
None |
Source code in kitops/modelkit/manager.py
189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 | |
pull_and_unpack_modelkit(load_kitfile=False, filters=None)
Unpacks the ModelKit into the working directory.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
filters
|
Optional[list[str]]
|
The filters to apply when unpacking the ModelKit. Defaults to None. The filters are used to specify the Kitfile parts to unpack from the ModelKit (e.g. ["model", "data"]). If None, all parts are unpacked. |
None
|
load_kitfile
|
bool
|
If True, the Kitfile will be loaded from the working directory afer the ModelKit has been unpacked. Defaults to False. |
False
|
Returns:
| Type | Description |
|---|---|
None
|
None |
Source code in kitops/modelkit/manager.py
155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 | |
remove_modelkit(local=False, remote=False)
Removes the ModelKit from the registry.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
local
|
Optional[bool]
|
If True, the ModelKit will be removed from the local registry. Defaults to True. |
False
|
remote
|
Optional[bool]
|
If True, the ModelKit will be removed from the remote registry. |
False
|
Returns:
| Type | Description |
|---|---|
None
|
None |
Examples:
>>> modelkit_tag = "jozu.ml/brett/titanic-survivability:latest"
>>> manager = ModelKitManager(working_directory = "temp/titanic-full",
... modelkit_tag = modelkit_tag)
>>> manager.remove_modelkit(local = True, remote = True)
Source code in kitops/modelkit/manager.py
219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 | |