开发

此页面提供有关如何构建、测试和开发 dask-gateway 的信息。

构建 Dask-Gateway

克隆仓库

克隆 Dask-Gateway 的 git 仓库

$ git clone https://github.com/dask/dask-gateway.git

安装依赖项 (Conda)

我们推荐使用 Conda 包管理器来设置您的开发环境。这里我们设置一个 conda 环境来包含构建依赖项。

# Create a new conda environment
$ conda create -n dask-gateway

# Activate environment
$ conda activate dask-gateway

# Install dependencies
$ conda install -c conda-forge \
    cryptography \
    tornado \
    traitlets \
    sqlalchemy \
    dask

除了上述依赖项,您还需要一个 Go 编译器。您可以使用系统包管理器、Go 网站或 Conda 来安装 Go。

$ conda install -c conda-forge go

安装依赖项 (Pip)

您也可以使用 pip 设置开发环境。

$ pip install \
    cryptography \
    tornado \
    traitlets \
    sqlalchemy \
    dask

除了上述依赖项,您还需要一个 Go 编译器。您可以使用系统包管理器或 Go 网站来安装 Go。

(可选) 通过 Conda 环境文件安装依赖项

您可以轻松地使用 dev-environment.yaml 环境文件安装本地开发所需的所有依赖项

$ conda env create --file dev-environment.yaml

构建并安装 Dask-Gateway

Dask-Gateway 由两个包组成,两者都包含在同一个仓库中

  • dask-gateway-server: 网关服务器,位于 dask-gateway-server 子目录中。

  • dask-gateway: 网关客户端,位于 dask-gateway 子目录中。

下面的安装说明假设您在仓库的顶层目录中。

构建 dask-gateway-server

# Build and install dask-gateway-server as an editable package
$ pip install -e ./dask-gateway-server

# or, build and install as a regular package
$ pip install ./dask-gateway-server

构建 dask-gateway

# Build and install dask-gateway as an editable package
$ pip install -e ./dask-gateway

# or, build and install as a regular package
$ pip install ./dask-gateway

运行测试

测试位于 tests 子目录中,并测试两个包。要运行测试,您还需要安装 pytest

# Install pytest with conda
$ conda install -c conda-forge pytest

# Or install with pip
$ pip install pytest

然后可以按如下方式运行测试

# Run the test suite
$ pytest -v tests

除了主要的测试之外,针对各种后端的额外测试在 docker 中运行(或者对于 kubernetes 在 minikube 中运行)。用于设置这些测试环境的脚本位于 continuous_integration 子目录中

  • Hadoop 测试:continuous_integration/docker/hadoop

  • PBS 测试:continuous_integration/docker/pbs

  • Slurm 测试:continuous_integration/docker/slurm

  • Kubernetes 测试:continuous_integration/kubernetes

每种设置的具体细节不同,请参阅 .github/workflows/test.yaml 文件了解具体信息。

构建文档

Dask-Gateway 使用 Sphinx 生成文档。源文件位于 dask-gateway/docs/source。要在本地构建文档,首先安装文档构建所需的依赖项。请注意,使用 autodoc-traits 检查 Python 源代码,这使得我们需要安装 autodoc-traits 后列出的包来生成完整的配置参考。

# Install docs dependencies with conda
$ conda install -c conda-forge sphinx dask-sphinx-theme sphinx-autobuild autodoc-traits kubernetes_asyncio skein sqlalchemy

# Or install with pip
$ pip install sphinx dask-sphinx-theme sphinx-autobuild autodoc-traits kubernetes_asyncio skein sqlalchemy

然后使用 make 构建文档

# Running from the dask-gateway/docs folder
$ make html

生成的 HTML 文件位于 _build/html 目录中。

然后考虑使用另一个 make 命令来重新构建文档并刷新浏览器查看构建好的文档。

# Running from the dask-gateway/docs folder
$ make devenv