Allow for empty data set - #9
Merged
Merged
Conversation
There was a problem hiding this comment.
Pull request overview
This PR improves resilience of the Python client when the API returns an empty/absent dataset for a given viewBy (e.g., time missing/empty when viewBy=rollup), preventing frame-construction errors and tightening request error handling.
Changes:
- Allow
lk_layout_data_to_frame_v2to build an empty DataFrame when thedatakey is missing (instead of raising aKeyError). - Simplify
payload_to_frameto avoid indexing into potentially-empty payloads and consistently delegate tolk_api_data_to_frames. - Improve
make_api_requesttoken-expiry handling robustness and ensure HTTP errors are surfaced viaraise_for_status().
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| if data_type == 'time': | ||
| data_headers[0] = 'Date' | ||
| data_frame = pd.DataFrame([r for r in data['data']], columns=data_headers) | ||
| data_frame = pd.DataFrame([r for r in data.get('data', [])], columns=data_headers) |
wtftc
approved these changes
Jul 9, 2026
robarthur
added a commit
that referenced
this pull request
Jul 17, 2026
Resolves the modify/delete conflict on client/python/lkapi.py by keeping the deletion; main's PR #9 fixes are ported to python/src/lkapi in a follow-up commit.
robarthur
added a commit
that referenced
this pull request
Jul 17, 2026
Ports PR #9 to the packaged library: * frame stub blocks (e.g. time when viewby=rollup) as empty instead of KeyError * parse 401 bodies defensively before checking for Token Expired * regression tests for both
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
I believe the viewBy parameter introduced the case where the unselected viewBy data type will return an empty data set. For example, if viewBy is set to rollup, the "time" data set will not be available. We were trying to frame the empty data and would get an error.
The other update is to raise an error, rather then produce a garbage/error-shaped data instead of an exception