Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Document more HfFilesyStem Methods #2380

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions docs/source/en/package_reference/hf_file_system.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ The `HfFileSystem` class provides a pythonic file interface to the Hugging Face

`HfFileSystem` is based on [fsspec](https://filesystem-spec.readthedocs.io/en/latest/), so it is compatible with most of the APIs that it offers. For more details, check out [our guide](../guides/hf_file_system) and fsspec's [API Reference](https://filesystem-spec.readthedocs.io/en/latest/api.html#fsspec.spec.AbstractFileSystem).

[[autodoc]] HfFileSystem
[[autodoc]] HfFileSystem
- __init__
- resolve_path
- ls
- all
18 changes: 18 additions & 0 deletions src/huggingface_hub/hf_file_system.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import inspect
import os
import re
import tempfile
Expand Down Expand Up @@ -889,3 +890,20 @@ def _raise_file_not_found(path: str, err: Optional[Exception]) -> NoReturn:

def reopen(fs: HfFileSystem, path: str, mode: str, block_size: int, cache_type: str):
return fs.open(path, mode=mode, block_size=block_size, cache_type=cache_type)


# Add docstrings to the methods of HfFileSystem from fsspec.AbstractFileSystem
for name, function in inspect.getmembers(HfFileSystem, predicate=inspect.isfunction):
parent = getattr(fsspec.AbstractFileSystem, name, None)
if parent is not None and parent.__doc__ is not None:
parent_doc = parent.__doc__
parent_doc = parent_doc.replace("Parameters\n ----------\n", "Args:\n")
parent_doc = parent_doc.replace("Returns\n -------\n", "Return:\n")
function.__doc__ = (
(
"\n_Docstring taken from "
f"[fsspec documentation](https://filesystem-spec.readthedocs.io/en/latest/api.html#fsspec.spec.AbstractFileSystem.{name})._"
)
+ "\n\n"
+ parent_doc
)
Loading