기여자로 시작하기

전제 조건

Flower uses pyproject.toml to manage dependencies and configure development tools (the ones which support it). Poetry is a build tool which supports PEP 517.

개발자 머신 설정

Preliminaries

일부 시스템 전체에 대한 의존성이 필요합니다.

macOS의 경우

  • `homebrew <https://brew.sh/>`_를 설치합니다. 설치 후 `brew`를 PATH에 추가하는 작업을 잊지 마세요.

  • Install xz (to install different Python versions) and pandoc to build the docs:

    $ brew install xz pandoc
    

Ubuntu의 경우

Ensure you system (Ubuntu 22.04+) is up-to-date, and you have all necessary packages:

$ apt update
$ apt install build-essential zlib1g-dev libssl-dev libsqlite3-dev \
              libreadline-dev libbz2-dev libffi-dev liblzma-dev pandoc

Flower 개발 환경 만들기

  1. Clone the Flower repository from GitHub:

$ git clone git@github.com:adap/flower.git
$ cd flower
  1. Let’s create the Python environment for all-things Flower. If you wish to use pyenv, we provide two convenience scripts that you can use. If you prefer using something else than pyenv, create a new environment, activate and skip to the last point where all packages are installed.

  • If you don’t have pyenv installed, the following script that will install it, set it up, and create the virtual environment (with Python 3.9.20 by default):

    $ ./dev/setup-defaults.sh <version> # once completed, run the bootstrap script
    
  • If you already have pyenv installed (along with the pyenv-virtualenv plugin), you can use the following convenience script (with Python 3.9.20 by default):

    $ ./dev/venv-create.sh <version> # once completed, run the `bootstrap.sh` script
    

3. Install the Flower package in development mode (think pip install -e) along with all necessary dependencies:

(flower-<version>) $ ./dev/bootstrap.sh

편의 스크립트

The Flower repository contains a number of convenience scripts to make recurring development tasks easier and less error-prone. See the /dev subdirectory for a full list. The following scripts are amongst the most important ones:

가상 환경 생성/삭제

$ ./dev/venv-create.sh <version> # Default is 3.9.20
$ ./dev/venv-delete.sh <version> # Default is 3.9.20

ProtoBuf 정의 컴파일

$ python -m flwr_tool.protoc

자동 포맷 코드

$ ./dev/format.sh

린터 및 테스트 실행

$ ./dev/test.sh

사전 커밋 훅 추가

개발자는 pre-commit 라이브러리를 사용하여 사전 커밋 훅을 워크플로에 통합할 수 있습니다. 사전 커밋 훅은 두 가지 기본 작업을 실행하도록 구성됩니다:./dev/format.sh./dev/test.sh 스크립트.

개발자가 이것을 사용할 수 있는 여러가지 방법이 있습니다:

  1. 간단하게 실행하여 로컬 git 디렉터리에 사전 커밋 훅을 설치하세요:

    $ pre-commit install
    
    • ``git 커밋``은 포맷 및 린팅/테스트 스크립트의 실행을 트리거합니다.

    • If in a hurry, bypass the hook using --no-verify with the git commit command.

      $ git commit --no-verify -m "Add new feature"
      
  2. 훅을 영구적으로 설치하지 않으려는 개발자의 경우 다음 명령을 사용하여 변경 사항을 커밋하기 전에 일회성 검사를 실행할 수 있습니다:

    $ pre-commit run --all-files
    

    이렇게 하면 ``git commit``의 기본 동작을 수정하지 않고 모든 파일에 대해 포맷 및 린팅 검사/테스트를 실행합니다.

로컬에서 Github Action(CI) 실행하기

Developers could run the full set of Github Actions workflows under their local environment by using Act. Please refer to the installation instructions under the linked repository and run the next command under Flower main cloned repository folder:

$ act

Flower 기본 워크플로우는 아래에 필요한 Docker 머신을 설정하여 실행합니다.

릴리즈 빌드

Flower uses Poetry to build releases. The necessary command is wrapped in a simple script:

$ ./dev/build.sh

The resulting .whl and .tar.gz releases will be stored in the /dist subdirectory.

문서 빌드

Flower’s documentation uses Sphinx. There’s no convenience script to re-build the documentation yet, but it’s pretty easy:

$ cd doc
$ make html

그러면 ``doc/build/html``에 HTML 문서가 생성됩니다.

로컬에서 문서를 작성하려면(아래 설명과 같이 ``poetry run make html``로) `Pandoc <https://pandoc.org/installing.html>`_이 시스템에 설치되어 있어야 합니다.