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

use rdata as a driver for 'rds' files #231

Merged
merged 4 commits into from
Mar 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 .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ jobs:
run: |
python -m pip install --upgrade pip
python -m pip install -r requirements/dev.txt
python -m pip install rdata
python -m pip install -e .[test]

- name: run Posit Connect
Expand Down
10 changes: 10 additions & 0 deletions pins/drivers.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,16 @@ def load_data(
" Use `.pin_download()` to download the file."
)

elif meta.type == "rds":
try:
import rdata

return rdata.read_rds(f)
except ModuleNotFoundError:
raise ModuleNotFoundError(
"Install the 'rdata' package to attempt to convert 'rds' files into Python objects."
)

raise NotImplementedError(f"No driver for type {meta.type}")


Expand Down
10 changes: 7 additions & 3 deletions pins/tests/test_compat.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,9 +153,13 @@ def test_compat_pin_read(board):
assert src_df.equals(dst_df)


def test_compat_pin_read_supported(board):
with pytest.raises(NotImplementedError):
board.pin_read("df_rds")
def test_compat_pin_read_supported_rds(board):
pytest.importorskip("rdata")
import pandas as pd

src_df = board.pin_read("df_rds")

assert isinstance(src_df, pd.DataFrame)


# pin_write ----
Expand Down
Loading