Skip to content

Allow for empty data set - #9

Merged
wtftc merged 1 commit into
mainfrom
main_dc_payload-bug-fix
Jul 9, 2026
Merged

Allow for empty data set#9
wtftc merged 1 commit into
mainfrom
main_dc_payload-bug-fix

Conversation

@cranedc

@cranedc cranedc commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

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

@cranedc
cranedc requested review from Copilot and wtftc July 9, 2026 16:26
@cranedc cranedc self-assigned this Jul 9, 2026

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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_v2 to build an empty DataFrame when the data key is missing (instead of raising a KeyError).
  • Simplify payload_to_frame to avoid indexing into potentially-empty payloads and consistently delegate to lk_api_data_to_frames.
  • Improve make_api_request token-expiry handling robustness and ensure HTTP errors are surfaced via raise_for_status().

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread client/python/lkapi.py
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
wtftc merged commit 6a148ae into main Jul 9, 2026
1 check passed
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
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.

3 participants