scitq.lib technical documentation
LazyObject
A lazy object or dict initialized with a queue.Queue perform q.get as soon as you try to use it...
Source code in src/scitq/lib.py
65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 | |
__getattr__(__name)
Retrieve real attribute (object style) in real object once it is there
Source code in src/scitq/lib.py
72 73 74 75 76 | |
__getitem__(__key)
Retrieve real key in real object (dict style) once it is there
Source code in src/scitq/lib.py
77 78 79 80 81 | |
__init__(q)
Initialize object with queue.Queue q
Source code in src/scitq/lib.py
68 69 70 71 | |
__str__()
Wait for real object and use real object representation
Source code in src/scitq/lib.py
82 83 84 85 86 | |
RestartingThread
This Thread class is a thin wrapper above a threading.Thread that can be restarted, it implements only start() and is_alive() methods
Source code in src/scitq/lib.py
123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 | |
Server
A thin wrapper above requests with URLs registered and several extrathings: - output is JSON de-marshalled, - date are converted, - if server is not accessible, the lib will retry or do the job later, - expected arguments are explicit which makes life easier.
Arguments: - ip: the name or IP address of server, - style: if 'dict' (default) all the objects are rendered as dict, if 'object', dict are passed to Namespace to produce real Python objects.
Source code in src/scitq/lib.py
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 249 250 251 252 253 254 255 256 257 258 259 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 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 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 | |
__init__(ip=os.environ.get('SCITQ_SERVER', DEFAULT_SERVER), style='dict', asynchronous=True, put_timeout=PUT_TIMEOUT, get_timeout=GET_TIMEOUT)
initialise the object with IP or name of the server
Arguments: - ip: the name or IP address of server, - style: if 'dict' (default) all the objects are rendered as dict, if 'object', dict are passed to Namespace to produce real Python objects. - asynchronous: if True (default) then put and post operations are asynchronous, if False then all operations will wait (forever) for the server to come back. get operations are always synchronous
Source code in src/scitq/lib.py
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 | |
batch_delete(batch, asynchronous=True)
List all batches, their tasks and workers
Source code in src/scitq/lib.py
554 555 556 | |
batch_go(batch, signal=0, asynchronous=True)
(re)set all workers affected to this batch to running
Source code in src/scitq/lib.py
545 546 547 548 | |
batch_stop(batch, signal=0, asynchronous=True)
Pause all workers for this batch
Source code in src/scitq/lib.py
538 539 540 541 542 543 | |
batches()
List all batches, their tasks and workers
Source code in src/scitq/lib.py
550 551 552 | |
config_rclone()
Provide the content of current rclone file
Source code in src/scitq/lib.py
593 594 595 | |
config_remote()
Provide remote resources base URI
Source code in src/scitq/lib.py
597 598 599 | |
delete(url, asynchronous=None, timeout=None)
A wrapper used for all put operations. - url: extra string to add after base server URL - data: extra data (payload of put operation) represented as dict
return the objects according to Server style (see style in class doc) (in asynchronous mode, return a lazy object)
Source code in src/scitq/lib.py
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 | |
execution_create(worker_id, task_id, status='pending', command=None, asynchronous=True)
Create a new execution, return the newly created execution
Source code in src/scitq/lib.py
380 381 382 383 384 385 386 387 388 389 | |
execution_error_write(id, error, asynchronous=True)
Add some error (stderr) to a specific execution, return the updated execution
Source code in src/scitq/lib.py
413 414 415 416 417 418 419 420 421 | |
execution_get(id)
get a specific execution with execution_id equal to id return the execution
Source code in src/scitq/lib.py
423 424 425 426 | |
execution_output(id, output=None, error=None, output_position=None, error_position=None)
get the output and error flow (can be restricted to one or the other specifying error=False or output=False) starting from a given position (notably to get only newer output or error flow): first character is position 1
Source code in src/scitq/lib.py
428 429 430 431 432 433 | |
execution_output_write(id, output, asynchronous=True)
Add some output to a specific execution, return the updated execution
Source code in src/scitq/lib.py
403 404 405 406 407 408 409 410 411 | |
execution_update(id, status=None, pid=None, return_code=None, output=None, error=None, output_files=None, command=None, freeze=False, asynchronous=True)
Update a specific execution, return the updated execution
Source code in src/scitq/lib.py
391 392 393 394 395 396 397 398 399 400 401 | |
executions(**args)
Get a list of all executions. Optional args are optional attributes to filter list with: - task_id: int - status: str - latest: boolean - batch: str - task_name: str - limit: int (limit results to N) - reverse: set to true to have most recent executions first (default to False) - trunc: trunc output/error to this size (trunc, keeping only this number of last characters)
Source code in src/scitq/lib.py
366 367 368 369 370 371 372 373 374 375 376 377 378 | |
flavor_find(cpu=0, ram=0, disk=0, max_eviction=FLAVOR_DEFAULT_EVICTION, n=1)
Return a flavor or a list of flavor if n>0
Source code in src/scitq/lib.py
671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 | |
flavors(min_cpu=0, min_ram=0, min_disk=0, max_eviction=FLAVOR_DEFAULT_EVICTION, limit=FLAVOR_DEFAULT_LIMIT, provider=None, region=None, protofilters=None)
List all available flavors
Source code in src/scitq/lib.py
665 666 667 668 669 | |
get(url, wrap=None, **args)
A wrapper used for all get operations. - url: extra string to add after base server URL - wrap: an optional argument for use in special case
return the objects according to Server style (see style in class doc)
Source code in src/scitq/lib.py
194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 | |
join(task_list, retry=1, check=False)
Wait for a certain list of tasks to succeed. In case of failure, relaunch tasks a limited number of time (retry). If check is True, then join will fail if one of the task fails (after all retries). Return a dictionary of the different status of tasks when tasks were all done
Source code in src/scitq/lib.py
601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 | |
post(url, data, asynchronous=None, timeout=None)
A wrapper used for all post operations. - url: extra string to add after base server URL - data: extra data (payload of post operation) represented as dict
return the objects according to Server style (see style in class doc)
Source code in src/scitq/lib.py
244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 | |
put(url, data, asynchronous=None, timeout=None)
A wrapper used for all put operations. - url: extra string to add after base server URL - data: extra data (payload of put operation) represented as dict
return the objects according to Server style (see style in class doc) (in asynchronous mode, return a lazy object)
Source code in src/scitq/lib.py
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 | |
queue_size()
A method to estimate send queue size
Source code in src/scitq/lib.py
190 191 192 | |
recruiter_create(batch, rank, tasks_per_worker, flavor, concurrency, region=None, provider=None, prefetch=None, minimum_tasks=None, maximum_workers=None, asynchronous=True)
Create a new recruiter (or update an existing recruiter of the same rank)
Source code in src/scitq/lib.py
563 564 565 566 567 568 569 570 571 | |
recruiter_delete(batch, rank, asynchronous=True)
Delete an existing recruiter
Source code in src/scitq/lib.py
584 585 586 | |
recruiter_update(batch, rank, tasks_per_worker=None, flavor=None, region=None, provider=None, concurrency=None, prefetch=None, minimum_tasks=None, maximum_workers=None, asynchronous=True)
Update an existing recruiter
Source code in src/scitq/lib.py
573 574 575 576 577 578 579 580 581 582 | |
recruiters(**args)
List all recruiters (a recruiter is an automate that deploy workers as needed for a certain batch) - args: some filtering option like batch='Default'
Source code in src/scitq/lib.py
558 559 560 561 | |
recruiters_match(**args)
List all recruiters (a recruiter is an automate that deploy workers as needed for a certain batch) - args: some filtering option like batch='Default'
Source code in src/scitq/lib.py
588 589 590 591 | |
task_create(command, name=None, status=None, batch=None, input=None, output=None, container=None, container_options='', resource=None, required_task_ids=None, shell=False, retry=None, download_timeout=None, run_timeout=None, use_cache=None, asynchronous=True)
Create a new task, return the newly created task
Source code in src/scitq/lib.py
435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 | |
task_delete(id, asynchronous=True)
delete a specific task
Source code in src/scitq/lib.py
509 510 511 | |
task_freeze(id, execution_id)
get a specific task with task_id equal to id - and copy values to execution execution_id return the task
Source code in src/scitq/lib.py
487 488 489 490 | |
task_get(id)
get a specific task with task_id equal to id return the task
Source code in src/scitq/lib.py
482 483 484 485 | |
task_status(task_id_list)
Get a list of tasks'status Only one mandatory argument, a list of task.task_id: - task_id_list: list(int)
Source code in src/scitq/lib.py
502 503 504 505 506 507 | |
task_update(id, command=None, name=None, status=None, batch=None, input=None, output=None, container=None, container_options=None, resource=None, required_task_ids=None, retry=None, download_timeout=None, run_timeout=None, use_cache=None, asynchronous=True)
Update a specific execution, return the updated execution
Source code in src/scitq/lib.py
462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 | |
tasks(**args)
Get a list of all tasks Optional args are optional attributes to filter list with: - task_id: list(int) - status: str - batch: str - name: str
Source code in src/scitq/lib.py
492 493 494 495 496 497 498 499 500 | |
worker_callback(id, message, asynchronous=False)
Send a callback message (mainly idle) to trigger action on worker from the server return a object with result attribute, equal to ok
Source code in src/scitq/lib.py
343 344 345 346 347 | |
worker_create(name, concurrency, hostname=None, status='paused', batch=None, permanent=None, prefetch=0, flavor=None, asynchronous=True)
Create a new worker return the new worker (or None if the server timeout)
Source code in src/scitq/lib.py
321 322 323 324 325 326 327 328 329 330 | |
worker_create_signal(id, execution_id, signal, asynchronous=True)
Create a signal for this worker
Source code in src/scitq/lib.py
517 518 519 520 521 522 | |
worker_delete(id, asynchronous=True)
Delete a worker
Source code in src/scitq/lib.py
358 359 360 | |
worker_deploy(number, batch, region, flavor, concurrency, provider, prefetch=0, asynchronous=True)
Deploy (and create) some workers
Source code in src/scitq/lib.py
524 525 526 527 528 529 530 531 532 533 534 535 536 | |
worker_executions(id, status=None)
Get a list of a worker current assigned executions. If status is used, only executions with this status are shown
Source code in src/scitq/lib.py
349 350 351 352 353 354 355 356 | |
worker_get(id)
get a specific worker with worker_id equal to id return the worker
Source code in src/scitq/lib.py
332 333 334 335 | |
worker_ping(id, load, memory, stats, asynchronous=False)
Update a specific worker ping time (heartbit) return a updated worker object with attribute or key (depending on style)
Source code in src/scitq/lib.py
337 338 339 340 341 | |
worker_signals(id)
Get a list of signals for this worker
Source code in src/scitq/lib.py
513 514 515 | |
worker_update(id, name=None, hostname=None, concurrency=None, status=None, batch=None, permanent=None, prefetch=None, flavor=None, task_properties=None, asynchronous=True)
Update a specific worker with worker_id equal to id return the updated worker (or None if the server timeout)
Source code in src/scitq/lib.py
310 311 312 313 314 315 316 317 318 319 | |
workers(**args)
Get a list of all workers
Source code in src/scitq/lib.py
306 307 308 | |
workers_tasks()
Return a list of all the different tasks for a certain worker
Source code in src/scitq/lib.py
362 363 364 | |
query_thread(send_queue, put_timeout)
A Query-thread which treats all the queries with a while loop until the object is there, then it put the result in the returning queue
Source code in src/scitq/lib.py
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 | |