API Reference¶
Node¶
pyodx.api.Node
¶
A client to interact with NodeODX API.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
host
|
str
|
Hostname or IP address of processing node |
required |
port
|
int
|
Port of processing node |
required |
token
|
str
|
Token to use for authentication |
''
|
timeout
|
int
|
Timeout value in seconds for network requests |
30
|
Source code in pyodx/api.py
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 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 | |
__init__(host, port, token='', timeout=30)
¶
from_url(url, timeout=30)
staticmethod
¶
Create a Node instance from a URL.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
url
|
str
|
URL in the format proto://hostname:port/?token=value |
required |
timeout
|
int
|
Timeout value in seconds for network requests |
30
|
Returns:
| Name | Type | Description |
|---|---|---|
Node |
Node
|
Node instance |
Examples:
Source code in pyodx/api.py
info()
¶
Retrieve information about this node.
Returns:
| Name | Type | Description |
|---|---|---|
NodeInfo |
NodeInfo
|
Node information |
Examples:
Source code in pyodx/api.py
options()
¶
Retrieve the options available for creating new tasks on this node.
Returns:
| Name | Type | Description |
|---|---|---|
Options |
list[NodeOption]
|
Available options |
Examples:
Source code in pyodx/api.py
version_greater_or_equal_than(version)
¶
Checks whether this node version is greater than or equal than a certain version number.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
version
|
str
|
Version number to compare |
required |
Returns:
| Name | Type | Description |
|---|---|---|
result |
bool
|
True if node's version if >= version |
Examples:
>>> n = Node('localhost', 3000)
>>> n.version_greater_or_equal_than('1.3.1')
True
>>> n.version_greater_or_equal_than('10.5.1')
False
Source code in pyodx/api.py
create_task(files, options={}, name=None, progress_callback=None, skip_post_processing=False, webhook=None, outputs=[], parallel_uploads=10, max_retries=5, retry_timeout=5, task_uuid=None)
¶
Start processing a new task. At a minimum you need to pass a list of image paths. All other parameters are optional.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
files
|
list
|
List of image paths + optional GCP file path. |
required |
options
|
dict
|
Options to use, for example {'orthophoto-resolution': 3, ...} |
{}
|
name
|
str
|
Name for the task |
None
|
progress_callback
|
function
|
Callback reporting upload progress percentage |
None
|
skip_post_processing
|
bool
|
When true, skips generation of map tiles, derivate assets, point cloud tiles. |
False
|
webhook
|
str
|
Optional URL to call when processing has ended (either successfully or unsuccessfully). |
None
|
outputs
|
list
|
Optional paths relative to the project directory that should be included in the all.zip result file, overriding the default behavior. |
[]
|
parallel_uploads
|
int
|
Number of parallel uploads. |
10
|
max_retries
|
int
|
Number of attempts to make before giving up on a file upload. |
5
|
retry_timeout
|
int
|
Wait at least these many seconds before attempting to upload a file a second time, multiplied by the retry number. |
5
|
task_uuid
|
str
|
An optional UUID string that will be used as UUID for this task instead of generating a random one. |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
Task |
Task
|
The created task |
Examples:
>>> n = Node('localhost', 3000)
>>> t = n.create_task(['examples/images/image_1.jpg', 'examples/images/image_2.jpg'],
... {'orthophoto-resolution': 2, 'dsm': True})
>>> info = t.info()
>>> info.status
<TaskStatus.RUNNING: 20>
>>> info.last_error
''
>>> t.info().images_count
2
>>> t.output()[0:2]
['DJI_0131.JPG - DJI_0313.JPG has 1 candidate matches', 'DJI_0131.JPG - DJI_0177.JPG has 3 candidate matches']
Source code in pyodx/api.py
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 | |
get_task(uuid)
¶
Helper method to initialize a task from an existing UUID
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
uuid
|
str
|
Unique identifier of the task |
required |
Returns:
| Name | Type | Description |
|---|---|---|
Task |
Task
|
The task instance |
Examples:
>>> n = Node("localhost", 3000)
>>> t = n.get_task('00000000-0000-0000-0000-000000000000')
>>> t.__class__
<class 'pyodx.api.Task'>
Source code in pyodx/api.py
url(url, query={})
¶
Get a URL relative to this node.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
url
|
str
|
Relative URL |
required |
query
|
dict
|
Query values to append to the URL |
{}
|
Returns:
| Name | Type | Description |
|---|---|---|
URL |
str
|
Absolute URL |
Source code in pyodx/api.py
Task¶
pyodx.api.Task
¶
A task is created to process images. To create a task, use Node.create_task.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
node
|
Node
|
Node this task belongs to |
required |
uuid
|
str
|
Unique identifier assigned to this task. |
required |
Source code in pyodx/api.py
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 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 | |
info(with_output=None)
¶
Retrieves information about this task.
Returns:
| Name | Type | Description |
|---|---|---|
TaskInfo |
TaskInfo
|
Task information |
Source code in pyodx/api.py
output(line=0)
¶
Retrieve console task output.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
line
|
int
|
Optional line number that the console output should be truncated from. For example, passing a value of 100 will retrieve the console output starting from line 100. Negative numbers are also allowed. For example -50 will retrieve the last 50 lines of console output. Defaults to 0 (retrieve all console output). |
0
|
Returns:
| Name | Type | Description |
|---|---|---|
output |
list[str]
|
Console output (one list item per row). |
Source code in pyodx/api.py
cancel()
¶
Cancel this task.
Returns:
| Name | Type | Description |
|---|---|---|
success |
bool
|
Task was canceled or not |
remove()
¶
Remove this task.
Returns:
| Name | Type | Description |
|---|---|---|
success |
bool
|
Task was removed or not |
restart(options=None)
¶
Restart this task.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
options
|
dict
|
Options to use, for example {'orthophoto-resolution': 3, ...} |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
success |
bool
|
Task was restarted or not |
Source code in pyodx/api.py
download_zip(destination, progress_callback=None, parallel_downloads=16, parallel_chunks_size=10)
¶
Download this task's assets archive to a directory.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
destination
|
str
|
Directory where to download assets archive. If the directory does not exist, it will be created. |
required |
progress_callback
|
function
|
Optional callback with one parameter, the download progress percentage. |
None
|
parallel_downloads
|
int
|
Maximum number of parallel downloads if the node supports http range. |
16
|
parallel_chunks_size
|
int
|
Size in MB of chunks for parallel downloads |
10
|
Returns: Path (str): Path to archive file (.zip)
Source code in pyodx/api.py
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 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 | |
download_assets(destination, progress_callback=None, parallel_downloads=16, parallel_chunks_size=10)
¶
Download this task's assets to a directory.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
destination
|
str
|
Directory where to download assets. If the directory does not exist, it will be created. |
required |
progress_callback
|
function
|
Optional callback with one parameter, the download progress percentage |
None
|
parallel_downloads
|
int
|
Maximum number of parallel downloads if the node supports http range. |
16
|
parallel_chunks_size
|
int
|
Size in MB of chunks for parallel downloads |
10
|
Returns: Path (str): Path to saved assets
Source code in pyodx/api.py
wait_for_completion(status_callback=None, interval=3, max_retries=5, retry_timeout=5)
¶
Wait for the task to complete. The call will block until the task status has become
TaskStatus.COMPLETED. If the status is set to TaskStatus.CANCELED or TaskStatus.FAILED
it raises a TaskFailedError exception.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
status_callback
|
function
|
Optional callback that will be called with task info updates every interval seconds. |
None
|
interval
|
int
|
Seconds between status checks. |
3
|
max_retries
|
int
|
Number of repeated attempts that should be made to receive a status update before giving up. |
5
|
retry_timeout
|
int
|
Wait N*retry_timeout between attempts, where N is the attempt number. |
5
|
Source code in pyodx/api.py
Types¶
pyodx.types.NodeInfo
¶
Bases: JsonResponse
Information about a node
Attributes:
| Name | Type | Description |
|---|---|---|
version |
str
|
Current API version |
task_queue_count |
int
|
Number of tasks currently being processed or waiting to be processed |
total_memory |
int
|
Amount of total RAM in the system in bytes |
available_memory |
int
|
Amount of RAM available in bytes |
cpu_cores |
int
|
Number of virtual CPU cores |
max_images |
int
|
Maximum number of images allowed for new tasks or None if there's no limit. |
max_parallel_tasks |
int
|
Maximum number of tasks that can be processed simultaneously |
odm_version |
str
|
Current version of ODM (deprecated, use engine_version instead) |
engine |
str
|
Lowercase identifier of the engine (odm, micmac, ...) |
engine_version |
str
|
Current engine version |
Source code in pyodx/types.py
pyodx.types.NodeOption
¶
Bases: JsonResponse
A node option available to be passed to a node.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
domain
|
str
|
Valid range of values |
required |
help
|
str
|
Description of what this option does |
required |
name
|
str
|
Option name |
required |
value
|
str
|
Default value for this option |
required |
type
|
str
|
One of: ['int', 'float', 'string', 'bool', 'enum'] |
required |
Source code in pyodx/types.py
pyodx.types.TaskInfo
¶
Bases: JsonResponse
Task information
Attributes:
| Name | Type | Description |
|---|---|---|
uuid |
str
|
Unique identifier |
name |
str
|
Human friendly name |
date_created |
datetime
|
Creation date and time |
processing_time |
int
|
Milliseconds that have elapsed since the start of processing, or -1 if no information is available. |
status |
TaskStatus
|
Status (running, queued, etc.) |
last_error |
str
|
If the task fails, this will be set to a string representing the last error that occured, otherwise it's an empty string. |
options |
dict
|
Options used for this task |
images_count |
int
|
Number of images (+ GCP file) |
progress |
float
|
Percentage progress (estimated) of the task |
output |
list[str]
|
Optional console output (one list item per row). This is populated only if the with_output parameter is passed to info(). |
Source code in pyodx/types.py
pyodx.types.TaskStatus
¶
Bases: Enum
Task status
Attributes:
| Name | Type | Description |
|---|---|---|
QUEUED |
Task's files have been uploaded and are waiting to be processed. |
|
RUNNING |
Task is currently being processed. |
|
FAILED |
Task has failed for some reason (not enough images, out of memory, etc. |
|
COMPLETED |
Task has completed. Assets are be ready to be downloaded. |
|
CANCELED |
Task was manually canceled by the user. |
Source code in pyodx/types.py
Exceptions¶
pyodx.exceptions.GenericError
¶
pyodx.exceptions.NodeServerError
¶
Bases: GenericError
The server replied in a manner which we did not expect. Usually this indicates a temporary malfunction of the node.
pyodx.exceptions.NodeConnectionError
¶
Bases: GenericError
A connection problem (such as a timeout or a network error) has occurred.
pyodx.exceptions.NodeResponseError
¶
Bases: GenericError
The node responded with an error message indicating that the requested operation failed.
pyodx.exceptions.TaskFailedError
¶
Bases: GenericError
A task did not complete successfully.
pyodx.exceptions.RangeNotAvailableError
¶
Bases: GenericError
A download attempt to use Range requests failed.