job
ImageOptions ¶
Bases: BaseModel
Options to configure the build of the Docker image used to execute a
jobq.Job
in the cluster.
Either the spec
argument or the dockerfile
argument must be
given, and if given, spec
must be an existing file containing
valid YAML.
Source code in client/src/jobq/job.py
name
class-attribute
instance-attribute
¶
The name under which the image should be pushed to the cluster image registry.
tag
class-attribute
instance-attribute
¶
The tag identifier to use for the newly built Docker image.
spec
class-attribute
instance-attribute
¶
Path to a YAML spec file describing a Docker image build.
dockerfile
class-attribute
instance-attribute
¶
Path to an existing Dockerfile to use for the image build.
ResourceOptions ¶
Bases: JsonSerializable
, DictSerializable
, BaseModel
Options for requesting cluster compute resources for a jobq.Job
.
Memory and CPU values need to be given as <num> <prefix>
, where num
is a floating point number, and prefix is one of the following SI metric
prefixes:
* m, k, M, G, T
(base 10)
* Ki, Mi, Gi, Ti
(base 2).
Source code in client/src/jobq/job.py
SchedulingOptions ¶
Bases: BaseModel
Options configuring a jobq.Job
's priority in the cluster, and
the Kueue cluster queue name the job should be submitted to.
Source code in client/src/jobq/job.py
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 |
|
priority_class
class-attribute
instance-attribute
¶
Name of a Kueue priority class to use for the job. Must exist in the target cluster.
queue_name
instance-attribute
¶
The Kueue cluster queue name to submit the job to. Must refer to an existing queue in the cluster, otherwise the resulting workload will be marked inadmissible.
to_str ¶
to_json ¶
Returns the JSON representation of the model using alias
from_json
classmethod
¶
to_dict ¶
Return the dictionary representation of the model using alias.
This has the following differences from calling pydantic's
self.model_dump(by_alias=True)
:
None
is only added to the output dict for nullable fields that were set at model initialization. Other fields with valueNone
are ignored.
Source code in client/src/jobq/job.py
from_dict
classmethod
¶
Create an instance of SchedulingOptions from a dict
Source code in client/src/jobq/job.py
JobOptions ¶
Bases: JsonSerializable
, DictSerializable
, BaseModel
Options for customizing a Kubernetes job definition from a Python function.
Source code in client/src/jobq/job.py
resources
class-attribute
instance-attribute
¶
resources: ResourceOptions | None = None
Compute resources to request for the job.
scheduling
instance-attribute
¶
scheduling: SchedulingOptions
Information about the Kueue cluster queue, and job priority.
labels
class-attribute
instance-attribute
¶
Kubernetes labels to attach to the resulting Kueue workload.
Job ¶
Bases: Generic[P, T]
Source code in client/src/jobq/job.py
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 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 |
|
job ¶
job(
*, options: JobOptions | None = None, image: ImageOptions | None = None
) -> Callable[[Callable[P, T]], Job[P, T]]
A decorator to declare a Python function as a Kubernetes job, to be packaged and sent to a Kueue cluster queue for execution.
PARAMETER | DESCRIPTION |
---|---|
options |
Additional options to customize the job with. The given options influence scheduling, resource allocation for the job in the cluster, and labels to identify the job with.
TYPE:
|
image |
Options for customizing the Docker image build. Includes the image name, tag, and either a YAML spec file to build a Dockerfile from, or alternatively, a path to a pre-existing Dockerfile.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
Job
|
The actual Job instance wrapping the decorated function. |
Source code in client/src/jobq/job.py
validate_labels ¶
Validate the syntactic correctness of user-specified job labels.
Note that the rules for labels are the intersection (i.e., the strictest subset) of syntax restrictions on Docker labels and Kubernetes annotations, so that the labels can be applied in either context.
See the following documents for further reference: - Docker: https://docs.docker.com/config/labels-custom-metadata/#value-guidelines - Kubernetes: https://kubernetes.io/docs/concepts/overview/working-with-objects/annotations/#syntax-and-character-set
RAISES | DESCRIPTION |
---|---|
ValueError
|
if the labels are not well-formed |