Update lance related deps: Handle NaN values with pyarrow based writing.#947
Merged
Merged
Conversation
…lated deps ### Motivation - LanceDB's `table.add()` path in versions >= 0.30 rejects NaN values in fixed-size-list/vector columns, so writing through `pylance` is needed to preserve NaNs and maintain the existing fixed-size-list on-disk format. - Upstream package compatibility changed around `lance-namespace` and `pylance`, so dependency caps were adjusted to track a compatible set of releases until broader support is available. ### Description - Add `import lance` and switch `ResultDatasetWriter.write_batch` to write Arrow batches via `lance.write_dataset(...)` instead of creating an empty table and using `table.add()` through `lancedb`, preserving fixed-size-list schemas and NaNs. - Track the current dataset handle via `self.lance_dataset` and `self.lance_uri` and append subsequent batches with mode switching (`overwrite` for the first write, `append` thereafter). - Change `commit` to call `lancedb.connect(...).open_table(TABLE_NAME).optimize()` for optimization after writes. - Update `pyproject.toml` dependency pins to `lancedb < 0.34.0`, `lance-namespace >= 0.7.7, < 0.8.0`, and `pylance >= 7.0.0, < 8.0.0` to reflect the compatibility window used by the new write path. - Update tests in `tests/hyrax/test_result_dataset.py` to import `pyarrow as pa` and validate that the stored `data` field is a `fixed_size_list` with the expected list size. ### Testing - Ran the updated unit tests for the result dataset file with `pytest tests/hyrax/test_result_dataset.py` and the tests completed successfully.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #947 +/- ##
==========================================
- Coverage 63.80% 63.79% -0.02%
==========================================
Files 74 74
Lines 7689 7686 -3
==========================================
- Hits 4906 4903 -3
Misses 2783 2783 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
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.
Motivation
lance-namespaceandpylanceversion constraints with the pylance runtime that supports the required namespace behavior.Description
pyproject.toml: setlancedb < 0.34.0,lance-namespace >= 0.7.7, < 0.8.0, andpylance >= 7.0.0, < 8.0.0to ensure compatibility with pylance-based Arrow writes.import lanceand changeResultDatasetWriterto convert batches to Arrow tables and write them withlance.write_dataset(...)instead of usingtable.add(...), so the fixed-size-listdatacolumn and NaNs are preserved.lancedb.create_tableand instead consistently write Arrow tables with a schema created from the first sample tensor; validate tensor dtype and shape on subsequent batches.commit(), calllancedb.connect(...).open_table(TABLE_NAME).optimize()to optimize the final table.tests/hyrax/test_result_dataset.pyto assert the createddatacolumn is a fixed-size-list with the expectedlist_sizeand to exercise multi-batch writes viaResultDatasetloading.Testing
pytest tests/hyrax/test_result_dataset.pywhich exercisestest_writer_basic,test_writer_multiple_batches, and multidimensional tensor writing, and all tests passed.Codex Task