Hub Python Library documentation

与讨论和拉取请求进行交互

Hugging Face's logo
Join the Hugging Face community

and get access to the augmented documentation experience

to get started

与讨论和拉取请求进行交互

请查阅 HfApi 文档页面,以获取用于与 Hub 上的 Pull Requests 和 Discussions 进行交互的方法参考。

数据结构

类 huggingface_hub.Discussion

< >

( title: strstatus: typing.Literal['open', 'closed', 'merged', 'draft']num: intrepo_id: strrepo_type: strauthor: stris_pull_request: boolcreated_at: datetimeendpoint: str )

参数

  • title (str) — 讨论 / 拉取请求的标题
  • status (str) — Discussion / Pull Request 的状态。 必须是以下之一:
    • "open"
    • "closed"
    • "merged"(仅适用于 Pull Requests)
    • "draft"(仅适用于 Pull Requests)
  • num (int) — 讨论 / 拉取请求的编号。
  • repo_id (str) — 该 Discussion / Pull Request 所打开的仓库的 id("{namespace}/{repo_name}")。
  • repo_type (str) — 该 Discussion / Pull Request 所打开的仓库类型。 可能的值为:"model"、"dataset"、"space"。
  • author (str) — 讨论 / 拉取请求作者的 username。 如果该用户此后已被删除,则可能为 "deleted"。
  • is_pull_request (bool) — 是否为 Pull Request。
  • created_at (datetime) — 讨论 / 拉取请求的创建datetime。
  • endpoint (str) — Hub 的端点。默认为 https://huggingface.co。
  • git_reference (str, 可选) — (属性)如果这是一个 Pull Request,则更改可以推送到的 Git 引用,否则为 None。
  • url (str) — (属性)Hub 上该讨论的 URL。

Hub 上的讨论或拉取请求。

此 dataclass 不打算直接实例化。

类 huggingface_hub.DiscussionWithDetails

< >

( 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 )

参数

  • title (str) — 讨论 / 拉取请求的标题
  • status (str) — Discussion / Pull Request 的状态。 可以是以下之一:
    • "open"
    • "closed"
    • "merged"(仅适用于 Pull Requests)
    • "draft"(仅适用于 Pull Requests)
  • num (int) — 讨论 / 拉取请求的编号。
  • repo_id (str) — 该 Discussion / Pull Request 所打开的仓库的 id("{namespace}/{repo_name}")。
  • repo_type (str) — 该 Discussion / Pull Request 所打开的仓库类型。 可能的值为:"model"、"dataset"、"space"。
  • author (str) — 讨论 / 拉取请求作者的 username。 如果该用户此后已被删除,则可能为 "deleted"。
  • is_pull_request (bool) — 是否为 Pull Request。
  • created_at (datetime) — 讨论 / 拉取请求的创建datetime。
  • events (list of DiscussionEvent) — 此 Discussion 或 Pull Request 中的 DiscussionEvents 列表。
  • conflicting_files (Union[list[str], bool, None], 可选) — 如果这是一个 Pull Request,则为冲突文件列表。 如果 self.is_pull_request 为 False,则为 None。 如果存在冲突文件但无法获取列表,则为 True。
  • target_branch (str, 可选) — 如果这是一个 Pull Request,则是要合并更改的目标分支。如果 self.is_pull_request 为 False,则为 None。
  • merge_commit_oid (str, 可选) — 如果这是一个已合并的 Pull Request,则设置为合并提交的 OID / SHA,否则为 None。
  • diff (str, 可选) — 如果这是一个 Pull Request,则为 git diff,否则为 None。
  • endpoint (str) — Hub 的端点。默认为 https://huggingface.co。
  • git_reference (str, 可选) — (属性)如果这是一个 Pull Request,则更改可以推送到的 Git 引用,否则为 None。
  • url (str) — (属性)Hub 上该讨论的 URL。

Discussion 的子类。

类 huggingface_hub.DiscussionEvent

< >

( id: strtype: strcreated_at: datetimeauthor: str_event: dict )

参数

  • id (str) — 事件的 ID。一个十六进制字符串。
  • type (str) — 事件的类型。
  • created_at (datetime) — 一个 datetime 对象,保存该事件的创建时间戳。
  • author (str) — 讨论 / 拉取请求作者的 username。 如果该用户此后已被删除,则可能为 "deleted"。

讨论或拉取请求中的事件。

使用具体类:

类 huggingface_hub.DiscussionComment

< >

( id: strtype: strcreated_at: datetimeauthor: str_event: dictcontent: stredited: boolhidden: bool )

参数

  • id (str) — 事件的 ID。一个十六进制字符串。
  • type (str) — 事件的类型。
  • created_at (datetime) — 一个 datetime 对象,保存该事件的创建时间戳。
  • author (str) — 讨论 / 拉取请求作者的 username。 如果该用户此后已被删除,则可能为 "deleted"。
  • content (str) — 评论的原始 Markdown 内容。提及、链接和图片不会被渲染。
  • edited (bool) — 此评论是否已被编辑。
  • hidden (bool) — 此评论是否已被隐藏。

讨论 / 拉取请求中的评论。

DiscussionEvent 的子类。

类 huggingface_hub.DiscussionStatusChange

< >

( id: strtype: strcreated_at: datetimeauthor: str_event: dictnew_status: str )

参数

  • id (str) — 事件的 ID。一个十六进制字符串。
  • type (str) — 事件的类型。
  • created_at (datetime) — 一个 datetime 对象,保存该事件的创建时间戳。
  • author (str) — 讨论 / 拉取请求作者的 username。 如果该用户此后已被删除,则可能为 "deleted"。
  • new_status (str) — 更改后 Discussion / Pull Request 的状态。 可以是以下之一:
    • "open"
    • "closed"
    • "merged"(仅适用于 Pull Requests)

讨论 / 拉取请求中的状态变更。

DiscussionEvent 的子类。

类 huggingface_hub.DiscussionCommit

< >

( id: strtype: strcreated_at: datetimeauthor: str_event: dictsummary: stroid: str )

参数

  • id (str) — 事件的 ID。一个十六进制字符串。
  • type (str) — 事件的类型。
  • created_at (datetime) — 一个 datetime 对象,保存该事件的创建时间戳。
  • author (str) — 讨论 / 拉取请求作者的 username。 如果该用户此后已被删除,则可能为 "deleted"。
  • summary (str) — 提交的摘要。
  • oid (str) — 提交(commit)的 OID / SHA,以十六进制字符串形式表示。

Pull Request 中的提交。

DiscussionEvent 的子类。

类 huggingface_hub.DiscussionTitleChange

< >

( id: strtype: strcreated_at: datetimeauthor: str_event: dictold_title: strnew_title: str )

参数

  • id (str) — 事件的 ID。一个十六进制字符串。
  • type (str) — 事件的类型。
  • created_at (datetime) — 一个 datetime 对象,保存该事件的创建时间戳。
  • author (str) — 讨论 / 拉取请求作者的 username。 如果该用户此后已被删除,则可能为 "deleted"。
  • old_title (str) — 讨论 / 拉取请求的旧标题。
  • new_title (str) — 新标题。

讨论 / 拉取请求中的重命名事件。

DiscussionEvent 的子类。

Update on GitHub