Hub Python 庫文件
與討論和拉取請求互動
並獲得增強的文件體驗
開始使用
與討論和拉取請求互動
請參閱 HfApi 文件頁面,瞭解有關可用於與 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()
資料結構
class huggingface_hub.Discussion
< 原始檔 >( title: str status: typing.Literal['open', 'closed', 'merged', 'draft'] num: int repo_id: str repo_type: str author: str is_pull_request: bool created_at: datetime endpoint: str )
引數
- title (
str) — 討論/拉取請求的標題 - status (
str) — 討論/拉取請求的狀態。它必須是以下之一:"open""closed""merged"(僅限拉取請求)"draft"(僅限拉取請求)
- num (
int) — 討論/拉取請求的編號。 - repo_id (
str) — 討論/拉取請求所在倉庫的 ID("{namespace}/{repo_name}")。 - repo_type (
str) — 討論/拉取請求所在倉庫的型別。可能的值為:"model"、"dataset"、"space"。 - author (
str) — 討論/拉取請求作者的使用者名稱。如果使用者已被刪除,則可能為"deleted"。 - is_pull_request (
bool) — 這是否是拉取請求。 - created_at (
datetime) — 討論/拉取請求建立的datetime。 - endpoint (
str) — Hub 的端點。預設值為 https://huggingface.co。 - git_reference (
str, optional) — (屬性)如果這是拉取請求,則可以推送到 Git 引用;否則為None。 - url (
str) — (屬性)Hub 上討論的 URL。
Hub 上的討論或拉取請求。
此資料類不打算直接例項化。
class huggingface_hub.DiscussionWithDetails
< 原始檔 >( title: str status: typing.Literal['open', 'closed', 'merged', 'draft'] num: int repo_id: str repo_type: str author: str is_pull_request: bool created_at: datetime endpoint: str events: list conflicting_files: typing.Union[list[str], bool, NoneType] target_branch: typing.Optional[str] merge_commit_oid: typing.Optional[str] diff: typing.Optional[str] )
引數
- title (
str) — 討論/拉取請求的標題 - status (
str) — 討論/拉取請求的狀態。它可以是以下之一:"open""closed""merged"(僅限拉取請求)"draft"(僅限拉取請求)
- num (
int) — 該討論/拉取請求的編號。 - repo_id (
str) — 該討論/拉取請求所在的倉庫 ID ("{namespace}/{repo_name}")。 - repo_type (
str) — 該討論/拉取請求所在的倉庫型別。可能的值為:"model"、"dataset"、"space"。 - author (
str) — 該討論/拉取請求作者的使用者名稱。如果使用者已被刪除,則可能為"deleted"。 - is_pull_request (
bool) — 這是否是拉取請求。 - created_at (
datetime) — 該討論/拉取請求的建立datetime物件。 - events (
listof DiscussionEvent) — 此討論或拉取請求中的DiscussionEvents列表。 - conflicting_files (
Union[list[str], bool, None], optional) — 如果這是拉取請求,則為衝突檔案的列表。如果self.is_pull_request為False,則為None。如果存在衝突檔案但無法檢索列表,則為True。 - target_branch (
str, optional) — 如果這是拉取請求,則為要合併更改的分支。如果self.is_pull_request為False,則為None。 - merge_commit_oid (
str, optional) — 如果這是已合併的拉取請求,則設定為合併提交的 OID/SHA,否則為None。 - diff (
str, optional) — 如果這是拉取請求,則為 git diff,否則為None。 - endpoint (
str) — Hub 的端點。預設為 https://huggingface.co。 - git_reference (
str, optional) — (property) 如果這是拉取請求,則為可以推送更改的 Git 引用,否則為None。 - url (
str) — (property) Hub 上討論的 URL。
Discussion 的子類。
class huggingface_hub.DiscussionEvent
< source >( id: str type: str created_at: datetime author: str _event: dict )
引數
- id (
str) — 事件 ID。一個十六進位制字串。 - type (
str) — 事件的型別。 - created_at (
datetime) — 一個包含事件建立時間戳的datetime物件。 - author (
str) — 該討論/拉取請求作者的使用者名稱。如果使用者已被刪除,則可能為"deleted"。
討論或拉取請求中的一個事件。
使用具體類
class huggingface_hub.DiscussionComment
< source >( id: str type: str created_at: datetime author: str _event: dict content: str edited: bool hidden: bool )
引數
- id (
str) — 事件 ID。一個十六進位制字串。 - type (
str) — 事件的型別。 - created_at (
datetime) — 一個包含事件建立時間戳的datetime物件。 - author (
str) — 該討論/拉取請求作者的使用者名稱。如果使用者已被刪除,則可能為"deleted"。 - content (
str) — 評論的原始 markdown 內容。提及、連結和影像未渲染。 - edited (
bool) — 此評論是否已被編輯。 - hidden (
bool) — 此評論是否已被隱藏。
討論/拉取請求中的一條評論。
DiscussionEvent 的子類。
class huggingface_hub.DiscussionStatusChange
< source >( id: str type: str created_at: datetime author: str _event: dict new_status: str )
引數
- id (
str) — 事件 ID。一個十六進位制字串。 - type (
str) — 事件的型別。 - created_at (
datetime) — 一個包含事件建立時間戳的datetime物件。 - author (
str) — Discussion/Pull Request 的作者使用者名稱。如果使用者已被刪除,則可以為"deleted"。 - new_status (
str) — 更改後的 Discussion/Pull Request 狀態。可以是以下之一:"open""closed""merged"(僅限 Pull Requests)
Discussion/Pull Request 狀態的更改。
DiscussionEvent 的子類。
class huggingface_hub.DiscussionCommit
< source >( id: str type: str created_at: datetime author: str _event: dict summary: str oid: str )
引數
- id (
str) — 事件 ID。十六進位制字串。 - type (
str) — 事件的型別。 - created_at (
datetime) — 一個包含事件建立時間戳的datetime物件。 - author (
str) — Discussion/Pull Request 的作者使用者名稱。如果使用者已被刪除,則可以為"deleted"。 - summary (
str) — commit 的摘要。 - oid (
str) — commit 的 OID/SHA,以十六進位制字串表示。
Pull Request 中的一個 commit。
DiscussionEvent 的子類。
class huggingface_hub.DiscussionTitleChange
< source >( id: str type: str created_at: datetime author: str _event: dict old_title: str new_title: str )
引數
- id (
str) — 事件 ID。十六進位制字串。 - type (
str) — 事件的型別。 - created_at (
datetime) — 一個包含事件建立時間戳的datetime物件。 - author (
str) — Discussion/Pull Request 的作者使用者名稱。如果使用者已被刪除,則可以為"deleted"。 - old_title (
str) — Discussion/Pull Request 的先前標題。 - new_title (
str) — 新標題。
Discussion/Pull Request 的重新命名事件。
DiscussionEvent 的子類。