Skip to content
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

Initial PyTorch Dataset support #134

Merged
merged 12 commits into from
Sep 7, 2022
Merged

Initial PyTorch Dataset support #134

merged 12 commits into from
Sep 7, 2022

Conversation

eddyxu
Copy link
Contributor

@eddyxu eddyxu commented Aug 30, 2022

Basic and experimental implementation of torch.Dataset.

Closes #109

@eddyxu eddyxu self-assigned this Sep 5, 2022
@eddyxu eddyxu added python PyTorch PyTorch support labels Sep 5, 2022
@eddyxu eddyxu changed the title Pytorch Dataset Initial PyTorch Dataset support Sep 5, 2022
from libcpp.string cimport string

from pathlib import Path

from pyarrow import Table
from pyarrow._dataset cimport FileFormat, FileWriteOptions, CFileWriteOptions, CScanner, CDataset, Dataset

Copy link
Contributor Author

Choose a reason for hiding this comment

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

These changes were due to running isort

@eddyxu eddyxu marked this pull request as ready for review September 5, 2022 20:19
@eddyxu eddyxu requested a review from changhiskhan September 5, 2022 20:21
@@ -49,13 +49,19 @@ def scanner(
data: Union[str, Path, ds.Dataset],
columns: Optional[str] = None,
filter: Optional[pc.Expression] = None,
batch_size: Optional[int] = None,
Copy link
Contributor

Choose a reason for hiding this comment

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

Let's add docstrings for the function?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

python/setup.py Outdated
@@ -69,7 +67,8 @@
ext_modules=cythonize(extensions, language_level="3"),
zip_safe=False,
install_requires=["pyarrow>=9,<10"],
extras_require={"test": ["pytest>=6.0", "pandas", "duckdb", "click"]},
extras_require={"test": ["pytest>=6.0", "pandas", "duckdb", "click"],
"pytorch": ["torch"]},
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm wondering if we should just ask the user to manually pip install torch? I feel like Rikai's extras system is way too complicated and hard to maintain. I'm wondering whether we should keep it simple for now.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hmm ok.


import pytest

pytest.importorskip("torch")
Copy link
Contributor

Choose a reason for hiding this comment

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

torch = pytest.importorskip("torch")? Save the import torch call afterwards

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh, i dont know this works. TIL

@@ -16,10 +16,10 @@
from pathlib import Path
Copy link
Contributor

Choose a reason for hiding this comment

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

Changes in this whole file is just formatting right?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yes, that's right.

Copy link
Contributor

@changhiskhan changhiskhan left a comment

Choose a reason for hiding this comment

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

the gh action needs update but lgtm otherwise

@@ -31,7 +31,7 @@ jobs:
run: ./tools/build_wheel.sh $(echo cp${{ matrix.python-version }} | sed "s/\.//")
- name: Pip install
run: |
python -m pip install $(ls wheels/*.whl)[test]
python -m pip install $(ls wheels/*.whl)[test,pytorch]
Copy link
Contributor

Choose a reason for hiding this comment

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

install pytorch directly?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed.

@eddyxu eddyxu merged commit 3f192d3 into main Sep 7, 2022
@eddyxu eddyxu deleted the lei/pytorch branch September 7, 2022 17:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
python PyTorch PyTorch support
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support reading lance into PyTorch
2 participants