Default Kernel
penvm.kernels.default.client
Client-side interface to access the "default" kernel operations.
See penvm.kernels.default.server.
KernelClient
Bases: _KernelClient
Additional kernel ops.
Source code in penvm/src/kernels/penvm/kernels/default/client.py
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 249 250 251 252 253 |
|
file_copyfrom(rpath, lpath, blksize=1024)
Copy remote file to local.
Source code in penvm/src/kernels/penvm/kernels/default/client.py
75 76 77 |
|
file_copyto(lpath, rpath, blksize=1024)
Copy local file to remote.
Source code in penvm/src/kernels/penvm/kernels/default/client.py
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 |
|
file_get_block(filename, start=None, size=None)
See penvm.kernels.default.server.FileGetBlock.
Source code in penvm/src/kernels/penvm/kernels/default/client.py
79 80 81 82 83 84 85 86 87 88 |
|
file_get_status(path)
See penvm.kernels.default.server.FileGetStatus.
Source code in penvm/src/kernels/penvm/kernels/default/client.py
90 91 92 93 94 95 |
|
file_list(path, pattern=None, sort=None, split=None)
See penvm.kernels.default.server.FileList.
Source code in penvm/src/kernels/penvm/kernels/default/client.py
97 98 99 100 101 102 103 104 105 106 107 108 |
|
file_put_block(path, data, start=None, size=None, truncate=None)
See penvm.kernels.default.server.FilePutBlock.
Source code in penvm/src/kernels/penvm/kernels/default/client.py
110 111 112 113 114 115 116 117 118 119 120 121 122 |
|
file_set_status(path, uid=None, gid=None, user=None, group=None, mode=None)
See penvm.kernels.default.server.FileSetStatus.
Source code in penvm/src/kernels/penvm/kernels/default/client.py
124 125 126 127 128 129 130 131 132 133 134 |
|
run_exec(path, args, capture_output=False, text=True, env=None, cwd=None, path_key=None)
See penvm.kernels.default.server.RunExec.
Source code in penvm/src/kernels/penvm/kernels/default/client.py
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 |
|
run_exec_stream(path, args, capture_output=False, text=True, env=None, wd=None, path_key=None)
See penvm.kernels.default.server.RunExecStream.
Source code in penvm/src/kernels/penvm/kernels/default/client.py
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 |
|
run_python(code, args=None, kwargs=None, _globals=None, _locals=None)
See penvm.kernels.default.server.RunPython.
Source code in penvm/src/kernels/penvm/kernels/default/client.py
188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 |
|
run_python_function(code, fnname, args=None, kwargs=None)
See penvm.kernels.default.server.RunPythonFunction.
Source code in penvm/src/kernels/penvm/kernels/default/client.py
205 206 207 208 209 210 211 212 213 |
|
store_drop(name)
See penvm.kernels.default.server.StoreDrop.
Source code in penvm/src/kernels/penvm/kernels/default/client.py
215 216 217 218 219 220 |
|
store_get(name)
See penvm.kernels.default.server.StoreGet.
Source code in penvm/src/kernels/penvm/kernels/default/client.py
222 223 224 225 226 227 |
|
store_get_state()
See penvm.kernels.default.server.StoreGetState.
Source code in penvm/src/kernels/penvm/kernels/default/client.py
229 230 231 |
|
store_list(pattern=None)
See penvm.kernels.default.server.StoreList.
Source code in penvm/src/kernels/penvm/kernels/default/client.py
233 234 235 236 237 238 |
|
store_pop(name)
See penvm.kernels.default.server.StorePop.
Source code in penvm/src/kernels/penvm/kernels/default/client.py
240 241 242 243 244 245 |
|
store_put(name, data)
See penvm.kernels.default.server.StorePut.
Source code in penvm/src/kernels/penvm/kernels/default/client.py
247 248 249 250 251 252 253 |
|
penvm.kernels.default.server
Server-side "default" kernel operations.
The default operations providing the necessary functionality for many/most use cases including support for: filesystem, kv store, and binary and python code execution.
For an explanation of the Request and Response sections see penvm.kernels.core.server.
FileGetBlock
Bases: Op
Read data (block) from a file object.
Request:
Name | Type | Description |
---|---|---|
path |
str
|
File path. |
size |
int
|
Size (in bytes) to read. Defaults to 1024. |
start |
int
|
Offset from file start. Defaults to 0. |
OkResponse:
Name | Type | Description |
---|---|---|
data |
bytes
|
Bytes (up to |
size |
int
|
Size (in bytes) read. |
start |
int
|
Offset from file start. |
ErrorResponse:
Name | Type | Description |
---|---|---|
- |
Error message. |
Source code in penvm/src/kernels/penvm/kernels/default/server.py
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 |
|
FileGetStatus
Bases: Op
Get file status (os.stat()
).
Request:
Name | Type | Description |
---|---|---|
path |
str
|
File path to stat. |
OkResponse:
Name | Type | Description |
---|---|---|
mode |
int
|
File mode. |
ino |
int
|
Inode. |
dev |
int
|
Device identifier. |
nlink |
int
|
Number of hard links. |
uid |
int
|
User id of file owner. |
gid |
int
|
Group id of file owner. |
size |
int
|
File size (in bytes). |
atime |
int
|
Most recent access time (in seconds). |
mtime |
int
|
Most recent content modication time (in seconds). |
ctime |
int
|
Most recent metadata change time (in seconds). |
ErrorResponse:
Name | Type | Description |
---|---|---|
- |
Error message. |
Source code in penvm/src/kernels/penvm/kernels/default/server.py
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 |
|
FileList
Bases: Op
List filenames/dirnames at filesystem path.
Request:
Name | Type | Description |
---|---|---|
path |
str
|
Directory path. |
filter |
str
|
Filename filter. Defaults to no filter. |
sort |
bool
|
Sort names. Defaults to False. |
Response:
Name | Type | Description |
---|---|---|
names |
list of str
|
List of directory entries. |
ErrorResponse:
Name | Type | Description |
---|---|---|
- |
Error message. |
Source code in penvm/src/kernels/penvm/kernels/default/server.py
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 |
|
FilePutBlock
Bases: Op
Write data (block) to a file object.
Request:
Name | Type | Description |
---|---|---|
data |
bytes
|
Data to store. |
path |
str
|
File path. |
size |
int
|
Size (in bytes) of data. |
start |
int
|
Offset from file start. Defaults to 0. |
truncate |
bool
|
Flag to indicate truncation of file. Defaults to False. |
OkResponse:
Name | Type | Description |
---|---|---|
- |
Empty. |
ErrorResponse:
Name | Type | Description |
---|---|---|
- |
Error message. |
Source code in penvm/src/kernels/penvm/kernels/default/server.py
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 |
|
FileSetStatus
Bases: Op
Set file status settings.
Request:
Name | Type | Description |
---|---|---|
path |
str
|
File object path. |
uid |
int
|
User id of file owner. |
user |
str
|
User name of file owner. |
gid |
int
|
Group id of file owner. |
group |
int
|
Group name of file owner. |
mode |
int
|
File mode. |
Response:
Name | Type | Description |
---|---|---|
- |
None. |
Source code in penvm/src/kernels/penvm/kernels/default/server.py
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 |
|
RunExec
Bases: Op
Run a locally available executable via a path with arguments.
Request:
Name | Type | Description |
---|---|---|
args |
list of string
|
Arguments. Defaults to empty list. |
capture_output |
bool
|
Capture stdout/stderr. Defaults to True. |
env |
dict|list of strings
|
Dictionary or list of strings for the environment. |
path |
str
|
Path of executable. See also |
path-key |
str
|
Name of item in file kvstore. See also |
text |
bool
|
Treat output as "text". Otherwise, "binary". |
cwd |
str
|
Working directory to run under. Defaults to "/". |
OkResponse:
Name | Type | Description |
---|---|---|
returncode |
int
|
Exit/return code |
stderr |
str
|
stderr output |
stdout |
str
|
stdout output |
Source code in penvm/src/kernels/penvm/kernels/default/server.py
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 |
|
run(ctxt, req)
Run operation.
Source code in penvm/src/kernels/penvm/kernels/default/server.py
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 |
|
RunExecStream
Bases: Op
Run a locally available executable via a path with arguments with streaming capability.
Whereas RunExec
runs the executable, waits for it to complete,
then collects and returns the stdout
, stderr
, and
returncode
, RunExecStream
streams partial results over the
lifetime of the operation. As such, an undetermined number of
responses are collected and returned. When the operation
completes, a final message will contain a returncode
!= None
.
The requester must perform queue management (e.g.,
session-pop-omq
at the server, and consume the messages at the
client side).
Note
stdin
is not supported.
Request:
Name | Type | Description |
---|---|---|
args |
list of string
|
Arguments. Defaults to empty list. |
capture_output |
bool
|
Capture stdout/stderr. Defaults to True. |
env |
bool
|
(dict|list of strings): Dictionary or list of strings for the environment. |
path |
str
|
Path of executable. See also |
path-key |
str
|
Name of item in file kvstore. See also |
text |
bool
|
Treat output as "text". Otherwise, "binary". |
cwd |
str
|
Working directory to run under. Defaults to "/". |
OkResponse:
Name | Type | Description |
---|---|---|
returncode |
int | None
|
Exit/return code. Last response sends
|
stderr |
str
|
|
stdout |
str
|
|
Source code in penvm/src/kernels/penvm/kernels/default/server.py
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 |
|
run(ctxt, req)
Run operation.
Source code in penvm/src/kernels/penvm/kernels/default/server.py
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 |
|
RunPython
Bases: Op
Run python code snippet with typed args and typed kwargs.
The code is executed in a thread of the machine
.
Danger
Running in the machine process can cause problems.
See penvm.kernels.default.server.RunExec.
Request:
Name | Type | Description |
---|---|---|
args |
typed list
|
Arguments. |
code |
str
|
Code snippet. |
globals |
typed dict
|
Dictionary of "globals" to use. Defaults to current "globals". |
kwargs |
typed dict
|
Keyword arguments. |
locals |
typed dict
|
Dictionary of "locals" to use. Defaults to empty dict. |
path-key |
str
|
Path of code snippet in file kvstore. See also
|
Response:
Name | Type | Description |
---|---|---|
return-value |
typed value
|
Taken from |
Source code in penvm/src/kernels/penvm/kernels/default/server.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 664 665 666 667 668 669 670 671 672 673 674 675 |
|
run(ctxt, req)
Run operation.
Source code in penvm/src/kernels/penvm/kernels/default/server.py
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 |
|
RunPythonFunction
Bases: Op
Run function from python code snippet with typed args and typed kwargs.
The code is executed in a thread of the machine
.
Danger
Running in the machine process can cause problems.
See penvm.kernels.default.server.RunExec.
Request:
Name | Type | Description |
---|---|---|
args |
typed list
|
Arguments. |
code |
str
|
Code snippet. |
code-key |
str
|
Code snippet in file kvstore. See also |
globals |
typed dict
|
Dictionary of "globals" to use. Defaults to current "globals" |
kwargs |
typed dict
|
Keyword arguments. |
locals |
typed dict
|
Dictionary of "locals" to use. Defaults to empty dict |
path-key |
str
|
Path of code snippet in file kvstore. See also
|
OkResponse:
Name | Type | Description |
---|---|---|
return-value |
typed
|
Return value from function call. |
Source code in penvm/src/kernels/penvm/kernels/default/server.py
678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 |
|
run(ctxt, req)
Run operation.
Source code in penvm/src/kernels/penvm/kernels/default/server.py
710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 |
|
StoreDrop
Bases: Op
Drop item from store.
Request:
Name | Type | Description |
---|---|---|
name |
Item name. |
TODO: should an reponse be sent?
Source code in penvm/src/kernels/penvm/kernels/default/server.py
780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 |
|
StoreGet
Bases: Op
Get item from store.
Request:
Name | Type | Description |
---|---|---|
name |
Item name. |
Response:
Name | Type | Description |
---|---|---|
data |
Data as text or binary. |
|
name |
Item name. |
Source code in penvm/src/kernels/penvm/kernels/default/server.py
799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 |
|
StoreGetState
Bases: Op
Get store state.
Request:
Name | Type | Description |
---|---|---|
|
Unused. |
OkResponse:
Name | Type | Description |
---|---|---|
|
Dictionary of state. |
Source code in penvm/src/kernels/penvm/kernels/default/server.py
839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 |
|
StoreList
Bases: Op
Get item from store.
Request:
Name | Type | Description |
---|---|---|
- |
Unused. |
Response:
Name | Type | Description |
---|---|---|
names |
Item name. |
Source code in penvm/src/kernels/penvm/kernels/default/server.py
864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 |
|
StorePop
Bases: Op
Get item from store and remove from store.
Request:
Name | Type | Description |
---|---|---|
name |
Item name. |
Response:
Name | Type | Description |
---|---|---|
data |
Data as text or binary. |
|
name |
Item name. |
Source code in penvm/src/kernels/penvm/kernels/default/server.py
891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 |
|
StorePut
Bases: Op
Put item into store.
Request:
Name | Type | Description |
---|---|---|
data |
Data as text or binary. |
|
name |
Item name. |
TODO: should an reponse be sent?
Source code in penvm/src/kernels/penvm/kernels/default/server.py
915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 |
|