기여자로 시작하기

전제 조건

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
    
  2. Create and activate a Python virtual environment for development. See Set up a virtual env for detailed instructions.

    One way to do this is by using pyenv and pyenv-virtualenv. You can also optionally install a specific Python version using pyenv if you haven’t already installed your desired version:

    $ pyenv install <your-python-version>
    $ pyenv virtualenv <your-python-version> <your-env-name>
    $ pyenv activate <your-env-name>
    
  3. Install Poetry, which is used to manage dependencies and development workflows:

    (your-env-name) $ pip install poetry==1.7.1
    
  4. Navigate to the framework directory and install the Flower project in development mode, including all optional dependencies:

    (your-env-name) $ cd framework
    (your-env-name) $ python -m poetry install --all-extras
    

편의 스크립트

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:

ProtoBuf 정의 컴파일

$ python -m flwr_tool.protoc

자동 포맷 코드

$ ./framework/dev/format.sh

린터 및 테스트 실행

$ ./framework/dev/test.sh

사전 커밋 훅 추가

Developers may integrate a pre-commit hook into their workflow utilizing the pre-commit library. The pre-commit hook is configured to execute two primary operations: ./framework/dev/format.sh and ./framework/dev/test.sh scripts.

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

  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:

$ ./framework/dev/build.sh

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

문서 빌드

Flower’s documentation uses Sphinx. To build the documentation locally, run the following script:

$ ./framework/dev/build-docs.sh

This will generate HTML documentation in ./framework/doc/build/html.

Note that, in order to build the documentation locally, Pandoc needs to be installed on the system.