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
< source >( 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
) — 讨论 / 拉取请求的创建时间。 - endpoint (
str
) — Hub 的终端节点。 默认为 https://huggingface.co。 - git_reference (
str
, 可选) — (属性) 如果这是拉取请求,则更改可以推送到的 Git 引用,否则为 None。 - url (
str
) — (属性) Hub 上讨论的 URL。
Hub 上的讨论或拉取请求。
此数据类不应直接实例化。
class huggingface_hub.DiscussionWithDetails
< source >( 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: typing.List[ForwardRef('DiscussionEvent')] conflicting_files: typing.Union[typing.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 (
list
of DiscussionEvent) — 此讨论或拉取请求中的DiscussionEvents
列表。 - conflicting_files (
Union[List[str], bool, None]
, 可选) — 如果这是拉取请求,则为冲突文件列表。 如果self.is_pull_request
为False
,则为None
。 如果存在冲突文件但无法检索列表,则为True
。 - target_branch (
str
, 可选) — 如果这是拉取请求,则更改要合并到的分支。 如果self.is_pull_request
为False
,则为None
。 - merge_commit_oid (
str
, 可选) — 如果这是一个已合并的拉取请求,则设置为合并提交的 OID / SHA,否则为None
。 - diff (
str
, 可选) — 如果这是拉取请求,则为 git diff,否则为None
。 - endpoint (
str
) — Hub 的端点。 默认值为 https://huggingface.co。 - git_reference (
str
, 可选) — (属性) 如果这是一个拉取请求,则更改可以推送到的 Git 引用,否则为None
。 - url (
str
) — (属性) 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
) — 讨论/拉取请求作者的用户名。如果用户已被删除,则可以是"deleted"
。 - new_status (
str
) — 更改后讨论/拉取请求的状态。它可以是以下之一:"open"
"closed"
"merged"
(仅用于拉取请求)
讨论/拉取请求中的状态更改。
的子类 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
) — 讨论/拉取请求作者的用户名。如果用户已被删除,则可以是"deleted"
。 - summary (
str
) — commit 的摘要。 - oid (
str
) — commit 的 OID / SHA,为十六进制字符串。
拉取请求中的一个 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
) — 讨论/拉取请求作者的用户名。如果用户已被删除,则可以是"deleted"
。 - old_title (
str
) — 讨论/拉取请求之前的标题。 - new_title (
str
) — 新标题。
讨论/拉取请求中的重命名事件。
的子类 DiscussionEvent。