rslearn.dataset.manage¶
manage ¶
Functions to manage datasets.
AttemptsCounter ¶
A simple counter for tracking attempts (including initial attempt and retries).
Source code in rslearn/dataset/manage.py
retry ¶
retry(fn: Callable, retry_max_attempts: int, retry_backoff: timedelta, attempts_counter: AttemptsCounter | None = None) -> Any
Retry the function multiple times in case of error.
The function is retried until either the attempts are exhausted, or the function runs successfully without raising an Exception.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
fn
|
Callable
|
the function to call. |
required |
retry_max_attempts
|
int
|
retry this many times (plus the original attempt) before giving up (and raising Exception). |
required |
retry_backoff
|
timedelta
|
the base backoff time used to compute how long to wait between retries. The actual time is (retry_backoff * attempts) * r, where r is a random number between 1 and 2, and attempts is the number of attempts tried so far. |
required |
attempts_counter
|
AttemptsCounter | None
|
an optional counter to increment for each attempt |
None
|
Source code in rslearn/dataset/manage.py
prepare_dataset_windows ¶
prepare_dataset_windows(dataset: Dataset, windows: list[Window], force: bool = False, ignore_errors: bool = False, retry_max_attempts: int = 0, retry_backoff: timedelta = timedelta(minutes=1)) -> PrepareDatasetWindowsSummary
Prepare windows in a dataset.
Preparing a window involves looking up items corresponding to the window in each of the retrieved layers specified in the dataset.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
dataset
|
Dataset
|
the dataset |
required |
windows
|
list[Window]
|
the windows to prepare |
required |
force
|
bool
|
whether to prepare windows even if they were previously prepared (default false) |
False
|
ignore_errors
|
bool
|
if True, catch errors and continue to next layer instead of raising. Errors are tracked in the returned summary. |
False
|
retry_max_attempts
|
int
|
set greater than zero to retry for this many attempts in case of error. |
0
|
retry_backoff
|
timedelta
|
how long to wait before retrying (see retry). |
timedelta(minutes=1)
|
Returns:
| Type | Description |
|---|---|
PrepareDatasetWindowsSummary
|
a summary of the prepare operation, fit for telemetry purposes |
Source code in rslearn/dataset/manage.py
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 | |
ingest_dataset_windows ¶
ingest_dataset_windows(dataset: Dataset, windows: list[Window], retry_max_attempts: int = 0, retry_backoff: timedelta = timedelta(minutes=1)) -> None
Ingest items for retrieved layers in a dataset.
The items associated with the specified windows are downloaded and divided into tiles which are then added to the dataset's tile store.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
dataset
|
Dataset
|
the dataset |
required |
windows
|
list[Window]
|
the windows to ingest |
required |
retry_max_attempts
|
int
|
set greater than zero to retry for this many attempts in case of error. |
0
|
retry_backoff
|
timedelta
|
how long to wait before retrying (see retry). |
timedelta(minutes=1)
|
Source code in rslearn/dataset/manage.py
is_window_ingested ¶
Check if a window is ingested.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
dataset
|
Dataset
|
the dataset |
required |
window
|
Window
|
the window |
required |
check_layer_name
|
str | None
|
optional layer name to only check that layer is ingested |
None
|
Returns:
| Type | Description |
|---|---|
bool
|
true if the window is ingested, false otherwise |
Source code in rslearn/dataset/manage.py
materialize_window ¶
materialize_window(window: Window, dataset: Dataset, data_source: DataSource, tile_store: TileStore, layer_name: str, layer_cfg: LayerConfig, retry_max_attempts: int = 0, retry_backoff: timedelta = timedelta(minutes=1)) -> MaterializeWindowLayerSummary
Materialize a window.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
window
|
Window
|
the window |
required |
dataset
|
Dataset
|
the dataset |
required |
data_source
|
DataSource
|
the DataSource |
required |
tile_store
|
TileStore
|
tile store of the dataset to materialize from |
required |
layer_name
|
str
|
the layer name |
required |
layer_cfg
|
LayerConfig
|
the layer config |
required |
retry_max_attempts
|
int
|
set greater than zero to retry for this many attempts in case of error. |
0
|
retry_backoff
|
timedelta
|
how long to wait before retrying (see retry). |
timedelta(minutes=1)
|
Returns:
| Type | Description |
|---|---|
MaterializeWindowLayerSummary
|
a summary of the materialize operation, fit for telemetry purposes |
Source code in rslearn/dataset/manage.py
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 | |
materialize_dataset_windows ¶
materialize_dataset_windows(dataset: Dataset, windows: list[Window], ignore_errors: bool = False, retry_max_attempts: int = 0, retry_backoff: timedelta = timedelta(minutes=1)) -> MaterializeDatasetWindowsSummary
Materialize items for retrieved layers in a dataset.
The portions of items corresponding to dataset windows are extracted from the tile store and written to the window directory.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
dataset
|
Dataset
|
the dataset |
required |
windows
|
list[Window]
|
the windows to materialize |
required |
ignore_errors
|
bool
|
if True, catch errors per-window and continue. Errors are tracked in the returned summary. |
False
|
retry_max_attempts
|
int
|
set greater than zero to retry for this many attempts in case of error. |
0
|
retry_backoff
|
timedelta
|
how long to wait before retrying (see retry). |
timedelta(minutes=1)
|
Returns:
| Type | Description |
|---|---|
MaterializeDatasetWindowsSummary
|
a summary of the materialize operation, fit for telemetry purposes |
Source code in rslearn/dataset/manage.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 | |