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

Add pyarrow usage test case #38

Merged
merged 1 commit into from
Apr 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
"pytest",
"pytest-aiohttp",
"ray",
"pyarrow",
]
},
python_requires=">=3.8",
Expand Down
47 changes: 47 additions & 0 deletions tests/fs/test_docker_pyarrow_usage.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
import logging
import os

from pyarrow.fs import FSSpecHandler
from pyarrow.fs import PyFileSystem

from alluxiofs import AlluxioFileSystem
from tests.conftest import ALLUXIO_FILE_PATH
from tests.conftest import LOCAL_FILE_PATH
from tests.fs.test_docker_fsspec_cat import ALLUXIO_PREFIX
from tests.fs.test_docker_fsspec_cat import FILE_PATH

LOGGER = logging.getLogger(__name__)


def alluxio_pyarrow_test(py_fs, alluxio_path, local_path):
file_size = os.path.getsize(local_path)

file_info = py_fs.get_file_info(alluxio_path)
assert file_info.is_file
assert file_info.size == file_size
assert file_info.path == alluxio_path

with py_fs.open_input_file(alluxio_path) as f:
alluxio_file_data = f.read()

with open(local_path, "rb") as local_file:
local_file_data = local_file.read()
assert local_file_data == alluxio_file_data


def test_alluxio_pyarrow(alluxio_file_system: AlluxioFileSystem):
py_fs = PyFileSystem(FSSpecHandler(alluxio_file_system))
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can you add the the PyArrow usage examples in the README.md
especially how can we create the PyFileSystem using other ways, we may not be able to pass in created alluxio_file_system to PyArrow Filesystem but directly pass the arguments to create PyFileSystem directly

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Sure, I will add it in the next PR.


alluxio_pyarrow_test(py_fs, ALLUXIO_FILE_PATH, LOCAL_FILE_PATH)
alluxio_pyarrow_test(
py_fs,
ALLUXIO_PREFIX + ALLUXIO_FILE_PATH,
LOCAL_FILE_PATH,
)
alluxio_pyarrow_test(py_fs, FILE_PATH, LOCAL_FILE_PATH)


def test_etcd_alluxio_pyarrow(
etcd_alluxio_file_system: AlluxioFileSystem,
):
test_alluxio_pyarrow(etcd_alluxio_file_system)
Loading