Skip to content

Commit

Permalink
use rdata as a driver for 'rds' files (#231)
Browse files Browse the repository at this point in the history
* add rdata driver

* update tests

* install qs

* importorskip in test
  • Loading branch information
isabelizimm authored Mar 29, 2024
1 parent be9968d commit 5806a71
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 3 deletions.
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

0 comments on commit 5806a71

Please sign in to comment.