agentic_huge_data_base / wiki
页面 Argilla · 5.2 贡献工作流·DeepWiki 中文全文译文

5.2 · 贡献工作流(Contribution Workflow)

人工复核与反馈数据 · 聚焦本章的模块关系、源码依据与实现要点。

项目Argilla 章节5.2 状态全文译文 模块安装与启动、测试、发布与运维、界面与交互、接口与服务契约
源码线索
  • .github/workflows/argilla-frontend.build-push-dev-frontend-docker.yml
  • .github/workflows/argilla-frontend.deploy-environment.yml
  • .github/workflows/argilla-frontend.yml
  • .github/workflows/argilla-server.yml
  • .github/workflows/argilla-v1.yml
  • .github/workflows/argilla.docs.yml
  • .github/workflows/argilla.yml
  • .github/workflows/close-inactive-issues-bot.yml
  • docs/_source/.readthedocs.yaml
  • docs/_source/_common/tabs/argilla_install_python.md
模块标签
  • 安装与启动
  • 测试、发布与运维
  • 界面与交互
  • 接口与服务契约
  • 工作流与编排

章节正文

贡献工作流

贡献工作流

相关源文件

本章引用的主要源码文件:

  • .github/workflows/argilla-frontend.build-push-dev-frontend-docker.yml
  • .github/workflows/argilla-frontend.deploy-environment.yml
  • .github/workflows/argilla-frontend.yml
  • .github/workflows/argilla-server.yml
  • .github/workflows/argilla-v1.yml
  • .github/workflows/argilla.docs.yml
  • .github/workflows/argilla.yml
  • .github/workflows/close-inactive-issues-bot.yml
  • docs/_source/.readthedocs.yaml
  • docs/_source/_common/tabs/argilla_install_python.md
  • docs/_source/_static/images/og-doc.png
  • docs/_source/_templates/page.html
  • docs/_source/community/contributing.md
  • docs/_source/community/developer_docs.md
  • docs/_source/community/migration-rubrix.md
  • docs/_source/conf.py
  • docs/_source/getting_started/installation/deployments/docker.md
  • docs/_source/getting_started/installation/deployments/docker_compose.md
  • docs/_source/getting_started/installation/deployments/python.md
  • docs/_source/getting_started/quickstart.md
  • docs/_source/reference/cli.md
  • docs/_source/reference/notebooks.rst
  • docs/_source/reference/python/python_client.rst
  • docs/_source/reference/python/python_training.rst
  • docs/_source/requirements.txt
  • docs/migration-rubrix.md
  • docs/template.ipynb

本文档详细介绍了向 Argilla 项目贡献代码的流程,涵盖从搭建开发环境到将代码合并到主仓库的整个过程。有关配置开发环境的详细说明,请参阅开发环境搭建

前置条件

在向 Argilla 贡献代码之前,请确保您已完成以下操作:

  1. 了解仓库结构
    • argilla/:Python SDK
    • argilla-server/:FastAPI 服务器
    • argilla-frontend/:Vue.js 用户界面
    • docs/:文档
  1. 加入社区:通过 Discord 与团队和其他贡献者联系。
  1. 搭建环境:按照开发环境搭建中的说明配置您的开发环境。

来源: docs/_source/community/contributing.md docs/_source/community/developer_docs.md

贡献流程概览

下图展示了贡献工作流的高层概览:

Argilla · 贡献流程概览 · 图 1
Argilla · 贡献流程概览 · 图 1

来源: docs/_source/community/contributing.md

第一步:Fork 和克隆

  1. Fork 仓库:访问 Argilla GitHub 仓库并点击 "Fork" 按钮。
  1. 克隆您的 Fork
   git clone https://github.com/[您的 GitHub 用户名]/argilla.git
   cd argilla
  1. 添加上游远程仓库
   git remote add upstream https://github.com/argilla-io/argilla.git

来源: docs/_source/community/contributing.md:80-87

第二步:创建分支

为每个要解决的问题创建一个新分支,并使用适当的前缀:

# 对于代码修改,使用 develop 作为基础分支
git checkout develop
git pull upstream develop
git checkout -b feature/您的功能名称

# 对于文档修改,使用 main 作为基础分支
git checkout main
git pull upstream main
git checkout -b docs/您的文档修改
注意:仅文档修改使用 main 分支。所有其他修改请使用 develop 分支。

来源: docs/_source/community/contributing.md:94-110

第三步:进行修改

  1. 实现您的修改:进行必要的代码修改。
  2. 遵循编码规范:运行 pre-commit 以确保代码格式正确。
  3. 添加测试:为您的修改添加单元测试/集成测试。
  4. 更新 CHANGELOG.md:在相应部分下添加条目:
- 修复了 `init` 方法的键错误([#123](链接到 PR))。由 @github_handle 贡献。

来源: docs/_source/community/contributing.md:117-134

第四步:测试

在提交之前,请确保所有测试通过:

对于 Python SDK:

pytest tests/unit
pytest tests/integration

对于服务器:

cd argilla-server
pdm test test/unit

对于前端:

cd argilla-frontend
npm run test

来源: docs/_source/community/developer_docs.md:362-399

第五步:提交拉取请求

  1. 推送您的分支
   git push origin 您的分支名称
  1. 创建拉取请求:访问 GitHub,针对适当的基础分支(代码修改使用 develop,文档修改使用 main)创建 PR。
  1. 填写 PR 模板:添加描述性标题并使用适当的前缀(feat:bug:docs:),关联相关问题,并描述您的修改。
  1. 添加标签:为您的 PR 添加相关标签(例如 featurebugdocumentation)。

来源: docs/_source/community/contributing.md:166-195

持续集成与持续交付管线

当您提交 PR 时,GitHub Actions 会自动运行多个 CI/CD 工作流:

Argilla · 持续集成与持续交付管线 · 图 2
Argilla · 持续集成与持续交付管线 · 图 2

CI/CD 管线根据受影响的组件运行不同的工作流:

  1. SDK 管线.github/workflows/argilla.yml):
    • argilla/ 中的文件发生更改时触发
    • 使用多个 Python 版本(3.9-3.13)测试 SDK
    • 构建 SDK 包
    • 如果在 main 分支上,则发布到 PyPI
  1. 服务器管线.github/workflows/argilla-server.yml):
    • argilla-server/ 中的文件发生更改时触发
    • 设置测试服务(Elasticsearch、PostgreSQL、Redis)
    • 构建服务器包和 Docker 镜像
    • 如果在 main 分支上,则发布到 PyPI 和 Docker Hub
  1. 前端管线.github/workflows/argilla-frontend.yml):
    • argilla-frontend/ 中的文件发生更改时触发
    • 运行 linting 和测试
    • 构建前端资源
  1. 文档管线.github/workflows/argilla.docs.yml):
    • 当文档文件发生更改或打标签时触发
    • 构建并部署文档到相应版本

来源: .github/workflows/argilla.yml .github/workflows/argilla-server.yml .github/workflows/argilla-frontend.yml .github/workflows/argilla.docs.yml

评审流程

CI 检查通过后,维护者将评审您的 PR。他们可能会:

  1. 请求修改:要求对您的代码进行修改。
  2. 批准:按原样批准您的 PR。
  3. 评论:提供一般性反馈,但不明确批准或拒绝。

处理评审意见的步骤:

  1. 在您的分支上进行请求的修改。
  2. 将修改推送到您的 Fork。
  3. 回复评审意见,说明您已进行的修改。

一旦 PR 获得批准且所有检查通过,维护者将合并您的 PR,通常使用 squash 和 merge 策略以保持提交历史的整洁。

来源: docs/_source/community/contributing.md:193-204

开发环境搭建

下图说明了搭建开发环境的过程:

Argilla · 开发环境搭建 · 图 3
Argilla · 开发环境搭建 · 图 3
关键搭建步骤:
  1. 安装依赖
   # 对于 Python SDK
   cd argilla
   pip install -e .

   # 对于包含所有扩展的服务器
   pip install -e ".[server,listeners,postgresql,integrations,tests]"

   # 对于代码格式化
   pip install pre-commit
   pre-commit install

   # 对于前端
   cd argilla-frontend
   npm install
  1. 设置数据库
    • Elasticsearch:用于向量存储(必需)
    • Redis:用于任务队列(必需)
    • PostgreSQL(可选):替代 SQLite 用于关系数据
  1. 运行数据库迁移
   argilla server database migrate
   argilla server database users create_default
  1. 启动服务
   # 启动服务器
   argilla server start

   # 启动前端(在另一个终端中)
   cd argilla-frontend
   npm run dev

来源: docs/_source/community/developer_docs.md:152-351

组件特定指南

组件基础分支测试命令受影响文件
SDKdeveloppytest tests/unit tests/integrationargilla/**
服务器developpdm test test/unitargilla-server/**
前端developnpm run testargilla-frontend/**
文档mainsphinx-autobuild docs/_source docs/_build/htmldocs/_source/**

来源: docs/_source/community/developer_docs.md docs/_source/community/contributing.md

PR 最佳实践

  1. 保持 PR 聚焦:每个 PR 只解决一个问题或功能。
  2. 包含测试:为您的修改添加或更新测试。
  3. 更新文档:保持文档与代码修改同步。
  4. 使用适当的前缀
    • PR:在标题中使用 feat:bug:docs: 前缀
    • 分支:使用 feature/bug/docs/ 前缀
  5. 关联问题:始终在 PR 描述中引用相关问题
  6. 编写有意义的提交信息:使用清晰且描述性的提交信息
  7. 应用标签:为您的 PR 添加适当标签以便于分类

来源:

  • docs/_source/community/contributing.md
  • .github/workflows/argilla.yml
  • .github/workflows/argilla-server.yml
  • .github/workflows/argilla-frontend.yml
  • .github/workflows/argilla.docs.yml