6
6
import fsspec
7
7
import pytest
8
8
9
- from huggingface_hub .constants import REPO_TYPES_URL_PREFIXES
10
9
from huggingface_hub .hf_file_system import HfFileSystem
11
10
from huggingface_hub .utils import RepositoryNotFoundError , RevisionNotFoundError
12
11
13
- from .testing_constants import ENDPOINT_STAGING , TOKEN , USER
12
+ from .testing_constants import ENDPOINT_STAGING , TOKEN
14
13
from .testing_utils import repo_name
15
14
16
15
@@ -22,36 +21,37 @@ def setUpClass(cls):
22
21
fsspec .register_implementation (HfFileSystem .protocol , HfFileSystem )
23
22
24
23
def setUp (self ):
25
- self .repo_id = f"{ USER } /{ repo_name ()} "
26
- self .repo_type = "dataset"
27
- self .hf_path = REPO_TYPES_URL_PREFIXES .get (self .repo_type , "" ) + self .repo_id
28
24
self .hffs = HfFileSystem (endpoint = ENDPOINT_STAGING , token = TOKEN )
29
25
self .api = self .hffs ._api
30
26
31
27
# Create dummy repo
32
- self .api .create_repo (self .repo_id , repo_type = self .repo_type )
28
+ repo_url = self .api .create_repo (repo_name (), repo_type = "dataset" )
29
+ self .repo_id = repo_url .repo_id
30
+ self .hf_path = f"datasets/{ self .repo_id } "
31
+
32
+ # Upload files
33
33
self .api .upload_file (
34
34
path_or_fileobj = b"dummy binary data on pr" ,
35
35
path_in_repo = "data/binary_data_for_pr.bin" ,
36
36
repo_id = self .repo_id ,
37
- repo_type = self . repo_type ,
37
+ repo_type = "dataset" ,
38
38
create_pr = True ,
39
39
)
40
40
self .api .upload_file (
41
41
path_or_fileobj = "dummy text data" .encode ("utf-8" ),
42
42
path_in_repo = "data/text_data.txt" ,
43
43
repo_id = self .repo_id ,
44
- repo_type = self . repo_type ,
44
+ repo_type = "dataset" ,
45
45
)
46
46
self .api .upload_file (
47
47
path_or_fileobj = b"dummy binary data" ,
48
48
path_in_repo = "data/binary_data.bin" ,
49
49
repo_id = self .repo_id ,
50
- repo_type = self . repo_type ,
50
+ repo_type = "dataset" ,
51
51
)
52
52
53
53
def tearDown (self ):
54
- self .api .delete_repo (self .repo_id , repo_type = self . repo_type )
54
+ self .api .delete_repo (self .repo_id , repo_type = "dataset" )
55
55
56
56
def test_glob (self ):
57
57
self .assertEqual (
@@ -141,7 +141,7 @@ def test_modified_time(self):
141
141
142
142
def test_initialize_from_fsspec (self ):
143
143
fs , _ , paths = fsspec .get_fs_token_paths (
144
- f"hf://{ self . repo_type } s /{ self .repo_id } /data/text_data.txt" ,
144
+ f"hf://datasets /{ self .repo_id } /data/text_data.txt" ,
145
145
storage_options = {
146
146
"endpoint" : ENDPOINT_STAGING ,
147
147
"token" : TOKEN ,
0 commit comments