Skip to content

Commit e701af7

Browse files
authored
Final fixes for datasets' push_to_hub (#415)
1 parent b514069 commit e701af7

File tree

1 file changed

+14
-3
lines changed

1 file changed

+14
-3
lines changed

src/huggingface_hub/hf_api.py

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
from typing_extensions import Literal
4242

4343

44-
REMOTE_FILEPATH_REGEX = re.compile(r"^\w[\w\/]*(\.\w+)?$")
44+
REMOTE_FILEPATH_REGEX = re.compile(r"^\w[\w\/\-]*(\.\w+)?$")
4545
# ^^ No trailing slash, no backslash, no spaces, no relative parts ("." or "..")
4646
# Only word characters and an optional extension
4747

@@ -590,13 +590,24 @@ def list_repo_files(
590590
self,
591591
repo_id: str,
592592
revision: Optional[str] = None,
593+
repo_type: Optional[str] = None,
593594
token: Optional[str] = None,
594595
timeout: Optional[float] = None,
595-
) -> ModelInfo:
596+
) -> List[str]:
596597
"""
597598
Get the list of files in a given repo.
598599
"""
599-
info = self.model_info(repo_id, revision=revision, token=token, timeout=timeout)
600+
if repo_type is None:
601+
info = self.model_info(
602+
repo_id, revision=revision, token=token, timeout=timeout
603+
)
604+
elif repo_type == "dataset":
605+
info = self.dataset_info(
606+
repo_id, revision=revision, token=token, timeout=timeout
607+
)
608+
else:
609+
raise ValueError("Spaces are not available yet.")
610+
600611
return [f.rfilename for f in info.siblings]
601612

602613
def list_repos_objs(

0 commit comments

Comments
 (0)