-
Notifications
You must be signed in to change notification settings - Fork 0
fix(codec): await nested Arrow decode in torch #33
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
Caution Review failedThe pull request is closed. 📝 WalkthroughWalkthroughAdded asynchronous envelope decoding internals and an async decode path so nested Promise-based decodes (e.g., Arrow-encoded ndarrays inside Changes
Sequence Diagram(s)sequenceDiagram
participant Caller
participant Codec as codec (decodeValueAsync / decodeEnvelopeAsync)
participant Arrow as Arrow decoder
participant Result
Caller->>Codec: decodeValueAsync(envelope)
Codec->>Codec: inspect envelope.type (e.g., torch.tensor)
alt nested value uses Arrow encoding
Codec->>Arrow: decodeArrow(bytes) (async)
Arrow-->>Codec: Promise<decoded ndarray>
Codec->>Codec: await decoded ndarray
end
Codec->>Result: construct resolved object (no Promises in fields)
Result-->>Caller: return resolved value
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
📜 Recent review detailsConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Pro 📒 Files selected for processing (2)
✏️ Tip: You can disable this entire section by setting Comment |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 2
🤖 Fix all issues with AI agents
In `@src/utils/codec.ts`:
- Around line 261-370: Duplicate envelope-parsing/validation logic exists
between decodeEnvelope and decodeEnvelopeAsync; extract the shared
marker/validation and per-marker extraction into a single helper (e.g.,
parseEnvelope or extractEnvelopePayload) that returns a normalized envelope
descriptor (marker, encoding, and raw fields) and have both decodeEnvelope and
decodeEnvelopeAsync call that helper, with decodeEnvelopeAsync awaiting nested
decodeArrow calls and decodeEnvelope either wrapping a sync decodeArrow or
calling the same helper plus synchronous decoders; update usages where
torch.tensor and nested value decoding occur so the async path awaits
decodeEnvelopeAsync but reuses the same extracted envelope data.
In `@test/runtime_codec.test.ts`:
- Around line 395-419: Add an explicit assertion that the decoded `data` is not
a Promise to prevent regressions where `data` was unresolved (issue `#21`): after
calling `decodeValueAsync(envelope)` in the test, add a check such as
`expect(result.data).not.toBeInstanceOf(Promise)` (or assert `typeof
result.data.then !== 'function'`) in addition to the existing
`expect.any(Uint8Array)` check so the `decodeValueAsync` /
`registerArrowDecoder` path is validated to return a concrete Uint8Array rather
than a Promise.
📜 Review details
Configuration used: Organization UI
Review profile: ASSERTIVE
Plan: Pro
📒 Files selected for processing (2)
src/utils/codec.tstest/runtime_codec.test.ts
🧰 Additional context used
🧬 Code graph analysis (2)
test/runtime_codec.test.ts (1)
src/utils/codec.ts (3)
registerArrowDecoder(102-106)CodecEnvelope(43-90)decodeValueAsync(375-377)
src/utils/codec.ts (1)
src/index.ts (1)
decodeValueAsync(71-71)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
- GitHub Check: os (windows-latest)
🔇 Additional comments (3)
src/utils/codec.ts (2)
339-347: Core fix is correct—nested Arrow decoding is now properly awaited.The key change at line 340 (
await decodeEnvelopeAsync(torchValue.value, decodeArrow)) correctly addresses issue#21by ensuring that when a torch tensor contains a nested Arrow-encoded ndarray, the Promise is resolved before assignment toTorchTensor.data.
375-377: LGTM—decodeValueAsyncnow correctly delegates to the async helper.The updated implementation properly chains to
decodeEnvelopeAsyncwithtryDecodeArrowTable, ensuring all nested async decodes are awaited.test/runtime_codec.test.ts (1)
396-396: Decoder is synchronous butdecodeValueAsyncwraps it intryDecodeArrowTable.The registered decoder (
bytes => bytes) is synchronous, buttryDecodeArrowTablein codec.ts wraps it in an async function. This test still validates the fix becausedecodeEnvelopeAsyncawaits the result regardless. The test coverage is adequate for the regression.
✏️ Tip: You can disable this entire section by setting review_details to false in your review settings.
|
Addressed CodeRabbit feedback:
@CodeRabbit full review |
|
I'll review all the changes in the PR now. ✅ Actions performedFull review triggered. |
|
@CodeRabbit full review |
✅ Actions performedFull review triggered. |
Fixes #21
What
decodeValueAsyncawaits nested envelope decodes when decodingtorch.tensorvalues (soTorchTensor.datais never a Promise).Tests