Skip to content

fix(lidar): accept .pkl when .pkl.gz absent#155

Open
Abhishek21g wants to merge 2 commits into
scaleapi:masterfrom
Abhishek21g:fix/lidar-pkl-extension
Open

fix(lidar): accept .pkl when .pkl.gz absent#155
Abhishek21g wants to merge 2 commits into
scaleapi:masterfrom
Abhishek21g:fix/lidar-pkl-extension

Conversation

@Abhishek21g

@Abhishek21g Abhishek21g commented Jul 13, 2026

Copy link
Copy Markdown

Problem

#140 — devkit expects *.pkl.gz lidar files but some dataset exports ship uncompressed *.pkl.

Fix

Lidar._load_data_structure prefers .pkl.gz, falls back to .pkl.

Verification

cd python && python -m unittest tests.test_lidar_extensions -v

Closes #140

Greptile Summary

This PR fixes issue #140 by overriding Lidar._load_data_structure so that the devkit accepts uncompressed .pkl files when no .pkl.gz files are present, while still preferring .pkl.gz when both formats exist.

  • sensors.py: Lidar._load_data_structure now globs for .pkl.gz first; if none are found it falls back to .pkl; a trailing else: super()._load_data_structure() is reached only when both globs return empty and is a no-op in practice.
  • test_lidar_extensions.py: Two new tests cover the .pkl fallback path and the .pkl.gz priority rule, addressing the gap noted in the previous review thread.

Confidence Score: 5/5

Safe to merge — the change is small, well-contained, and covered by two targeted tests.

The override is minimal and correct. The _load_data_file method already uses pd.read_pickle which transparently handles both compressed and uncompressed pickles, so no deserialization change was needed. Both the fallback and priority rule are exercised by the new tests.

No files require special attention.

Important Files Changed

Filename Overview
python/pandaset/sensors.py Adds _load_data_structure override in Lidar that prefers .pkl.gz and falls back to .pkl; the else super() branch is redundant but harmless.
python/tests/test_lidar_extensions.py New test file covering both the .pkl fallback and the .pkl.gz priority-over-.pkl case; both cases are well-structured and correct.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A["Lidar.__init__"] --> B["Sensor.__init__ -> _load_structure"]
    B --> C["_load_data_structure Override"]
    C --> D{"glob *.pkl.gz non-empty?"}
    D -- Yes --> E["_data_structure = gz list"]
    D -- No --> F{"glob *.pkl non-empty?"}
    F -- Yes --> G["_data_structure = plain list"]
    F -- No --> H["super call: _data_structure = []"]
    E --> I["lidar.load -> _load_data_file per entry"]
    G --> I
    H --> I
Loading
%%{init: {'theme': 'base', 'themeVariables': {"darkMode": true, "background": "#0d1117", "primaryColor": "#21262d", "primaryTextColor": "#e6edf3", "primaryBorderColor": "#8b949e", "lineColor": "#8b949e", "textColor": "#e6edf3", "edgeLabelBackground": "#161b22", "actorBkg": "#21262d", "actorBorder": "#8b949e", "actorTextColor": "#e6edf3", "actorLineColor": "#8b949e", "signalColor": "#8b949e", "signalTextColor": "#e6edf3", "noteBkgColor": "#373320", "noteBorderColor": "#d4a72c", "noteTextColor": "#f0e6c0", "labelBoxBkgColor": "#21262d", "labelBoxBorderColor": "#8b949e", "labelTextColor": "#e6edf3", "loopTextColor": "#e6edf3", "activationBkgColor": "#30363d", "activationBorderColor": "#8b949e"}}}%%
flowchart TD
    A["Lidar.__init__"] --> B["Sensor.__init__ -> _load_structure"]
    B --> C["_load_data_structure Override"]
    C --> D{"glob *.pkl.gz non-empty?"}
    D -- Yes --> E["_data_structure = gz list"]
    D -- No --> F{"glob *.pkl non-empty?"}
    F -- Yes --> G["_data_structure = plain list"]
    F -- No --> H["super call: _data_structure = []"]
    E --> I["lidar.load -> _load_data_file per entry"]
    G --> I
    H --> I
Loading

Reviews (2): Last reviewed commit: "test(lidar): assert .pkl.gz takes priori..." | Re-trigger Greptile

Some dataset exports ship uncompressed lidar pickles. Prefer .pkl.gz when
present, fall back to .pkl for compatibility.
Comment thread python/tests/test_lidar_extensions.py
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Lidar file ext wrong

1 participant