Skip to content

fix(datasink): correct write-result payload types and guard missing URIs - #5272

Open
jonasdedden wants to merge 1 commit into
lance-format:mainfrom
jonasdedden:typing/lance-ray-datasink-datasource
Open

fix(datasink): correct write-result payload types and guard missing URIs#5272
jonasdedden wants to merge 1 commit into
lance-format:mainfrom
jonasdedden:typing/lance-ray-datasink-datasource

Conversation

@jonasdedden

Copy link
Copy Markdown
Contributor

Type-hint the Ray Datasink/Datasource implementations (Fixing parts of #65.).

Two real defects surfaced while doing so:

  • on_write_complete declared the per-fragment payloads as tuple[str, str], but they are pickle.dumps output, i.e. bytes. The datasink is now Datasink[WriteReturn] with WriteReturn = list[tuple[bytes, bytes]].
  • self.uri is Optional[str] (the namespace protocol marks the table location optional), yet every write and commit path passed it where str is required. A dataset_uri property now raises a clear ValueError instead of failing deeper inside pylance.
  • _read_fragments raises instead of dereferencing None: take_blobs returns List[Optional[BlobFile]].
  • The ReadTask lambda-with-default-args capture is now functools.partial with the same eager binding and argument order.

The empty-result ordering in on_write_complete is deliberately unchanged so both warning messages still fire in the same situations.

Type-hint the Ray Datasink/Datasource implementations. Two real defects
surfaced while doing so:

- `on_write_complete` declared the per-fragment payloads as `tuple[str, str]`,
  but they are `pickle.dumps` output, i.e. `bytes`. The datasink is now
  `Datasink[WriteReturn]` with `WriteReturn = list[tuple[bytes, bytes]]`.
- `self.uri` is `Optional[str]` (the namespace protocol marks the table
  location optional), yet every write and commit path passed it where `str`
  is required. A `dataset_uri` property now raises a clear ValueError instead
  of failing deeper inside pylance.
- `_read_fragments` raises instead of dereferencing `None`: `take_blobs`
  returns `List[Optional[BlobFile]]`.
- The `ReadTask` lambda-with-default-args capture is now `functools.partial`
  with the same eager binding and argument order.

The empty-result ordering in `on_write_complete` is deliberately unchanged so
both warning messages still fire in the same situations.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant