euler-loading 2.3.0__tar.gz → 2.4.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {euler_loading-2.3.0 → euler_loading-2.4.0}/PKG-INFO +1 -1
- {euler_loading-2.3.0 → euler_loading-2.4.0}/euler_loading/dataset.py +82 -0
- {euler_loading-2.3.0 → euler_loading-2.4.0}/package-lock.json +1 -1
- {euler_loading-2.3.0 → euler_loading-2.4.0}/pyproject.toml +1 -1
- euler_loading-2.4.0/tests/test_id_schema.py +116 -0
- {euler_loading-2.3.0 → euler_loading-2.4.0}/.github/workflows/workflow.yml +0 -0
- {euler_loading-2.3.0 → euler_loading-2.4.0}/.gitignore +0 -0
- {euler_loading-2.3.0 → euler_loading-2.4.0}/README.md +0 -0
- {euler_loading-2.3.0 → euler_loading-2.4.0}/euler_loading/__init__.py +0 -0
- {euler_loading-2.3.0 → euler_loading-2.4.0}/euler_loading/_dataset_contract.py +0 -0
- {euler_loading-2.3.0 → euler_loading-2.4.0}/euler_loading/_ds_crawler_utils.py +0 -0
- {euler_loading-2.3.0 → euler_loading-2.4.0}/euler_loading/_metadata.py +0 -0
- {euler_loading-2.3.0 → euler_loading-2.4.0}/euler_loading/_resolution.py +0 -0
- {euler_loading-2.3.0 → euler_loading-2.4.0}/euler_loading/_writing.py +0 -0
- {euler_loading-2.3.0 → euler_loading-2.4.0}/euler_loading/indexing.py +0 -0
- {euler_loading-2.3.0 → euler_loading-2.4.0}/euler_loading/loaders/__init__.py +0 -0
- {euler_loading-2.3.0 → euler_loading-2.4.0}/euler_loading/loaders/_annotations.py +0 -0
- {euler_loading-2.3.0 → euler_loading-2.4.0}/euler_loading/loaders/_writer_utils.py +0 -0
- {euler_loading-2.3.0 → euler_loading-2.4.0}/euler_loading/loaders/contracts.py +0 -0
- {euler_loading-2.3.0 → euler_loading-2.4.0}/euler_loading/loaders/cpu/__init__.py +0 -0
- {euler_loading-2.3.0 → euler_loading-2.4.0}/euler_loading/loaders/cpu/generic.py +0 -0
- {euler_loading-2.3.0 → euler_loading-2.4.0}/euler_loading/loaders/cpu/generic_dense_depth.py +0 -0
- {euler_loading-2.3.0 → euler_loading-2.4.0}/euler_loading/loaders/cpu/real_drive_sim.py +0 -0
- {euler_loading-2.3.0 → euler_loading-2.4.0}/euler_loading/loaders/cpu/vkitti2.py +0 -0
- {euler_loading-2.3.0 → euler_loading-2.4.0}/euler_loading/loaders/generate/__init__.py +0 -0
- {euler_loading-2.3.0 → euler_loading-2.4.0}/euler_loading/loaders/generate/__main__.py +0 -0
- {euler_loading-2.3.0 → euler_loading-2.4.0}/euler_loading/loaders/generate/loaders.json +0 -0
- {euler_loading-2.3.0 → euler_loading-2.4.0}/euler_loading/loaders/generic.py +0 -0
- {euler_loading-2.3.0 → euler_loading-2.4.0}/euler_loading/loaders/gpu/__init__.py +0 -0
- {euler_loading-2.3.0 → euler_loading-2.4.0}/euler_loading/loaders/gpu/generic.py +0 -0
- {euler_loading-2.3.0 → euler_loading-2.4.0}/euler_loading/loaders/gpu/generic_dense_depth.py +0 -0
- {euler_loading-2.3.0 → euler_loading-2.4.0}/euler_loading/loaders/gpu/real_drive_sim.py +0 -0
- {euler_loading-2.3.0 → euler_loading-2.4.0}/euler_loading/loaders/gpu/vkitti2.py +0 -0
- {euler_loading-2.3.0 → euler_loading-2.4.0}/euler_loading/loaders/real_drive_sim.py +0 -0
- {euler_loading-2.3.0 → euler_loading-2.4.0}/euler_loading/loaders/vkitti2.py +0 -0
- {euler_loading-2.3.0 → euler_loading-2.4.0}/euler_loading/preprocessing.py +0 -0
- {euler_loading-2.3.0 → euler_loading-2.4.0}/example.py +0 -0
- {euler_loading-2.3.0 → euler_loading-2.4.0}/sample_rds.py +0 -0
- {euler_loading-2.3.0 → euler_loading-2.4.0}/tests/__init__.py +0 -0
- {euler_loading-2.3.0 → euler_loading-2.4.0}/tests/conftest.py +0 -0
- {euler_loading-2.3.0 → euler_loading-2.4.0}/tests/example_rds_calib.json +0 -0
- {euler_loading-2.3.0 → euler_loading-2.4.0}/tests/test_dataset.py +0 -0
- {euler_loading-2.3.0 → euler_loading-2.4.0}/tests/test_indexing.py +0 -0
- {euler_loading-2.3.0 → euler_loading-2.4.0}/tests/test_loaders.py +0 -0
- {euler_loading-2.3.0 → euler_loading-2.4.0}/tests/test_preprocessing.py +0 -0
- {euler_loading-2.3.0 → euler_loading-2.4.0}/tests/test_real_dataset.py +0 -0
- {euler_loading-2.3.0 → euler_loading-2.4.0}/tests/test_writing.py +0 -0
- {euler_loading-2.3.0 → euler_loading-2.4.0}/vkitti_cpu_example_output.json +0 -0
- {euler_loading-2.3.0 → euler_loading-2.4.0}/vkitti_gpu_example_output.json +0 -0
|
@@ -118,6 +118,36 @@ def _get_index_meta(index_output: Mapping[str, Any]) -> dict[str, Any] | None:
|
|
|
118
118
|
return None
|
|
119
119
|
|
|
120
120
|
|
|
121
|
+
def _extract_id_schema(index_output: Mapping[str, Any]) -> dict[str, Any]:
|
|
122
|
+
"""Pull id/hierarchy separators from a ds-crawler output payload.
|
|
123
|
+
|
|
124
|
+
Supports both modern (``indexing.id.join_char``) and legacy
|
|
125
|
+
(top-level ``id_regex_join_char``) layouts. Missing keys fall back to
|
|
126
|
+
ds-crawler defaults so the returned dict is always usable.
|
|
127
|
+
"""
|
|
128
|
+
indexing = index_output.get("indexing")
|
|
129
|
+
indexing_map = indexing if isinstance(indexing, Mapping) else {}
|
|
130
|
+
id_cfg = indexing_map.get("id")
|
|
131
|
+
id_map = id_cfg if isinstance(id_cfg, Mapping) else {}
|
|
132
|
+
hierarchy_cfg = indexing_map.get("hierarchy")
|
|
133
|
+
hierarchy_map = hierarchy_cfg if isinstance(hierarchy_cfg, Mapping) else {}
|
|
134
|
+
|
|
135
|
+
id_join_char = id_map.get("join_char") or index_output.get("id_regex_join_char") or "+"
|
|
136
|
+
hierarchy_separator = hierarchy_map.get("separator") or "-"
|
|
137
|
+
id_regex = id_map.get("regex") or index_output.get("id_regex")
|
|
138
|
+
hierarchy_regex = hierarchy_map.get("regex") or index_output.get("hierarchy_regex")
|
|
139
|
+
|
|
140
|
+
schema: dict[str, Any] = {
|
|
141
|
+
"hierarchy_separator": hierarchy_separator,
|
|
142
|
+
"id_join_char": id_join_char,
|
|
143
|
+
}
|
|
144
|
+
if id_regex:
|
|
145
|
+
schema["id_regex"] = id_regex
|
|
146
|
+
if hierarchy_regex:
|
|
147
|
+
schema["hierarchy_regex"] = hierarchy_regex
|
|
148
|
+
return schema
|
|
149
|
+
|
|
150
|
+
|
|
121
151
|
#TODO: might want to add slots=True in a 3.10+ only codebase
|
|
122
152
|
@dataclass(frozen=True)
|
|
123
153
|
class Modality:
|
|
@@ -488,6 +518,58 @@ class MultiModalDataset(_BaseDataset):
|
|
|
488
518
|
meta = _get_index_meta(index)
|
|
489
519
|
return meta or {}
|
|
490
520
|
|
|
521
|
+
def describe_id_schema(self) -> dict[str, Any]:
|
|
522
|
+
"""Return the id-construction schema used by this dataset.
|
|
523
|
+
|
|
524
|
+
Downstream consumers that want to split or match ``sample["full_id"]``
|
|
525
|
+
/ ``sample["id"]`` values back to ds-crawler fields need to know the
|
|
526
|
+
separators used to build them. This method exposes that schema so it
|
|
527
|
+
can be embedded in experiment manifests.
|
|
528
|
+
|
|
529
|
+
Schema keys:
|
|
530
|
+
- ``hierarchy_separator``: the character between the named
|
|
531
|
+
capture group *name* and its *value* within a single id part
|
|
532
|
+
(ds-crawler ``indexing.hierarchy.separator``, typically ``"-"``).
|
|
533
|
+
- ``id_join_char``: the character between id parts (ds-crawler
|
|
534
|
+
``indexing.id.join_char`` or legacy ``id_regex_join_char``,
|
|
535
|
+
default ``"+"``).
|
|
536
|
+
- ``full_id_separator``: the character between hierarchy levels
|
|
537
|
+
and the file id in ``sample["full_id"]`` (currently ``"/"``).
|
|
538
|
+
- ``id_regex`` / ``hierarchy_regex``: the raw regexes, when
|
|
539
|
+
recorded in the ds-crawler output.
|
|
540
|
+
- ``modalities``: per-modality overrides populated only when
|
|
541
|
+
modalities disagree on the above.
|
|
542
|
+
|
|
543
|
+
Example::
|
|
544
|
+
|
|
545
|
+
{
|
|
546
|
+
"hierarchy_separator": "-",
|
|
547
|
+
"id_join_char": "+",
|
|
548
|
+
"full_id_separator": "/",
|
|
549
|
+
"id_regex": "...",
|
|
550
|
+
}
|
|
551
|
+
"""
|
|
552
|
+
per_modality: dict[str, dict[str, Any]] = {}
|
|
553
|
+
for name, index in self._index_outputs.items():
|
|
554
|
+
per_modality[name] = _extract_id_schema(index)
|
|
555
|
+
|
|
556
|
+
if not per_modality:
|
|
557
|
+
return {}
|
|
558
|
+
|
|
559
|
+
base = dict(next(iter(per_modality.values())))
|
|
560
|
+
base["full_id_separator"] = "/"
|
|
561
|
+
|
|
562
|
+
overrides: dict[str, dict[str, Any]] = {}
|
|
563
|
+
for mod_name, mod_schema in per_modality.items():
|
|
564
|
+
mod_with_separator = dict(mod_schema)
|
|
565
|
+
mod_with_separator["full_id_separator"] = "/"
|
|
566
|
+
if mod_with_separator != base:
|
|
567
|
+
overrides[mod_name] = mod_with_separator
|
|
568
|
+
|
|
569
|
+
if overrides:
|
|
570
|
+
base["modalities"] = overrides
|
|
571
|
+
return base
|
|
572
|
+
|
|
491
573
|
def get_modality_index(self, modality_name: str) -> dict[str, Any]:
|
|
492
574
|
"""Return the cached ds-crawler index for a modality."""
|
|
493
575
|
if modality_name in self._modalities:
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
"""Tests for MultiModalDataset.describe_id_schema."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
from typing import Any
|
|
6
|
+
from unittest.mock import patch
|
|
7
|
+
|
|
8
|
+
from euler_loading import Modality, MultiModalDataset
|
|
9
|
+
|
|
10
|
+
from .conftest import dummy_loader
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
def _flat_index(
|
|
14
|
+
file_ids: list[str],
|
|
15
|
+
*,
|
|
16
|
+
indexing: dict[str, Any] | None = None,
|
|
17
|
+
legacy_join_char: str | None = None,
|
|
18
|
+
) -> dict[str, Any]:
|
|
19
|
+
index: dict[str, Any] = {
|
|
20
|
+
"name": "test-ds",
|
|
21
|
+
"type": "depth",
|
|
22
|
+
"euler_train": {"used_as": "input", "modality_type": "depth"},
|
|
23
|
+
"dataset": {
|
|
24
|
+
"files": [
|
|
25
|
+
{
|
|
26
|
+
"id": fid,
|
|
27
|
+
"path": f"scene/{fid}.png",
|
|
28
|
+
"path_properties": {},
|
|
29
|
+
"basename_properties": {},
|
|
30
|
+
}
|
|
31
|
+
for fid in file_ids
|
|
32
|
+
]
|
|
33
|
+
},
|
|
34
|
+
}
|
|
35
|
+
if indexing is not None:
|
|
36
|
+
index["indexing"] = indexing
|
|
37
|
+
if legacy_join_char is not None:
|
|
38
|
+
index["id_regex_join_char"] = legacy_join_char
|
|
39
|
+
return index
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
class TestDescribeIdSchema:
|
|
43
|
+
def test_modern_indexing_block(self):
|
|
44
|
+
index = _flat_index(
|
|
45
|
+
["f001"],
|
|
46
|
+
indexing={
|
|
47
|
+
"id": {"regex": "^(.+)$", "join_char": "+"},
|
|
48
|
+
"hierarchy": {"separator": "-"},
|
|
49
|
+
},
|
|
50
|
+
)
|
|
51
|
+
with patch(
|
|
52
|
+
"euler_loading.dataset.index_dataset_from_path",
|
|
53
|
+
return_value=index,
|
|
54
|
+
):
|
|
55
|
+
ds = MultiModalDataset(
|
|
56
|
+
modalities={"depth": Modality("/data/depth", loader=dummy_loader)}
|
|
57
|
+
)
|
|
58
|
+
schema = ds.describe_id_schema()
|
|
59
|
+
assert schema["hierarchy_separator"] == "-"
|
|
60
|
+
assert schema["id_join_char"] == "+"
|
|
61
|
+
assert schema["full_id_separator"] == "/"
|
|
62
|
+
assert schema["id_regex"] == "^(.+)$"
|
|
63
|
+
|
|
64
|
+
def test_legacy_top_level_join_char(self):
|
|
65
|
+
index = _flat_index(["f001"], legacy_join_char="|")
|
|
66
|
+
with patch(
|
|
67
|
+
"euler_loading.dataset.index_dataset_from_path",
|
|
68
|
+
return_value=index,
|
|
69
|
+
):
|
|
70
|
+
ds = MultiModalDataset(
|
|
71
|
+
modalities={"depth": Modality("/data/depth", loader=dummy_loader)}
|
|
72
|
+
)
|
|
73
|
+
schema = ds.describe_id_schema()
|
|
74
|
+
assert schema["id_join_char"] == "|"
|
|
75
|
+
assert schema["hierarchy_separator"] == "-"
|
|
76
|
+
|
|
77
|
+
def test_missing_indexing_falls_back_to_defaults(self):
|
|
78
|
+
index = _flat_index(["f001"])
|
|
79
|
+
with patch(
|
|
80
|
+
"euler_loading.dataset.index_dataset_from_path",
|
|
81
|
+
return_value=index,
|
|
82
|
+
):
|
|
83
|
+
ds = MultiModalDataset(
|
|
84
|
+
modalities={"depth": Modality("/data/depth", loader=dummy_loader)}
|
|
85
|
+
)
|
|
86
|
+
schema = ds.describe_id_schema()
|
|
87
|
+
assert schema["hierarchy_separator"] == "-"
|
|
88
|
+
assert schema["id_join_char"] == "+"
|
|
89
|
+
assert schema["full_id_separator"] == "/"
|
|
90
|
+
|
|
91
|
+
def test_divergent_modalities_record_overrides(self):
|
|
92
|
+
rgb_index = _flat_index(
|
|
93
|
+
["f001"],
|
|
94
|
+
indexing={"id": {"join_char": "+"}, "hierarchy": {"separator": "-"}},
|
|
95
|
+
)
|
|
96
|
+
depth_index = _flat_index(
|
|
97
|
+
["f001"],
|
|
98
|
+
indexing={"id": {"join_char": "|"}, "hierarchy": {"separator": "-"}},
|
|
99
|
+
)
|
|
100
|
+
|
|
101
|
+
def mock_index(path: str, **_: Any) -> dict[str, Any]:
|
|
102
|
+
return rgb_index if "rgb" in path else depth_index
|
|
103
|
+
|
|
104
|
+
with patch(
|
|
105
|
+
"euler_loading.dataset.index_dataset_from_path",
|
|
106
|
+
side_effect=mock_index,
|
|
107
|
+
):
|
|
108
|
+
ds = MultiModalDataset(
|
|
109
|
+
modalities={
|
|
110
|
+
"rgb": Modality("/data/rgb", loader=dummy_loader),
|
|
111
|
+
"depth": Modality("/data/depth", loader=dummy_loader),
|
|
112
|
+
}
|
|
113
|
+
)
|
|
114
|
+
schema = ds.describe_id_schema()
|
|
115
|
+
assert "modalities" in schema
|
|
116
|
+
assert schema["modalities"]["depth"]["id_join_char"] == "|"
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{euler_loading-2.3.0 → euler_loading-2.4.0}/euler_loading/loaders/cpu/generic_dense_depth.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{euler_loading-2.3.0 → euler_loading-2.4.0}/euler_loading/loaders/gpu/generic_dense_depth.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|