Training¶
arkindex_worker.worker.training ¶
BaseWorker methods for training.
Attributes¶
Classes¶
TrainingMixin ¶
A mixin helper to create a new model version easily.
You may use publish_model_version
to publish a ready model version directly, or
separately create the model version then publish it (e.g to store training metrics).
Stores the currently handled model version as self.model_version
.
Attributes¶
is_finetuning
property
¶
is_finetuning: bool
Whether or not this worker is fine-tuning an existing model version.
Functions¶
publish_model_version ¶
publish_model_version(
model_path: DirPath,
model_id: str,
tag: str | None = None,
description: str | None = None,
configuration: dict | None = None,
parent: str | UUID | None = None,
)
Publish a unique version of a model in Arkindex, identified by its hash.
In case the create_model_version
method has been called, reuses that model
instead of creating a new one.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
model_path |
DirPath
|
Path to the directory containing the model version’s files. |
required |
model_id |
str
|
ID of the model |
required |
tag |
str | None
|
Tag of the model version |
None
|
description |
str | None
|
Description of the model version |
None
|
configuration |
dict | None
|
Configuration of the model version |
None
|
parent |
str | UUID | None
|
ID of the parent model version |
None
|
Source code in arkindex_worker/worker/training.py
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 |
|
create_model_version ¶
create_model_version(
model_id: str,
tag: str | None = None,
description: str | None = None,
configuration: dict | None = None,
parent: str | UUID | None = None,
)
Create a new version of the specified model with its base attributes.
Once successfully created, the model version is accessible via self.model_version
.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
tag |
str | None
|
Tag of the model version |
None
|
description |
str | None
|
Description of the model version |
None
|
configuration |
dict | None
|
Configuration of the model version |
None
|
parent |
str | UUID | None
|
ID of the parent model version |
None
|
Source code in arkindex_worker/worker/training.py
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 |
|
update_model_version ¶
update_model_version(
tag: str | None = None,
description: str | None = None,
configuration: dict | None = None,
parent: str | UUID | None = None,
)
Update the current model version with the given attributes.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
tag |
str | None
|
Tag of the model version |
None
|
description |
str | None
|
Description of the model version |
None
|
configuration |
dict | None
|
Configuration of the model version |
None
|
parent |
str | UUID | None
|
ID of the parent model version |
None
|
Source code in arkindex_worker/worker/training.py
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 |
|
upload_to_s3 ¶
upload_to_s3(archive_path: Path) -> None
Upload the archive of the model’s files to an Amazon s3 compatible storage
Source code in arkindex_worker/worker/training.py
234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 |
|
validate_model_version ¶
validate_model_version(
hash: str, size: int, archive_hash: str
)
Sets the model version as Available
, once its archive has been uploaded to S3.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
hash |
str
|
MD5 hash of the files contained in the archive |
required |
size |
int
|
The size of the uploaded archive |
required |
archive_hash |
str
|
MD5 hash of the uploaded archive |
required |
Source code in arkindex_worker/worker/training.py
260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 |
|
Functions¶
create_archive ¶
create_archive(
path: DirPath,
) -> tuple[Path, Hash, FileSize, Hash]
Create a tar archive from the files at the given location then compress it to a zst archive.
Yield its location, its hash, its size and its content’s hash.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
path |
DirPath
|
Create a compressed tar archive from the files |
required |
Returns:
Type | Description |
---|---|
tuple[Path, Hash, FileSize, Hash]
|
The location of the created archive, its hash, its size and its content’s hash |
Source code in arkindex_worker/worker/training.py
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
|
build_clean_payload ¶
build_clean_payload(**kwargs)
Remove null attributes from an API body payload
Source code in arkindex_worker/worker/training.py
50 51 52 53 54 |
|
skip_if_read_only ¶
skip_if_read_only(func)
Return shortly in case the is_read_only property is evaluated to True
Source code in arkindex_worker/worker/training.py
57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 |
|