Skip to content

Commit ea242bc

Browse files
authored
Merge pull request #213 from rstudio/versioned-false
2 parents 3ea40e8 + 3da6bb3 commit ea242bc

File tree

4 files changed

+43
-13
lines changed

4 files changed

+43
-13
lines changed

pins/boards.py

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -66,10 +66,6 @@ def __init__(
6666
self.board = str(board)
6767
self.fs = fs
6868
self.meta_factory = meta_factory
69-
70-
if versioned is False:
71-
raise NotImplementedError()
72-
7369
self.versioned = versioned
7470
self.allow_pickle_read = allow_pickle_read
7571

@@ -93,6 +89,11 @@ def pin_versions(self, name: str, as_df: bool = True) -> Sequence[VersionRaw]:
9389
Pin name.
9490
9591
"""
92+
if not self.versioned:
93+
raise NotImplementedError(
94+
"Cannot show versions for a board type that does not support versioning."
95+
)
96+
9697
if not self.pin_exists(name):
9798
raise PinsError("Cannot check version, since pin %s does not exist" % name)
9899

@@ -237,6 +238,11 @@ def _pin_store(
237238
created: Optional[datetime] = None,
238239
) -> Meta:
239240

241+
if not self.versioned:
242+
raise NotImplementedError(
243+
"Can only write pins with boards that support versioning."
244+
)
245+
240246
if type == "feather":
241247
warn_deprecated(
242248
'Writing pin type "feather" is unsupported. Switching type to "arrow".'
@@ -351,6 +357,11 @@ def pin_write(
351357
part of the pin version name.
352358
"""
353359

360+
if not self.versioned:
361+
raise NotImplementedError(
362+
"Can only write pins with boards that support versioning."
363+
)
364+
354365
if type == "file":
355366
raise NotImplementedError(
356367
".pin_write() does not support type='file'. "
@@ -449,6 +460,10 @@ def pin_version_delete(self, name: str, version: str):
449460
version:
450461
Version identifier.
451462
"""
463+
if not self.versioned:
464+
raise NotImplementedError(
465+
"Can only write pins with boards that support versioning."
466+
)
452467

453468
pin_name = self.path_to_pin(name)
454469

pins/constructors.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -370,7 +370,7 @@ def board_url(path: str, pin_paths: dict, cache=DEFAULT, allow_pickle_read=None)
370370
--------
371371
372372
```python
373-
github_raw = "https://raw.githubusercontent.com/machow/pins-python/main/pins/tests/pins-compat"
373+
github_raw = "https://raw.githubusercontent.com/rstudio/pins-python/main/pins/tests/pins-compat"
374374
pin_paths = {
375375
"df_csv": "df_csv/20220214T163720Z-9bfad/",
376376
"df_arrow": "df_arrow/20220214T163720Z-ad0c1/",
@@ -399,7 +399,7 @@ def board_url(path: str, pin_paths: dict, cache=DEFAULT, allow_pickle_read=None)
399399
return BoardManual(
400400
path,
401401
fs,
402-
versioned=True,
402+
versioned=False,
403403
allow_pickle_read=allow_pickle_read,
404404
pin_paths=pin_paths,
405405
)

pins/tests/test_boards.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -600,9 +600,8 @@ def test_board_rsc_pin_read_public(df, board_short):
600600

601601

602602
def test_board_manual_http_file_download():
603-
# TODO: change when repo is moved to RStudio
604603

605-
path = "https://raw.githubusercontent.com/machow/pins-python"
604+
path = "https://raw.githubusercontent.com/rstudio/pins-python"
606605
license_path = "main/LICENSE"
607606

608607
# use a simple cache, which automatically creates a temporary directory
@@ -630,7 +629,7 @@ def test_board_manual_pin_read():
630629
# see https://github.com/fsspec/filesystem_spec/issues/389
631630
fs = fsspec.filesystem("http", block_size=0)
632631
board = BoardManual(
633-
"https://raw.githubusercontent.com/machow/pins-python/main/pins/tests/pins-compat",
632+
"https://raw.githubusercontent.com/rstudio/pins-python/main/pins/tests/pins-compat",
634633
fs,
635634
pin_paths={
636635
"df_csv": "df_csv/20220214T163718Z-eceac/",

pins/tests/test_constructors.py

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ def construct_from_board(board):
5959
# copied from test_compat
6060
@pytest.mark.skip_on_github
6161
def test_constructor_board_url_data(tmp_cache, http_example_board_path, df_csv):
62-
board = c.board_urls(
62+
board = c.board_url(
6363
http_example_board_path,
6464
# could derive from example version path
6565
pin_paths={"df_csv": "df_csv/20220214T163720Z-9bfad/"},
@@ -73,18 +73,34 @@ def test_constructor_board_url_data(tmp_cache, http_example_board_path, df_csv):
7373

7474
@pytest.mark.xfail
7575
@pytest.mark.skip_on_github
76-
def test_constructor_board_url_cache(tmp_cache, http_example_board_path, df_csv):
76+
def test_constructor_board_url_cache(
77+
tmp_cache, http_example_board_path, df_csv, tmp_path
78+
):
7779
# TODO: downloading a pin does not put files in the same directory, since
7880
# in this case we are hashing on the full url.
7981

80-
board = c.board_urls(
82+
board = c.board_url(
8183
http_example_board_path,
8284
# could derive from example version path
8385
pin_paths={"df_csv": "df_csv/20220214T163718Z-eceac/"},
8486
)
8587

8688
board.pin_read("df_csv")
8789

90+
# cannot write or view pin versions
91+
92+
with pytest.raises(NotImplementedError):
93+
board.pin_write(df_csv)
94+
with pytest.raises(NotImplementedError):
95+
board.pin_versions("df_csv")
96+
with pytest.raises(NotImplementedError):
97+
board.pin_version_delete(name="df_csv", version="20220214T163718Z")
98+
with pytest.raises(NotImplementedError):
99+
df = pd.DataFrame({"x": [1, 2, 3]})
100+
path = tmp_path / "data.csv"
101+
df.to_csv(path, index=False)
102+
board.pin_upload(path, "cool_pin")
103+
88104
# check cache ----
89105
http_dirs = list(tmp_cache.glob("http_*"))
90106

@@ -107,7 +123,7 @@ def test_constructor_board_url_file(tmp_cache, http_example_board_path):
107123
# TODO: downloading a pin does not put files in the same directory, since
108124
# in this case we are hashing on the full url.
109125

110-
board = c.board_urls(
126+
board = c.board_url(
111127
http_example_board_path,
112128
# could derive from example version path
113129
pin_paths={"df_csv": "df_csv/20220214T163718Z-eceac/df_csv.csv"},

0 commit comments

Comments
 (0)