Skip to content

Commit 9f0f893

Browse files
committed
Move remove_from_cache to tests
1 parent 965ccb0 commit 9f0f893

File tree

2 files changed

+29
-34
lines changed

2 files changed

+29
-34
lines changed

src/probeinterface/library.py

Lines changed: 0 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -102,38 +102,6 @@ def get_from_cache(manufacturer: str, probe_name: str, tag: Optional[str] = None
102102
return probe
103103

104104

105-
def remove_from_cache(manufacturer: str, probe_name: str, tag: Optional[str] = None) -> Optional["Probe"]:
106-
"""
107-
Remove Probe from local cache
108-
109-
Parameters
110-
----------
111-
manufacturer : "cambridgeneurotech" | "neuronexus" | "plexon" | "imec" | "sinaps"
112-
The probe manufacturer
113-
probe_name : str (see probeinterface_libary for options)
114-
The probe name
115-
tag : str | None, default: None
116-
Optional tag for the probe
117-
118-
Returns
119-
-------
120-
probe : Probe object, or None if no probeinterface JSON file is found
121-
122-
"""
123-
cache_folder = get_cache_folder()
124-
if tag is not None:
125-
cache_folder_tag = cache_folder / tag
126-
if not cache_folder_tag.is_dir():
127-
return None
128-
cache_folder = cache_folder_tag
129-
else:
130-
cache_folder_tag = cache_folder / "main"
131-
132-
local_file = cache_folder_tag / manufacturer / (probe_name + ".json")
133-
if local_file.is_file():
134-
os.remove(local_file)
135-
136-
137105
def get_probe(
138106
manufacturer: str,
139107
probe_name: str,

tests/test_library.py

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1+
import os
12
from probeinterface import Probe
23
from probeinterface.library import (
34
download_probeinterface_file,
45
get_from_cache,
5-
remove_from_cache,
66
get_probe,
77
get_tags_in_library,
88
list_manufacturers_in_library,
@@ -15,6 +15,33 @@
1515
probe_name = "A1x32-Poly3-10mm-50-177"
1616

1717

18+
def _remove_from_cache(manufacturer: str, probe_name: str, tag = None) -> None:
19+
"""
20+
Remove Probe from local cache
21+
22+
Parameters
23+
----------
24+
manufacturer : "cambridgeneurotech" | "neuronexus" | "plexon" | "imec" | "sinaps"
25+
The probe manufacturer
26+
probe_name : str (see probeinterface_libary for options)
27+
The probe name
28+
tag : str | None, default: None
29+
Optional tag for the probe
30+
"""
31+
cache_folder = get_cache_folder()
32+
if tag is not None:
33+
cache_folder_tag = cache_folder / tag
34+
if not cache_folder_tag.is_dir():
35+
return None
36+
cache_folder = cache_folder_tag
37+
else:
38+
cache_folder_tag = cache_folder / "main"
39+
40+
local_file = cache_folder_tag / manufacturer / (probe_name + ".json")
41+
if local_file.is_file():
42+
os.remove(local_file)
43+
44+
1845
def test_download_probeinterface_file():
1946
download_probeinterface_file(manufacturer, probe_name, tag=None)
2047

@@ -29,7 +56,7 @@ def test_get_from_cache():
2956
assert probe is None # because we did not download with this tag
3057
download_probeinterface_file(manufacturer, probe_name, tag=tag)
3158
probe = get_from_cache(manufacturer, probe_name, tag=tag)
32-
remove_from_cache(manufacturer, probe_name, tag=tag)
59+
_remove_from_cache(manufacturer, probe_name, tag=tag)
3360
assert isinstance(probe, Probe)
3461

3562
probe = get_from_cache("yep", "yop")

0 commit comments

Comments
 (0)