Skip to content

Commit 5806a71

Browse files
authored
use rdata as a driver for 'rds' files (#231)
* add rdata driver * update tests * install qs * importorskip in test
1 parent be9968d commit 5806a71

File tree

3 files changed

+18
-3
lines changed

3 files changed

+18
-3
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ jobs:
9191
run: |
9292
python -m pip install --upgrade pip
9393
python -m pip install -r requirements/dev.txt
94+
python -m pip install rdata
9495
python -m pip install -e .[test]
9596
9697
- name: run Posit Connect

pins/drivers.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,16 @@ def load_data(
121121
" Use `.pin_download()` to download the file."
122122
)
123123

124+
elif meta.type == "rds":
125+
try:
126+
import rdata
127+
128+
return rdata.read_rds(f)
129+
except ModuleNotFoundError:
130+
raise ModuleNotFoundError(
131+
"Install the 'rdata' package to attempt to convert 'rds' files into Python objects."
132+
)
133+
124134
raise NotImplementedError(f"No driver for type {meta.type}")
125135

126136

pins/tests/test_compat.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -153,9 +153,13 @@ def test_compat_pin_read(board):
153153
assert src_df.equals(dst_df)
154154

155155

156-
def test_compat_pin_read_supported(board):
157-
with pytest.raises(NotImplementedError):
158-
board.pin_read("df_rds")
156+
def test_compat_pin_read_supported_rds(board):
157+
pytest.importorskip("rdata")
158+
import pandas as pd
159+
160+
src_df = board.pin_read("df_rds")
161+
162+
assert isinstance(src_df, pd.DataFrame)
159163

160164

161165
# pin_write ----

0 commit comments

Comments
 (0)