Skip to content

Commit c83459d

Browse files
committed
feat: support list with single entry for pin_upload
1 parent 0f0e6ae commit c83459d

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

pins/boards.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -248,6 +248,9 @@ def _pin_store(
248248
if type == "file":
249249
# the file type makes the name of the data the exact filename, rather
250250
# than the pin name + a suffix (e.g. my_pin.csv).
251+
if isinstance(x, (tuple, list)) and len(x) == 1:
252+
x = x[0]
253+
251254
_p = Path(x)
252255
_base_len = len(_p.name) - len("".join(_p.suffixes))
253256
object_name = _p.name[:_base_len]

pins/tests/test_boards.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,19 @@ def test_board_pin_download_no_cache_error(board, tmp_path):
218218
(pin_path,) = board.pin_download("cool_pin")
219219

220220

221+
def test_board_pin_upload_path_list(board_with_cache, tmp_path):
222+
# create and save data
223+
df = pd.DataFrame({"x": [1, 2, 3]})
224+
225+
path = tmp_path / "data.csv"
226+
df.to_csv(path, index=False)
227+
228+
meta = board_with_cache.pin_upload([path], "cool_pin")
229+
assert meta.type == "file"
230+
231+
(pin_path,) = board_with_cache.pin_download("cool_pin")
232+
233+
221234
def test_board_pin_write_rsc_index_html(board, tmp_dir2, snapshot):
222235
if board.fs.protocol != "rsc":
223236
pytest.skip()

0 commit comments

Comments
 (0)