API Reference
Synchronous datasets
ProfiledDataset
apairo.core.profiled_dataset.ProfiledDataset
Bases: SynchronousDataset, ConfigurableDataset
Synchronous dataset driven by a YAML structural profile.
Subclasses declare a _profile class attribute pointing to a YAML file
(relative to apairo/dataset/profiles/ or an absolute path). The profile
describes the directory layout, file extensions, dtypes, and any type
transformations. All file discovery, loading, split filtering, and derived
key resolution are handled automatically.
Example
Minimal subclass::
class MyDataset(ProfiledDataset):
_profile = "my_dataset.yaml"
Usage::
ds = MyDataset("/data/my_dataset", keys=["lidar", "labels"], split="train")
sample = ds[0]
# sample.data["lidar"] -> np.ndarray
# sample.data["labels"] -> np.ndarray
Attributes:
| Name | Type | Description |
|---|---|---|
available_keys |
frozenset[str]
|
Frozenset of key names declared in the profile. Populated at class definition time from the YAML file. |
See Also
YAML Profiles <https://apairo-robotics.github.io/apairo/datasets/yaml-profiles/>_
for the full profile specification.
Source code in apairo/core/profiled_dataset.py
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 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 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 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 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 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 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 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 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 | |
frame_sequence_ids
cached
property
Sequence ID for every frame, indexed by global frame index.
Returns a string array of shape (len(self),) where
frame_sequence_ids[i] is the sequence ID that frame i belongs
to. Combined with :attr:FilteredView.indices, this lets you split a
pre-filtered dataset by sequence without a second disk sweep::
ds_filtered = ds.filter("trav_gt", HasMinPositives(min_pos))
seq_ids = ds.frame_sequence_ids[ds_filtered.indices]
for train_seqs, val_seqs in folds:
train_idx = np.where(np.isin(seq_ids, train_seqs))[0]
val_idx = np.where(np.isin(seq_ids, val_seqs))[0]
ds_train = ds_filtered.filter(train_idx)
ds_val = ds_filtered.filter(val_idx)
frame_stems
cached
property
Filename stem for every frame, indexed by global frame index.
sequences
property
One view per sequence, in sequence_ids order.
A property, as on the asynchronous family (RawDataset(root).sequences).
It was a method until 0.10.0: ds.sequences() still works and warns.
init
classmethod
init(directory: str | Path, *, merge: bool = False, overwrite: bool = False, name: str | None = None) -> Path
Write .apairo/channels.yaml from the dataset profile.
Maps the profile's canonical channel names onto the raw directories
present on disk (e.g. os1_cloud_node_kitti_bin -> lidar). One
config at directory covers every sequence the profile spans.
Preprocessed channels are not auto-registered: after init, inspect
:meth:unregistered_channels (the CLI prints them) and declare the ones
you want with :meth:register_channel.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
directory
|
str | Path
|
Dataset root directory. |
required |
merge
|
bool
|
Add profile channels to an existing config, leaving channels already declared untouched. |
False
|
overwrite
|
bool
|
Discard any existing |
False
|
name
|
str | None
|
Dataset name recorded in the root manifest
( |
None
|
Returns:
| Type | Description |
|---|---|
Path
|
Path of the written |
Path
|
|
Source code in apairo/core/profiled_dataset.py
unregistered_channels
classmethod
Directories that look like channels but are in neither the profile nor the current config -- candidate preprocessed channels.
Best-effort and report-only: returns {name: loader} for sub-directories
at the profile's modality depth that hold loadable files. Nothing is
registered; declare the ones you want with :meth:register_channel.
Source code in apairo/core/profiled_dataset.py
remove_channel
classmethod
Remove a channel, profile-aware (overrides
:meth:ConfigurableDataset.remove_channel).
A profiled dataset keeps a single channels.yaml at the root but stores
each channel's data per sequence (e.g. Rellis-3D/<seq>/<modality>),
so the generic root/key deletion would miss the sequence directories.
This drops the (root) declaration and, with data=True, deletes the
channel's storage in every sequence the profile spans.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
directory
|
str | Path
|
Dataset root directory. |
required |
key
|
str
|
Channel name to remove (the profile's canonical name). |
required |
data
|
bool
|
Also delete the channel's per-sequence data (destructive). |
False
|
Source code in apairo/core/profiled_dataset.py
inventory
classmethod
Structural self-description from a root path, without loading data.
The path-based form of :meth:describe: builds the profile geometry
(no file discovery, no loaders) and reports identity, sequences, channel
layout, splits and calibration. Tolerant -- it describes a partial
dataset without raising, unlike the constructor. See :meth:describe
for the returned schema.
Source code in apairo/core/profiled_dataset.py
describe
Describe this dataset's structure -- identity, sequences, channels.
Returns a structured dict (and prints a human-readable summary). Cross-
references the profile's declared modalities with what is on disk to show
which raw channels are present or missing and where each lives, plus any
registered preprocessed channels. Per-frame facts (counts, shapes) are
intentionally not here -- read them from the loaded dataset
(len(ds), ds[i].data[key].shape).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
sequence_id
|
str | None
|
Optional identifier used as the printed display label only. Channel availability is dataset-wide. |
None
|
Returns:
| Type | Description |
|---|---|
dict
|
``{"class", "name", "root", "layout": {"fixed": [...]}, |
dict
|
"sequences": [...], "splits": [...], "calibration": [...], |
dict
|
"raw": {"present": [...], "missing": [...], "channels": {key: {...}}}, |
dict
|
"preprocess": {key: meta}}`` |
Example::
ds = Rellis3DDataset("/data/RELLIS")
ds.describe("00000")
Source code in apairo/core/profiled_dataset.py
split
Return a new dataset instance filtered to the named split.
This re-instantiates the dataset, so it starts with a clean pipeline: any
registered transform() is intentionally NOT carried over. To split
mid-chain while keeping transforms, use :meth:filter_split instead.
Source code in apairo/core/profiled_dataset.py
filter_split
Return a FilteredView restricted to the named predefined split.
Applies the split without re-instantiating the dataset — registered
transforms are preserved. Replaces :meth:split for use mid-chain::
ds = ds.transform("lidar", RobotFilter())
ds_train = ds.filter_split("train") # transforms kept
Works for both LST-based splits (SemanticKITTI/Rellis) and directory-layer splits (GOOSE), so there is a transform-preserving split for every dataset.
Source code in apairo/core/profiled_dataset.py
SynchronousDataset
apairo.core.synchronous_dataset.SynchronousDataset
Bases: AbstractDataset
Base class for datasets where index i returns a complete synchronous frame.
All modalities at index i are co-captured -- one row is one sample across
every channel, no interleaving. That co-capture is what synchronous means;
it is independent of whether the frame carries a timestamp. Random access and
standard PyTorch DataLoader shuffling work without any additional wrappers.
A synchronous dataset may still expose a shared per-frame clock in
:attr:timestamps (one entry per global frame, so sample.timestamp is
that frame's tick); it defaults to None -- clockless -- and subclasses
populate it when the frames carry a timestamp.
Subclasses must implement __len__ and _load.
For new synchronous datasets, prefer extending
:class:~apairo.core.profiled_dataset.ProfiledDataset with a YAML profile
rather than subclassing this directly.
Attributes:
| Name | Type | Description |
|---|---|---|
synchronous |
Always |
|
timestamps |
dict | ndarray | None
|
The shared per-frame clock array, or |
Source code in apairo/core/synchronous_dataset.py
SemanticKittiDataset
apairo.dataset.semantic_kitti.SemanticKittiDataset
Bases: ProfiledDataset
SemanticKITTI dataset -- driving LiDAR with dense semantic labels.
Keys: lidar (float32, shape (N, 4)), labels (int64, lower 16 bits = semantic class).
Example::
ds = SemanticKittiDataset("/data/kitti/dataset", keys=["lidar", "labels"])
sample = ds[0]
# sample.data["lidar"] -> np.ndarray (N, 4)
# sample.data["labels"] -> np.ndarray (N,)
Source code in apairo/dataset/semantic_kitti/dataset.py
Goose3DDataset
apairo.dataset.goose.Goose3DDataset
Bases: ProfiledDataset
GOOSE 3D dataset -- outdoor off-road LiDAR with traversability labels.
Keys: lidar (float32, shape (N, 4)), labels (int64).
Split: "train", "val", or "test".
Example::
ds = Goose3DDataset("/data/GOOSE_3D", keys=["lidar", "labels"], split="train")
sample = ds[0]
# sample.data["lidar"] -> np.ndarray (N, 4)
# sample.data["labels"] -> np.ndarray (N,)
Source code in apairo/dataset/goose/dataset.py
Rellis3DDataset
apairo.dataset.rellis.Rellis3DDataset
Bases: ProfiledDataset
RELLIS-3D dataset -- off-road LiDAR with semantic labels.
Keys: lidar (float32, shape (N, 4)), labels (int64).
Optional: poses (float64, shape (3, 4)) -- one 3x4 pose matrix per frame,
loaded from a per-sequence poses.txt file (one row of 12 floats per frame).
Example::
ds = Rellis3DDataset("/data/RELLIS", keys=["lidar", "labels"])
sample = ds[0]
# sample.data["lidar"] -> np.ndarray (N, 4)
# sample.data["labels"] -> np.ndarray (N,)
ds = Rellis3DDataset("/data/RELLIS", keys=["lidar", "poses"])
# sample.data["poses"] -> np.ndarray (3, 4)
Source code in apairo/dataset/rellis/dataset.py
Asynchronous datasets
RawDataset
apairo.dataset.raw.RawDataset
Bases: RootSequenceMixin, AsyncLayoutDataset, ConfigurableDataset
Generic channels.yaml-driven dataset; single sequence or dataset root.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
directory
|
str | Path
|
A sequence directory or a dataset root directory --
auto-detected. A directory with no |
required |
keys
|
list[str] | None
|
Channels to load. |
None
|
declare
|
str | Path | None
|
Path to a declaration file overlaid onto the channel metadata
(per channel, per field) -- see
:class: |
None
|
Example::
ds = RawDataset(root, keys=["lidar", "imu"]) # whole dataset
ds.run_preprocess(MyLabeler()) # persisted as a new channel
Source code in apairo/dataset/raw/dataset.py
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 | |
init
classmethod
init(directory: str | Path, *, merge: bool = False, overwrite: bool = False, name: str | None = None, declare: str | Path | None = None) -> Path
Write the .apairo sidecar(s) by scanning directory. Root-aware.
A sequence directory (its sub-directories hold data files) gets a
.apairo/channels.yaml with loaders inferred per channel. A root
directory (its sub-directories are sequences) gets each sequence
initialised, then a .apairo/dataset.yaml manifest (name + sequence
order + channel union).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
directory
|
str | Path
|
Sequence or dataset-root directory (auto-detected). |
required |
merge
|
bool
|
Add newly detected channels without touching existing ones. |
False
|
overwrite
|
bool
|
Discard existing |
False
|
name
|
str | None
|
Dataset name for the root manifest (default: directory name). |
None
|
declare
|
str | Path | None
|
External declaration file the scan should respect (the
in-tree |
None
|
Returns:
| Type | Description |
|---|---|
Path
|
Path of the file written -- |
Path
|
|
Source code in apairo/dataset/raw/dataset.py
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 | |
TartanKittiDataset
apairo.dataset.tartan_kitti.TartanKittiDataset
Bases: RawDataset
TartanDrive v2 -- a :class:~apairo.dataset.raw.RawDataset whose channel
set is the fixed TartanDrive profile.
Loading, multi-sequence roots, synchronization and preprocessing are exactly
:class:RawDataset's; this class only pins the canonical TartanDrive
channels (profile.yaml). That means a raw sequence with no .apairo
bootstraps with the profile's loaders rather than ones merely guessed from
file extensions, and :meth:describe can flag profile channels missing on
disk.
Single sequence or root directory, auto-detected::
ds = TartanKittiDataset(seq_dir, keys=["velodyne_0", "cmd"])
ds = TartanKittiDataset(root_dir, keys=["velodyne_0"]) # all sequences
Source code in apairo/dataset/tartan_kitti/dataset.py
AsyncLayoutDataset
Abstract per-channel layout base for the asynchronous family. Internal base
class — subclass it to add a fixed-channel async dataset; end users load through
RawDataset or TartanKittiDataset.
apairo.dataset.async_layout.AsyncLayoutDataset
Bases: AbstractDataset
Abstract asynchronous layout loader (one subdirectory per channel).
This is the format primitive of the asynchronous dataset family. It is not
a concrete dataset -- the synchronous KITTI-style datasets are
:class:~apairo.core.profiled_dataset.ProfiledDataset subclasses (e.g.
:class:~apairo.dataset.semantic_kitti.SemanticKittiDataset).
It describes how channels are stored, never which channels exist: each
channel is a subdirectory with its own timestamps.txt and data files in
a registered format (npys, npy, bin, img, zarr, pcd,
csv, or a plugin's -- see :mod:apairo.core.formats). A channel may instead carry its alignment key in its filenames --
a key: {name: <regex>} / {file: <name>} spec parses it in memory at
read time (nothing written), with an optional order enumeration policy;
see docs/datasets/bring-your-own-dataset.md. The set of channels is
per-instance state, read from .apairo/channels.yaml (or an explicit
dataset_profile). Datasets
with a fixed channel set layer a profile on top (e.g.
:class:~apairo.dataset.tartan_kitti.TartanKittiDataset); datasets with
dynamic channels (e.g. apairo-extractor output) use
:class:~apairo.dataset.raw.RawDataset, which reads the channel set from
.apairo with no profile.
Usage with an explicit profile (original API)::
ds = AsyncLayoutDataset(seq_dir, keys=["lidar", "cam"], dataset_profile="my.yaml")
Usage with .apairo (after :meth:init has been called)::
AsyncLayoutDataset.init(seq_dir) # once, auto-detects channels
ds = AsyncLayoutDataset(seq_dir) # keys and loaders come from .apairo
ds = AsyncLayoutDataset(seq_dir, keys=["lidar"]) # restrict to a subset
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
directory
|
str | Path
|
Path to the dataset root / sequence directory. |
required |
keys
|
list[str] | None
|
Modality names to load. |
None
|
dataset_profile
|
str | Path | None
|
YAML profile filename or absolute Path mapping keys
to loader types. |
None
|
declare
|
str | Path | None
|
Path to a declaration file (the
|
None
|
declare_base
|
str | Path | None
|
Lower-precedence declaration overlaid before the
in-tree |
None
|
Source code in apairo/dataset/async_layout/dataset.py
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 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 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 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 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 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 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 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 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 | |
frame_sequence_ids
property
Sequence id per global event -- the sequence directory name (a single
async dataset is one sequence). Object array of shape (len(self),).
frame_channel_ids
property
Channel that produced each global event. Object array of shape
(len(self),), vectorized from the merged timeline.
frame_stems
property
Filename stem backing each global event: the per-frame data file's stem, or the zero-padded row for stacked (single-file) channels.
init
classmethod
init(directory: str | Path, *, raw_keys: list[str] | None = None, overwrite: bool = False, merge: bool = False, declare: str | Path | None = None) -> Path
Scan an async-layout directory and write .apairo/channels.yaml.
All detected subdirectories are registered as raw channels. Loader type is inferred from file extensions:
.bin→bin.pcd→pcd.png/.jpg/ … →img- multiple
.npyfiles →npys - single
.npyfile →npy - a
.csvtable →csv(one row per frame)
For ambiguous cases (e.g. a single-frame .npy that is actually
per-frame), call :func:~apairo.core.config.register_raw_channel
afterwards to override the detected loader.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
directory
|
str | Path
|
Dataset root / sequence directory to initialize. |
required |
raw_keys
|
list[str] | None
|
Subdirectory names to include. |
None
|
overwrite
|
bool
|
Discard the existing |
False
|
merge
|
bool
|
Add newly detected raw channels to an existing |
False
|
declare
|
str | Path | None
|
Path to an external declaration file the scan should
respect, in addition to the in-tree |
None
|
Returns:
| Type | Description |
|---|---|
Path
|
Path of the written |
Raises:
| Type | Description |
|---|---|
ValueError
|
If both |
FileExistsError
|
If |
ValueError
|
If no new recognizable channels are found. |
Source code in apairo/dataset/async_layout/dataset.py
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 | |
load_view
Reload view name, persisted with synchronize(...).persist(name):
the same frames, as a synchronous dataset, without recomputing the
matching or copying any data. Open the sequence as the view was made
(the same declaration); channels it needs are loaded if missing.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
The view's name. |
required |
interpolators
|
dict | None
|
The interpolator of each interpolated channel, by channel -- they are code, not state, so they are passed again. |
None
|
Raises:
| Type | Description |
|---|---|
KeyError
|
No view of that name in this sequence. |
ValueError
|
The view is stale -- a source channel's frames or clock changed since it was persisted -- or an interpolator is missing. |
Source code in apairo/dataset/async_layout/dataset.py
channel_format
The name of the format channel key is stored in (its loader),
or None when the channel is unknown.
frame_info
Channel + row each interleaved event came from. See
:meth:AbstractDataset.frame_info.
Source code in apairo/dataset/async_layout/dataset.py
StreamDataset
apairo.dataset.stream.StreamDataset
Bases: AbstractDataset
In-memory asynchronous dataset built from timestamped event streams.
The bridge between live or freshly-decoded data (ROS messages, queue
items, arrays in RAM) and the apairo API: give it one (timestamps,
items) pair per channel and it behaves exactly like a file-backed
asynchronous dataset -- merged timeline, single-event samples, and above
all :meth:~apairo.core.abstract_dataset.AbstractDataset.synchronize::
ds = StreamDataset({
"image": (img_ts, img_msgs), # any indexable items
"lidar": (lidar_ts, lidar_msgs),
"odom": (odom_ts, odom_msgs),
})
ds[0] # one event, timestamp-ordered
frames = ds.synchronize(reference=clock, method="previous")
Items are stored as given -- they can be numpy arrays, ROS messages, or any Python objects; apairo never copies or converts them.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
streams
|
dict[str, tuple[ndarray, Sequence]]
|
|
required |
Raises:
| Type | Description |
|---|---|
ValueError
|
On empty streams, length mismatch, or non-ascending timestamps. |
Source code in apairo/dataset/stream.py
frame_channel_ids
property
Channel that produced each global event. Object array of shape
(len(self),), vectorized from the merged timeline.
frame_info
Channel + per-channel row each interleaved event came from -- async, so it mirrors AsyncLayoutDataset rather than the synchronous default.
Source code in apairo/dataset/stream.py
SynchronizedView
apairo.core.synchronized_view.SynchronizedView
Bases: AbstractDataset
A synchronous view over an asynchronous dataset.
Created by :meth:~apairo.core.abstract_dataset.AbstractDataset.synchronize.
Index i returns a complete sample built around the i-th tick of the
reference clock: every channel contributes either an existing event
matched by timestamp, or a value synthesized at the tick by an
:class:~apairo.core.interpolator.Interpolator. The matching is a pure
index computation (one np.searchsorted per channel at construction
time) -- no data is read until access.
Because the view is synchronous (timestamps is None), the full
chaining API applies: .filter(), .select(), .cache(),
.join(), and map-style PyTorch DataLoader with shuffling.
.. note:: The view reads channel data directly from the parent's loaders -- transforms registered on the parent are not applied (they were written for single-event samples). Register transforms on the view::
ds_sync = ds.synchronize().transform("velodyne_0", RangeFilter(50))
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
parent
|
AbstractDataset
|
Asynchronous dataset exposing per-channel |
required |
reference
|
str | ndarray | None
|
The clock to resample onto. Three forms:
|
None
|
method
|
ChannelStrategy | dict[str, ChannelStrategy]
|
Strategy applied to every channel, or a dict mapping channel
names to per-channel strategies (unlisted channels default to
|
'previous'
|
tolerance
|
Tolerance
|
Maximum |
None
|
Example::
from apairo_transform.interp import Se3Interp
ds = TartanKittiDataset(seq, keys=["velodyne_0", "gicp_poses"])
ds_sync = ds.synchronize(
reference="velodyne_0",
method={"gicp_poses": Se3Interp()}, # velodyne_0 -> "previous"
tolerance={"gicp_poses": 0.15}, # velodyne_0: unconstrained
)
s = ds_sync[0]
s.data["gicp_poses"] # pose interpolated at s.timestamp
Source code in apairo/core/synchronized_view.py
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 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 | |
root_dir
property
Delegates to the parent's root_dir (or None if it has
none), so .calibration still resolves on a synchronized view --
without this, every synchronized view read an empty Calibration
regardless of what its parent exposed.
reference
property
Channel providing the clock, or None for an external clock.
reference_timestamps
property
Timestamp of each frame in the view (reference clock).
frame_indices
property
Per-channel event indices backing each frame.
Shape (n,) for matched channels (the event used), (n, 2) for
interpolated channels (the bracketing pair).
frame_sequence_ids
cached
property
Sequence id per synchronised frame, shape (n,).
A synchronised frame mixes events from several channels, so it only
carries a sequence id when the whole parent belongs to one sequence;
over a multi-sequence parent this raises AttributeError, keeping
the availability probe of the base class.
frame_channel_ids
property
Unavailable: a synchronised frame composites every channel (see
:meth:frame_info), so there is no single origin channel -- unlike
:attr:frame_sequence_ids, this raises unconditionally, even over a
single-sequence parent. Use :attr:frame_indices for real per-channel
provenance.
persist
Freeze this view in its sequence's .apairo under name: the
reference clock, one index array per channel, the method, the
tolerance, and a fingerprint of every source channel. No data is
copied. Reload it -- the same frames, without recomputing the matching
-- with RawDataset(seq).load_view(name); a source changed since is
refused, by name.
Raises:
| Type | Description |
|---|---|
FileExistsError
|
A view of that name exists and overwrite is not set. |
TypeError
|
The view was not synchronized directly on a sequence. |
Source code in apairo/core/synchronized_view.py
time_offsets
Signed t_event - t_ref per frame for key, in seconds.
Interpolated channels return zeros: their values are synthesized at the reference instant.
Source code in apairo/core/synchronized_view.py
frame_info
Provenance of synchronised frame idx.
A synchronised frame is composite: each channel is backed by its own
source event (see :attr:frame_indices), so there is no single origin
channel -- channel is None and row is the view index, not
an on-disk row (unlike a profiled dataset, where row addresses a file
on disk). sequence is filled when the parent belongs to a single
sequence (see :attr:frame_sequence_ids), None otherwise.
For real per-frame provenance use :attr:frame_indices;
frame_indices[self.reference][idx] is the reference-clock event this
tick was resampled onto.
Source code in apairo/core/synchronized_view.py
load
Channel key of frame idx, read alone: the event matched to the
frame's tick, or the value interpolated at it. Only that channel's
events are read -- the cheap way to look at one channel of a frame
(self[idx] reads every channel). Like load on any dataset, the
stored value: transforms registered on the view are not applied.
Raises:
| Type | Description |
|---|---|
KeyError
|
key is not one of the view's channels. |
IndexError
|
idx is out of range. |
Source code in apairo/core/synchronized_view.py
Interpolator
apairo.core.interpolator.Interpolator
Bases: ABC
Synthesize a channel value at the reference instant from its two bracketing events.
This is the value-level counterpart of the index-level matching
strategies ("previous", "next", "nearest"): instead of
picking an existing
event, an interpolator builds a new value at t_ref. Use it for
continuous signals -- poses, IMU, commands -- never for data that cannot
be blended (point clouds, images).
Contract, as orchestrated by
:class:~apairo.core.synchronized_view.SynchronizedView:
- a channel whose strategy is an
Interpolatorreceives, for each reference tickt, its two bracketing events(t0, v0)and(t1, v1)witht0 <= t <= t1andt0 < t1; - ticks not bracketed by two events (before the first event or after the last) are dropped from the view;
- exact matches (
t == t0) bypass the interpolator -- the stored value is returned directly, so implementations never seet0 == t1; - with
tolerance, both neighbours must lie within tolerance oft(max(t - t0, t1 - t) <= tolerance).
Concrete implementations (LinearInterp, Se3Interp, ...) live in
apairo_transform.interp.
Example::
class LinearInterp(Interpolator):
def __call__(self, t, t0, v0, t1, v1):
a = (t - t0) / (t1 - t0)
return (1.0 - a) * v0 + a * v1
Source code in apairo/core/interpolator.py
__call__
abstractmethod
Dataset composition
ConcatDataset
apairo.dataset.concat.ConcatDataset
Bases: AbstractDataset
Concatenates multiple dataset instances into one.
Takes the intersection of keys across all datasets so every index returns the same set of modalities regardless of which underlying dataset is hit. Indexing is O(log n) via binary search over cumulative lengths.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
datasets
|
list[AbstractDataset]
|
Non-empty list of dataset instances to concatenate. |
required |
Example::
sequences = [
SemanticKittiDataset(f"/data/kitti/seq_{i:02d}", keys=["lidar", "labels"])
for i in range(11)
]
combined = ConcatDataset(sequences)
sample = combined[0]
Raises:
| Type | Description |
|---|---|
ValueError
|
If |
Source code in apairo/dataset/concat.py
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 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 | |
timestamps
cached
property
The concatenated clock. Gated on the structural is_synchronous
protocol -- every view implements it, whereas the view wrappers do not
all define a bare .timestamps attribute. A synchronous child exposes a
shared per-frame ndarray clock (or None); an asynchronous child a
per-channel dict.
frame_sequence_ids
cached
property
Sequence id per global frame, concatenated from the children.
Ids are forwarded verbatim -- two children exposing the same id stay
indistinguishable. Raises AttributeError when any child exposes
none, so the availability probe keeps working.
frame_stems
cached
property
Filename stem per global frame, concatenated from the children.
frame_channel_ids
cached
property
Channel that produced each global frame, concatenated from the children.
frame_info
Provenance of frame idx, delegated to the dataset that owns it.
load
Channel key of frame idx, read alone by the dataset that owns
the frame (see :meth:AbstractDataset.load).
Source code in apairo/dataset/concat.py
split_sequences
apairo.dataset.split_sequences
split_sequences(datasets: list, ratios: tuple[float, float, float] = (0.8, 0.1, 0.1)) -> tuple[list, list, list]
Split datasets into train/val/test at the sequence level.
Splitting at sequence level avoids temporal leakage between splits.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
datasets
|
list
|
Ordered list (one entry per recording session). |
required |
ratios
|
tuple[float, float, float]
|
(train, val, test) fractions, must sum to 1.0. |
(0.8, 0.1, 0.1)
|
Source code in apairo/dataset/__init__.py
Extensibility
ConfigurableDataset
apairo.core.configurable_dataset.ConfigurableDataset
Mixin for datasets that support preprocessed-channel extensibility via .apairo.
Any dataset class that wants to be extensible at runtime (i.e. allow users to register new preprocessed channels without touching source code) should inherit from this mixin alongside its normal base class.
Concrete subclasses must implement :meth:_bootstrap_config, which describes
how to auto-discover the dataset's raw channels when .apairo does not yet
exist.
Usage pattern for preprocessing scripts::
MyDataset.register_channel(
seq_dir, "my_channel", "npys",
timestamps_from="lidar",
sources=["lidar"],
)
Usage in dataset __init__::
config = self._load_or_create_config(sequence_dir)
Source code in apairo/core/configurable_dataset.py
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 | |
run_preprocess
class-attribute
instance-attribute
Run a preprocessor and persist the output channel.
Can be called on the class or on an existing instance:
Class form -- root_dir required::
Goose3DDataset.run_preprocess(preprocessor, "/data/GOOSE_3D", split="train")
Instance form -- root_dir inferred from the dataset::
ds = Goose3DDataset("/data/GOOSE_3D", keys=["lidar"], split="train")
ds.run_preprocess(preprocessor)
Extra keyword arguments are forwarded to the dataset constructor. The
instance form reopens the dataset as the instance was opened -- the same
declare=, split=, sequences=... -- with the preprocessor's
input_keys as its keys; a keyword argument given to run_preprocess
replaces the instance's own.
overwrite=True recomputes even if the output already exists.
To preview a :class:~apairo.core.preprocessor.FramePreprocessor without
writing anything, run the same instance lazily first:
ds.transform(preprocessor).
register_channel
classmethod
register_channel(sequence_dir: str | Path, key: str, loader: str, *, timestamps_from: str | None = None, sources: list[str] | None = None, recipe: str | None = None) -> None
Register a preprocessed channel in sequence_dir/.apairo.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
sequence_dir
|
str | Path
|
Dataset sequence directory. |
required |
key
|
str
|
Channel name -- must match its subdirectory name. |
required |
loader
|
str
|
Data format: |
required |
timestamps_from
|
str | None
|
Channel whose timestamps to share when this channel
has no |
None
|
sources
|
list[str] | None
|
Provenance -- channels this channel was derived from. |
None
|
recipe
|
str | None
|
Content hash of the producing preprocessor's declared config
(set by |
None
|
Source code in apairo/core/configurable_dataset.py
remove_channel
classmethod
Remove a channel from sequence_dir/.apairo (inverse of
:meth:register_channel).
By default only the declaration is dropped, which is reversible; pass
data=True to also delete the channel's directory on disk. Returns the
removed metadata entry. For an interactive guard on raw channels and
data deletion, prefer the CLI (apairo channel remove).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
sequence_dir
|
str | Path
|
Dataset sequence directory. |
required |
key
|
str
|
Channel name to remove (its on-disk directory name). |
required |
data
|
bool
|
Also delete the channel's directory from disk (destructive). |
False
|
Source code in apairo/core/configurable_dataset.py
describe
classmethod
Describe what is available in a sequence directory.
Reads .apairo (creating it if absent) and cross-references it with
the class's :attr:available_keys to produce a three-way breakdown:
- raw / present -- raw channels on disk and registered
- raw / missing -- raw channels known from the profile but not on disk
- preprocess -- channels produced by a preprocessing pipeline
Returns the breakdown as a dict and prints a human-readable summary.
Example::
MyDataset.describe("/data/my_dataset/sequence_01")
Source code in apairo/core/configurable_dataset.py
register_raw_channel
classmethod
register_raw_channel(sequence_dir: str | Path, key: str, loader: str, *, alias: str | None = None, directory: str | None = None, suffix: str | None = None) -> None
Declare a raw channel in sequence_dir/.apairo.
Use this to manually add or override a raw channel declaration, for
example after :meth:init detected the wrong loader type.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
sequence_dir
|
str | Path
|
Dataset sequence directory. |
required |
key
|
str
|
Channel name -- must match its subdirectory name. |
required |
loader
|
str
|
Data format: |
required |
alias
|
str | None
|
Public name to expose the channel under at load time (the
directory keeps its real name). See
:func: |
None
|
directory
|
str | None
|
On-disk subdirectory this channel's files live in, when different from key (a suffixed sub-channel sharing another channel's directory). Defaults to key. |
None
|
suffix
|
str | None
|
Frame-file suffix to load from directory (e.g.
|
None
|
Source code in apairo/core/configurable_dataset.py
verify
classmethod
Verify that .apairo is coherent with what is on disk.
Prints any issues found and returns True when the config is clean.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
sequence_dir
|
str | Path
|
Dataset sequence directory containing |
required |
Returns:
| Type | Description |
|---|---|
bool
|
|
Example::
ok = MyDataset.verify("/data/my_dataset/seq_01")
Source code in apairo/core/configurable_dataset.py
RootSequenceMixin
Shared single-sequence vs. dataset-root handling for the asynchronous family
(flat indexing, per-sequence access, per-sequence synchronize + concat).
Reused by RawDataset and TartanKittiDataset.
apairo.core.root_sequence.RootSequenceMixin
Bases: AbstractDataset
Flat-indexed root over several same-typed sequence datasets.
Source code in apairo/core/root_sequence.py
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 | |
calibration
property
Static extrinsics from .apairo/calibration.yaml (e.g. written from
/tf_static). On a root, sequences' tables are merged -- each sequence
carries its own, so the calibration follows the data, not the root.
available
property
Channels available -- intersection across sequences for a root dataset.
sequence_ids
property
Sequence directory names, in load order (root datasets only).
frame_sequence_ids
property
Sequence id per global frame index (object array). On a root, the sub-sequence each frame belongs to; on a single sequence, delegated.
frame_stems
property
Filename stem per global frame index, concatenated over sequences.
frame_channel_ids
property
Channel that produced each global frame index, concatenated over sequences.
sequence
Return a :class:~apairo.core.sequence_view.SequenceView for seq_id.
Source code in apairo/core/root_sequence.py
synchronize
Resample onto a reference clock -- see :meth:AbstractDataset.synchronize.
On a root dataset each sequence is synchronized independently (clocks are not comparable across recordings) and the results concatenated, so an external clock array is only valid on a single sequence.
Source code in apairo/core/root_sequence.py
load_view
Reload view name of every sequence -- see
:meth:~apairo.dataset.async_layout.dataset.AsyncLayoutDataset.load_view
-- concatenated in sequence order, as synchronize returned them.
Source code in apairo/core/root_sequence.py
frame_info
Channel + row each event came from, plus the sub-sequence it belongs
to (root datasets). See :meth:AbstractDataset.frame_info.
Source code in apairo/core/root_sequence.py
register_channel
apairo.core.config.register_channel
register_channel(root_dir: str | Path, key: str, loader: str, *, timestamps_from: str | None = None, sources: list[str] | None = None, frame: str | None = None, recipe: str | None = None) -> None
Register a preprocessed channel in root_dir/.apairo/channels.yaml.
This is the low-level standalone function. Most users will prefer the
classmethod :meth:ConfigurableDataset.register_channel so that the call
site names the dataset type explicitly.
Existing channels (raw or preprocessed) are preserved -- only key is
updated.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
root_dir
|
str | Path
|
Dataset root directory. |
required |
key
|
str
|
Channel name -- must match its subdirectory name. |
required |
loader
|
str
|
Data format: |
required |
timestamps_from
|
str | None
|
Source channel whose timestamps this channel shares
(provenance only -- the channel always has its own |
None
|
sources
|
list[str] | None
|
Provenance -- raw channels this channel was derived from. |
None
|
frame
|
str | None
|
Coordinate frame the channel's data is expressed in (descriptive metadata only; apairo does not apply transforms). |
None
|
recipe
|
str | None
|
Content hash of the producing preprocessor's declared config, so
a later |
None
|
Source code in apairo/core/config.py
Format
The format contract: one storage format of a channel. A new format is a plugin -- see Write a Format Plugin.
apairo.core.formats.Format
How one storage format of a channel is read.
Subclass it, set the class attributes, override what differs from the
defaults, and register an instance -- through the apairo.formats entry
point group, or :func:register_format in process. The defaults describe
a per-frame format: one file per frame, recognized by its extension, read
by loader(directory) or loader(directory, files=...).
Attributes:
| Name | Type | Description |
|---|---|---|
name |
str
|
The loader name channels declare ( |
loader |
type[AbstractLoader]
|
The :class: |
extensions |
frozenset[str]
|
Lower-case data-file suffixes, with the dot ( |
per_frame |
bool
|
One file per frame. Only a per-frame format can take a
filename |
one_channel_per_file |
bool
|
Each matching file is a channel of its own (a table), rather than all of them forming one channel. |
suffixes |
bool
|
Frames may carry suffixed variants ( |
fields |
frozenset[str]
|
Optional channel fields the format reads ( |
key_forms |
frozenset[str]
|
Clock forms the data itself provides, beyond the core's
filename and sidecar forms -- |
priority |
int
|
Detection order, lowest first, when several formats could claim a directory. |
write_suffix |
str
|
The suffix of the frame files a per-frame format writes
( |
detectable |
bool
|
|
A format that can store a channel -- a preprocess output, a conversion --
implements :meth:write_frame (per-frame) or :meth:write_channel
(stacked), and :meth:can_write. Without them it is read-only. What it
writes, it must read back unchanged.
Source code in apairo/core/formats.py
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 | |
writes
property
Can this format store a channel? It does when it implements
:meth:write_frame (per-frame) or :meth:write_channel (stacked).
data_files
The files of directory this format reads, in frame order (by name;
numerically when every name is a plain integer) -- never a dotfile or
timestamps.txt.
Source code in apairo/core/formats.py
matches
detect
open
The loader for a channel stored in directory.
meta is the channel's entry (loader, array_file, fields,
key, ...). files are the frame filenames the dataset resolved -- a
key / order regex, a suffixed variant, a subclass provider --
or None for the format's own listing.
Source code in apairo/core/formats.py
clock
The clock for a key form in :attr:key_forms, one value per
frame. Only called for those forms.
Source code in apairo/core/formats.py
can_write
Can array -- one frame for a per-frame format, the whole channel
(N, ...) for a stacked one -- be stored so that it reads back
unchanged? Asked of the first output, before anything is written.
Source code in apairo/core/formats.py
write_frame
Store one frame at path, <channel dir>/<stem><write_suffix>.
write_channel
Store channel name whole in directory, row i being frame
i -- a file named after the channel, or the directory itself.
Source code in apairo/core/formats.py
facts
Frames, shape, dtype -- and the span of a clock form of its own --
for apairo status. By default, opened as loading opens it (files
as in :meth:open), read off the first frame, and the span taken from
:meth:clock. Override when that is not cheap. May raise: status
then shows the channel's facts as unknown.
Source code in apairo/core/formats.py
declare_hints
Extra lines apairo declare writes under the channel (indented
four spaces, commented unless confident). The filename key hint of
a per-frame format is the core's.
Source code in apairo/core/formats.py
validate
Issues with the format-specific fields meta holds, for check.
Check the fields that are there, never require one: check reads
channels.yaml and the declaration apart, and a declaration may give
a field the registry entry lacks. A field missing at load time is
:meth:open's to refuse, by name.
Source code in apairo/core/formats.py
register_format
apairo.core.formats.register_format
Register a format under its :attr:Format.name. A name already taken is
refused unless replace is set; a built-in format is never replaced.
Source code in apairo/core/formats.py
The format registry
format_names() lists every registered format (built-in and plugin) -- the
replacement for 0.8's KNOWN_LOADERS; formats() returns them in detection
order; get_format / find_format look one up by name; detect_format names
the format of a channel directory.
apairo.core.formats.format_names
apairo.core.formats.formats
apairo.core.formats.get_format
The registered format called name.
Source code in apairo/core/formats.py
Facts
What a format's facts() returns for apairo status.
apairo.core.formats.Facts
dataclass
What apairo status shows about a channel, read cheaply from disk.
Any field left None prints as unknown. span -- the first and last
timestamps -- is only set for a clock form the format itself provides (a
table's column), and is all status needs of that clock: with
frames, it gives the rate. Filename and sidecar keys, and
timestamps.txt, are read by the core.
Source code in apairo/core/formats.py
check_format
apairo.testing.check_format
Check fmt against the format contract on a sample channel stored in
directory (at least one frame). meta is the channel entry the sample
needs (array_file, fields, a key of the format's own form), the
loader field excepted.
Raises AssertionError listing every breach, so one run shows them all.
Source code in apairo/testing/__init__.py
check_dataset
apairo.testing.check_dataset
check_dataset(dataset: type[Any] | str, root: str | Path, *, keys: list[str] | None = None, declare: str | Path | None = None, expect: dict[str, dict] | None = None, paired: list[list[str]] | None = None, clock: bool | None = None, splits: list[str] | None = None, frames: int | None = None, round_trip: bool = True) -> None
Check a dataset on a sample of it, and list every breach.
Every dataset is checked on:
initand loading, asapairo init --as <Class>and the class do;- each channel's first, middle and last frames: arrays whose dtype, rank and trailing dimensions do not change;
- its clock: finite, one timestamp per frame, never going back within a sequence;
apairo check, which must report nothing;- with round_trip, a preprocess output written into it and read back unchanged, which exercises where its layout places derived channels.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
dataset
|
type[Any] | str
|
The dataset class, or its registered name. |
required |
root
|
str | Path
|
The sample: a dataset root or a sequence, as a user passes it. |
required |
keys
|
list[str] | None
|
Channels to load; |
None
|
declare
|
str | Path | None
|
A declaration (a file, or the name of a shipped one) the dataset is read through. |
None
|
expect
|
dict[str, dict] | None
|
Per channel, what its frames are: |
None
|
paired
|
list[list[str]] | None
|
Groups of channels with one row per element of the same frame (a cloud and its per-point labels). |
None
|
clock
|
bool | None
|
|
None
|
splits
|
list[str] | None
|
Splits that must load, each non-empty, none sharing a frame. |
None
|
frames
|
int | None
|
The number of frames the sample holds. |
None
|
round_trip
|
bool
|
Write a preprocess output and read it back. Turn it off on a full dataset, whose copy of a channel would be large. |
True
|
Raises:
| Type | Description |
|---|---|
AssertionError
|
listing every breach. |
Source code in apairo/testing/datasets.py
Standard datasets
The dataset classes apairo selects by name (apairo init --as), built-in or
installed through the apairo.datasets entry point group, and the
declarations that ship with it.
apairo.dataset.registry.register_dataset
Register a dataset class under its class name. A name already taken is refused unless replace is set; a built-in dataset is never replaced.
Source code in apairo/dataset/registry.py
apairo.dataset.registry.dataset_names
Every registered dataset class name: RawDataset first, then the
built-in ones, then the plugins'.
apairo.dataset.registry.declaration
The path of the shipped declaration called name, for declare=.
Source code in apairo/dataset/registry.py
apairo.dataset.registry.declaration_names
apairo.dataset.registry.get_dataset
The registered dataset class called name.
Source code in apairo/dataset/registry.py
SynchronizedSequences
What synchronize() returns on a root: one synchronized view per sequence,
concatenated; persist(name) keeps one view per sequence, and a root's
load_view(name) concatenates them back.
apairo.dataset.concat.SynchronizedSequences
Bases: ConcatDataset
The synchronized views of a root's sequences, one after the other --
what synchronize returns on a root. Each sequence keeps its own clock;
:meth:persist freezes each view in its own sequence.
Source code in apairo/dataset/concat.py
persist
Persist every sequence's view under name; the index files written.
Source code in apairo/dataset/concat.py
WRITERS
File writers used by dataset layouts (DatasetLayout export: Zarr stores, tar
archives of images). Preprocess outputs are written through the format
contract instead -- see Format.write_frame / write_channel -- so replacing
an entry here does not change what run_preprocess writes. WRITERS["img"]
writes a tar archive of JPEG frames, which the img format does not read; the
img format writes PNG frames.
from apairo import WRITERS
writer = WRITERS["npy"]()
writer.write(my_array, Path("/data/output/000000.npy"))
apairo.writer.WRITERS
module-attribute
WRITERS: dict[str, type] = {'npy': NPYWriter, 'npys': NPYWriter, 'bin': BINWriter, 'zarr': ZarrWriter, 'img': TarImageWriter}
DERIVED_LOADERS
File-level loaders for derived/preprocessed keys.
Keyed by loader name ("npy", "bin", "img").
Each entry is a Callable[[Path], np.ndarray].
apairo.loader.DERIVED_LOADERS
module-attribute
DERIVED_LOADERS: dict[str, Callable[[Path], ndarray]] = {'npy': lambda path: np.load(path), 'bin': lambda path: np.fromfile(path, dtype=np.float32), 'img': _load_img, 'pcd': lambda path: read_pcd(str(path))}
Inference
InferenceView
apairo.core.chain.InferenceView
Bases: AbstractDataset
The chain of a dataset as deployed: only what outputs need, without
training-only steps. Returned by :meth:AbstractDataset.inference.
A full dataset: index it, iterate it, hand it to a DataLoader. Its
samples hold the requested outputs only. :meth:on runs the same chain
on another source; :meth:save writes it beside a model checkpoint.
Source code in apairo/core/chain.py
820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 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 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 | |
on
Chain
apairo.core.chain.Chain
A pruned recipe, ready to run on its original data or another source.
Obtained from :attr:InferenceView.chain or :func:load_chain. Holds no
data: :meth:on runs it on a source.
Source code in apairo/core/chain.py
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 761 762 763 764 765 766 767 768 769 770 771 772 773 774 | |
reference
property
The channel whose clock the chain follows: the reference of its
synchronize closest to the source, or None without one (each
event of the source is then a frame).
lookback
property
How many earlier reference frames one output can read: the reach of
the chain's window operations ((size - 1) * stride each). A
stream executor keeps at least this many past frames.
channels_needed
The channels a new source must provide; None when unknown.
on
Run the chain on source instead of the data it was built on.
source must provide the channels the chain reads, under the same
names (see :meth:channels_needed). Every operation is called again
on it -- synchronize with the same reference and strategies,
window with the same reducer -- and the steps registered on the
original source are registered on source. Frame filters, caches and
repeats are dropped: they selected or repeated frames of the original
data.
Raises:
| Type | Description |
|---|---|
ValueError
|
If the chain has several sources ( |
Source code in apairo/core/chain.py
save
Write the chain as a JSON declaration (see :mod:apairo.core.chain_io).
Summary
apairo.core.chain.Summary
dataclass
What :meth:AbstractDataset.inference kept, removed and flags.
print(view.summary) lists every step; summary.removed and
summary.flags give the entries to check before deploying.
Source code in apairo/core/chain.py
load_chain
apairo.core.chain.load_chain
Read a chain written by :meth:Chain.save -- see :mod:apairo.core.chain_io.
Source code in apairo/core/chain.py
step_io
apairo.core.chain.step_io
The channels a pipeline step reads and writes; None when unknown.
transform(key, fn, output=...)reads key and writes output (or key): known from the call itself.transform(preprocessor)reads the preprocessor'sinput_keysand writes its outputs.transform(fn)on a whole sample is opaque unless fn declaresinput_keysandoutput_keys(attributes or properties). AComposeof declared callables is declared.
Source code in apairo/core/chain.py
Preprocessing
FramePreprocessor
apairo.core.preprocessor.FramePreprocessor
Bases: Preprocessor
Preprocessor that operates frame-by-frame.
The runner calls the instance once per input frame. Use this for per-scan operations (label inference, feature extraction, …).
Output is stored as one file per frame (000000.npy, 000001.npy,
…) when output_loader is "npys" or "bin".
Because a frame preprocessor is just a Sample -> value callable, it
can also run lazily -- ds.transform(preprocessor) publishes its
result under output_key at access time, nothing is written. Preview
a preprocess this way before materializing it with run_preprocess.
Example::
class TravLabel(FramePreprocessor):
output_key = "trav_label"
output_loader = "npys"
input_keys = ["velodyne_0"]
timestamps_from = "velodyne_0" # no own timestamps.txt
def __call__(self, sample: Sample) -> np.ndarray:
pts = sample.data["velodyne_0"]
return my_model(pts)
Source code in apairo/core/preprocessor.py
__call__
abstractmethod
Process one frame.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
sample
|
Sample
|
A :class: |
required |
Returns:
| Type | Description |
|---|---|
Any
|
A |
Source code in apairo/core/preprocessor.py
SequencePreprocessor
apairo.core.preprocessor.SequencePreprocessor
Bases: Preprocessor
Preprocessor that operates on the full sequence at once.
The runner calls the instance with an iterator over all input frames.
Use this for algorithms that need global context (ICP, trajectory
smoothing, …). Global context is also why a sequence preprocessor
cannot run lazily: it must be materialized via run_preprocess.
Output is stored as a single {output_key}.npy file when
output_loader is "npy".
Example::
class GICPPoses(SequencePreprocessor):
output_key = "gicp_poses"
output_loader = "npy"
input_keys = ["velodyne_0"]
sources = ["velodyne_0"] # has its own timestamps.txt
def __call__(self, frames: Iterator[Sample]) -> np.ndarray:
poses = []
for sample in frames:
pts = sample.data["velodyne_0"]
poses.append(register(pts))
return np.stack(poses) # (N, 4, 4)
Source code in apairo/core/preprocessor.py
__call__
abstractmethod
Process all frames.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
frames
|
Iterator[Sample]
|
Iterator of :class: |
required |
Returns:
| Type | Description |
|---|---|
Any
|
A |
Source code in apairo/core/preprocessor.py
Convert
apairo.preprocess.convert.Convert
Bases: FramePreprocessor
Copy channel channel into the format to, as channel output_key
(<channel>_<to> by default). Any registered format that writes is a
target, a plugin's included; the runner refuses one that cannot hold the
frames, by name.
Source code in apairo/preprocess/convert.py
Data structures
Sample
apairo.core.sample.Sample
dataclass
A single dataset sample -- one timeline event or one complete frame.
timestamp follows the frame's clock, not merely whether the data is
synchronous:
- Asynchronous event --
datahas one key;timestampis that event's. - Synchronous clocked frame (a
synchronize()result) --datahas all requested keys;timestampis the reference-clock tick the frame was resampled onto. - Synchronous clockless frame (a profiled dataset) --
datahas all keys;timestampisNone.
sample[key] is sample.data[key], and key in sample tests
sample.data. Only channels are subscriptable: channel names are free,
so sample["timestamp"] is a channel named timestamp, never the
sample's time.
Source code in apairo/core/sample.py
FrameRef
Returned by AbstractDataset.frame_info(idx) -- where a global frame index comes
from (sequence, channel, row).
apairo.core.abstract_dataset.FrameRef
Bases: NamedTuple
Where a global frame index comes from -- for layout-aware tooling.
Returned by :meth:AbstractDataset.frame_info. Lets a visualizer or splitter
map a flat index back to its origin without reaching into private timeline
state.
Attributes:
| Name | Type | Description |
|---|---|---|
sequence |
str | None
|
Sub-sequence the frame belongs to ( |
channel |
str | None
|
Channel that produced the event -- asynchronous datasets
interleave channels, so one event is one channel. |
row |
int
|
Frame index within that channel/sequence. |