Hub Python Library documentation
Tương tác với Thảo luận và Yêu cầu Gộp
Tương tác với Thảo luận và Yêu cầu Gộp
Xem trang tài liệu HfApi để tham khảo các phương thức cho phép tương tác với Pull Requests và Discussions trên Hub.
- get_repo_discussions()
- get_discussion_details()
- create_discussion()
- create_pull_request()
- rename_discussion()
- comment_discussion()
- edit_discussion_comment()
- change_discussion_status()
- merge_pull_request()
Cấu trúc dữ liệu
lớp huggingface_hub.Discussion
< source >( title: strstatus: typing.Literal['open', 'closed', 'merged', 'draft']num: intrepo_id: strrepo_type: strauthor: stris_pull_request: boolcreated_at: datetimeendpoint: str )
Tham số
- title (
str) — Tiêu đề của Discussion / Pull Request - status (
str) — Trạng thái của Discussion / Pull Request. Phải là một trong các giá trị:"open""closed""merged"(chỉ dành cho Pull Requests)"draft"(chỉ dành cho Pull Requests)
- num (
int) — Số thứ tự của Discussion / Pull Request. - repo_id (
str) — id ("{namespace}/{repo_name}") của repo mà Discussion / Pull Request được mở trên đó. - repo_type (
str) — Loại kho mà Discussion / Pull Request được mở trên đó. Các giá trị có thể là:"model","dataset","space". - author (
str) — Tên người dùng của tác giả Discussion / Pull Request. Có thể là"deleted"nếu người dùng đã bị xóa kể từ đó. - is_pull_request (
bool) — Chỉ ra đây có phải là một Pull Request hay không. - created_at (
datetime) —datetimecủa thời điểm tạo Discussion / Pull Request. - endpoint (
str) — Endpoint của Hub. Mặc định là https://huggingface.co. - git_reference (
str, tùy chọn) — (property) Tham chiếu Git mà các thay đổi có thể được đẩy lên nếu đây là một Pull Request,Nonetrong trường hợp ngược lại. - url (
str) — (property) URL của cuộc thảo luận trên Hub.
Một Discussion hoặc Pull Request trên Hub.
Dataclass này không được thiết kế để khởi tạo trực tiếp.
lớp huggingface_hub.DiscussionWithDetails
< source >( title: strstatus: typing.Literal['open', 'closed', 'merged', 'draft']num: intrepo_id: strrepo_type: strauthor: stris_pull_request: boolcreated_at: datetimeendpoint: strevents: listconflicting_files: list[str] | bool | Nonetarget_branch: str | Nonemerge_commit_oid: str | Nonediff: str | None )
Tham số
- title (
str) — Tiêu đề của Discussion / Pull Request - status (
str) — Trạng thái của Discussion / Pull Request. Có thể là một trong các giá trị:"open""closed""merged"(chỉ dành cho Pull Requests)"draft"(chỉ dành cho Pull Requests)
- num (
int) — Số thứ tự của Discussion / Pull Request. - repo_id (
str) — id ("{namespace}/{repo_name}") của repo mà Discussion / Pull Request được mở trên đó. - repo_type (
str) — Loại kho mà Discussion / Pull Request được mở trên đó. Các giá trị có thể là:"model","dataset","space". - author (
str) — Tên người dùng của tác giả Discussion / Pull Request. Có thể là"deleted"nếu người dùng đã bị xóa kể từ đó. - is_pull_request (
bool) — Chỉ ra đây có phải là một Pull Request hay không. - created_at (
datetime) —datetimecủa thời điểm tạo Discussion / Pull Request. - events (
listcủa DiscussionEvent) — Danh sách cácDiscussionEventstrong Discussion hoặc Pull Request này. - conflicting_files (
Union[list[str], bool, None], tùy chọn) — Danh sách các tệp xung đột nếu đây là một Pull Request.Nonenếuself.is_pull_requestlàFalse.Truenếu có các tệp xung đột nhưng không thể lấy danh sách. - target_branch (
str, tuỳ chọn) — Nhánh mà các thay đổi sẽ được hợp nhất vào nếu đây là một Pull Request.Nonenếuself.is_pull_requestlàFalse. - merge_commit_oid (
str, tuỳ chọn) — Nếu đây là một Pull Request đã được hợp nhất, giá trị này được đặt thành OID / SHA của commit hợp nhất, ngược lại làNone. - diff (
str, optional) — Lệnh git diff nếu đây là một Pull Request, ngược lại làNone. - endpoint (
str) — Endpoint của Hub. Mặc định là https://huggingface.co. - git_reference (
str, tùy chọn) — (property) Tham chiếu Git mà các thay đổi có thể được đẩy lên nếu đây là một Pull Request,Nonetrong trường hợp ngược lại. - url (
str) — (property) URL của cuộc thảo luận trên Hub.
Lớp con của Discussion.
lớp huggingface_hub.DiscussionEvent
< source >( id: strtype: strcreated_at: datetimeauthor: str_event: dict )
Tham số
- id (
str) — ID của sự kiện. Một chuỗi hex. - type (
str) — Loại của sự kiện. - created_at (
datetime) — Một đối tượngdatetimechứa mốc thời gian tạo của sự kiện. - author (
str) — Tên người dùng của tác giả Discussion / Pull Request. Có thể là"deleted"nếu người dùng đã bị xóa kể từ đó.
Một sự kiện trong Thảo luận hoặc Pull Request.
Sử dụng các lớp cụ thể:
lớp huggingface_hub.DiscussionComment
< source >( id: strtype: strcreated_at: datetimeauthor: str_event: dictcontent: stredited: boolhidden: bool )
Tham số
- id (
str) — ID của sự kiện. Một chuỗi hex. - type (
str) — Loại của sự kiện. - created_at (
datetime) — Một đối tượngdatetimechứa mốc thời gian tạo của sự kiện. - author (
str) — Tên người dùng của tác giả Discussion / Pull Request. Có thể là"deleted"nếu người dùng đã bị xóa kể từ đó. - content (
str) — Nội dung markdown thô của bình luận. Các đề cập, liên kết và hình ảnh không được hiển thị. - edited (
bool) — Cho biết bình luận này đã được chỉnh sửa hay chưa. - hidden (
bool) — Cho biết bình luận này đã bị ẩn hay chưa.
Một bình luận trong một Discussion / Pull Request.
Lớp con của DiscussionEvent.
lớp huggingface_hub.DiscussionStatusChange
< source >( id: strtype: strcreated_at: datetimeauthor: str_event: dictnew_status: str )
Tham số
- id (
str) — ID của sự kiện. Một chuỗi hex. - type (
str) — Loại của sự kiện. - created_at (
datetime) — Một đối tượngdatetimechứa mốc thời gian tạo của sự kiện. - author (
str) — Tên người dùng của tác giả Discussion / Pull Request. Có thể là"deleted"nếu người dùng đã bị xóa kể từ đó. - new_status (
str) — Trạng thái của Discussion / Pull Request sau khi thay đổi. Nó có thể là một trong các giá trị:"open""closed""merged"(chỉ dành cho Pull Requests)
Thay đổi trạng thái trong một Discussion / Pull Request.
Lớp con của DiscussionEvent.
lớp huggingface_hub.DiscussionCommit
< source >( id: strtype: strcreated_at: datetimeauthor: str_event: dictsummary: stroid: str )
Tham số
- id (
str) — ID của sự kiện. Một chuỗi hex. - type (
str) — Loại của sự kiện. - created_at (
datetime) — Một đối tượngdatetimechứa mốc thời gian tạo của sự kiện. - author (
str) — Tên người dùng của tác giả Discussion / Pull Request. Có thể là"deleted"nếu người dùng đã bị xóa kể từ đó. - summary (
str) — Tóm tắt của commit. - oid (
str) — OID / SHA của commit, dưới dạng chuỗi hex.
Một commit trong một Pull Request.
Lớp con của DiscussionEvent.
lớp huggingface_hub.DiscussionTitleChange
< source >( id: strtype: strcreated_at: datetimeauthor: str_event: dictold_title: strnew_title: str )
Tham số
- id (
str) — ID của sự kiện. Một chuỗi hex. - type (
str) — Loại của sự kiện. - created_at (
datetime) — Một đối tượngdatetimechứa mốc thời gian tạo của sự kiện. - author (
str) — Tên người dùng của tác giả Discussion / Pull Request. Có thể là"deleted"nếu người dùng đã bị xóa kể từ đó. - old_title (
str) — Tiêu đề trước đó của Discussion / Pull Request. - new_title (
str) — Tiêu đề mới.
Sự kiện đổi tên trong một Discussion / Pull Request.
Lớp con của DiscussionEvent.