Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] Run test suite on arbitrary coiled environments #296

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
83 changes: 60 additions & 23 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,17 @@ jobs:
fail-fast: false
matrix:
python-version: ["3.8", "3.9", "3.10"]
# A/B TESTING: add AB_<name> as needed. Alternatively you may use 'include'
# statements.
# For each A/B runtime version there must be two files:
# - AB_environment/AB_<name>.conda.yaml
# - AB_environment/AB_<name>.dask.yaml
# Search for "A/B TESTING" for further change points in this file
runtime-version: [latest]
# TODO comment out before merge
include:
- python-version: "3.9"
runtime-version: AB_sample

steps:
- uses: actions/checkout@v2
Expand Down Expand Up @@ -75,7 +86,7 @@ jobs:
export PYTHON_VERSION_FORMATTED=$(echo "${{ matrix.python-version }}" | sed 's/\.//g' )
export REF_NAME_FORMATTED=$(echo "$GITHUB_REF_NAME" | sed 's/\./-/g' )
export COILED_SOFTWARE_NAME_HEAD=dask-engineering/coiled-runtime-${{ github.event_name }}
export COILED_SOFTWARE_NAME_TAIL=$GITHUB_RUN_ID-py$PYTHON_VERSION_FORMATTED
export COILED_SOFTWARE_NAME_TAIL=$GITHUB_RUN_ID-${{ matrix.runtime-version }}-py$PYTHON_VERSION_FORMATTED

if [[ ${{ github.event_name }} = 'pull_request' ]]
then
Expand All @@ -84,24 +95,33 @@ jobs:
export COILED_SOFTWARE_NAME=$COILED_SOFTWARE_NAME_HEAD-$GITHUB_REF_TYPE-$REF_NAME_FORMATTED-$COILED_SOFTWARE_NAME_TAIL
fi

# Create conda environment.yaml file for the latest software environment
python ci/create_latest_runtime_meta.py
export ENV_FILE=latest.yaml
if [[ ${{ matrix.runtime-version }} = 'latest' ]]
then
# Create conda environment.yaml file for the latest software environment
python ci/create_latest_runtime_meta.py
export COILED_SOFTWARE_ENV=""
else
cp AB_environments/${{ matrix.runtime-version }}.conda.yaml coiled_software_environment.yaml
export COILED_SOFTWARE_ENV=$(python ci/dask_config_to_env.py AB_environments/${{ matrix.runtime-version }}.dask.yaml)
fi

export ENV_FILE=coiled_software_environment.yaml
cat $ENV_FILE

mamba install coiled
echo "Creating Coiled software environment for $COILED_SOFTWARE_NAME"
coiled env create --name $COILED_SOFTWARE_NAME --conda $ENV_FILE
echo "Environment parameters: $COILED_SOFTWARE_ENV"
coiled env create --name $COILED_SOFTWARE_NAME --conda $ENV_FILE $COILED_SOFTWARE_ENV

# Put COILED_SOFTWARE_NAME into a file so it can be downloaded in subsequent workflow jobs
echo $COILED_SOFTWARE_NAME > software_name.txt

- name: Upload environment file
uses: actions/upload-artifact@v3
with:
name: software-environment-py${{ matrix.python-version }}
name: software-environment-${{ matrix.runtime-version }}-py${{ matrix.python-version }}
path: |
latest.yaml
coiled_software_environment.yaml
software_name.txt
test_upstream.txt

Expand All @@ -113,9 +133,14 @@ jobs:
strategy:
fail-fast: false
matrix:
os: ["ubuntu-latest"]
os: [ubuntu-latest]
python-version: ["3.9"]
runtime-version: ["latest", "0.0.4", "0.1.0"]
# A/B TESTING: add AB_<name> as needed (as specified in 'software')
# and remove what is not interesting for the test.
# You may also want to use include/exclude statements for specific
# combinations of python versions and OSs.
# runtime-version: [latest, "0.0.4", "0.1.0", AB_sample]
runtime-version: [latest, "0.0.4", "0.1.0", AB_sample] # TODO revert before merging

steps:
- uses: actions/checkout@v2
Expand All @@ -132,10 +157,10 @@ jobs:
environment-file: ci/environment.yml

- name: Download software environment assets
if: matrix.runtime-version == 'latest'
if: matrix.runtime-version == 'latest' || startsWith(matrix.runtime-version, 'AB_')
uses: actions/download-artifact@v3
with:
name: software-environment-py${{ matrix.python-version }}
name: software-environment-${{ matrix.runtime-version }}-py${{ matrix.python-version }}

- name: Install coiled-runtime
env:
Expand Down Expand Up @@ -168,9 +193,14 @@ jobs:
strategy:
fail-fast: false
matrix:
os: ["ubuntu-latest"]
os: [ubuntu-latest]
python-version: ["3.9"]
runtime-version: ["latest", "0.0.4", "0.1.0"]
# A/B TESTING: add AB_<name> as needed (as specified in 'software')
# and remove what is not interesting for the test.
# Alternatively you may use include/exclude statements for specific
# combinations of python versions and OSs.
# runtime-version: [latest, "0.0.4", "0.1.0", AB_sample]
runtime-version: [latest, "0.0.4", "0.1.0", AB_sample] # TODO revert before merging

steps:
- uses: actions/checkout@v2
Expand All @@ -187,10 +217,10 @@ jobs:
environment-file: ci/environment.yml

- name: Download software environment assets
if: matrix.runtime-version == 'latest'
if: matrix.runtime-version == 'latest' || startsWith(matrix.runtime-version, 'AB_')
uses: actions/download-artifact@v3
with:
name: software-environment-py${{ matrix.python-version }}
name: software-environment-${{ matrix.runtime-version }}-py${{ matrix.python-version }}

- name: Install coiled-runtime
env:
Expand Down Expand Up @@ -223,16 +253,23 @@ jobs:
strategy:
fail-fast: false
matrix:
os: ["ubuntu-latest"]
os: [ubuntu-latest]
python-version: ["3.8", "3.9", "3.10"]
runtime-version: ["latest", "0.0.4", "0.1.0"]
# A/B TESTING: add AB_<name> as needed (as specified in 'software')
# and remove what is not interesting for the test.
# Alternatively you may use include/exclude statements for specific
# combinations of python versions and OSs.
runtime-version: [latest, "0.0.4", "0.1.0"]
include:
- python-version: "3.9"
runtime-version: "latest"
os: "windows-latest"
runtime-version: latest
os: windows-latest
- python-version: "3.9"
runtime-version: "latest"
os: "macos-latest"
runtime-version: latest
os: macos-latest
# TODO comment out before merging
- python-version: "3.9"
runtime-version: AB_sample

steps:
- uses: actions/checkout@v2
Expand All @@ -249,10 +286,10 @@ jobs:
environment-file: ci/environment.yml

- name: Download software environment assets
if: matrix.runtime-version == 'latest'
if: matrix.runtime-version == 'latest' || startsWith(matrix.runtime-version, 'AB_')
uses: actions/download-artifact@v3
with:
name: software-environment-py${{ matrix.python-version }}
name: software-environment-${{ matrix.runtime-version }}-py${{ matrix.python-version }}

- name: Install coiled-runtime
env:
Expand Down
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,9 @@ venv.bak/
# Rope project settings
.ropeproject

# PyCharm project settings
.idea

# mkdocs documentation
/site

Expand Down
16 changes: 16 additions & 0 deletions AB_environments/AB_sample.conda.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Sample conda environment file for A/B testing
# It *must* be called AB_<name>.conda.yaml
# and *must* be accompanied by AB_<name>.dask.yaml
channels:
- conda-forge
dependencies:
- python=3.9
# Alternatively, we could use a nightly build, or no coiled-runtime at all
- coiled-runtime=0.1.0
- pip:
# Notes:
# - You can't install anything with conda which conflicts the versions
# pinned in coiled-runtime. Pip packages ignore these restrictions.
# - You can point to your own git fork instead
- dask==2022.8.1
- git+https://github.com/dask/distributed@dd81b424971e81616e1a52fa09ce4698a5002d41
7 changes: 7 additions & 0 deletions AB_environments/AB_sample.dask.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Sample dask config file for A/B testing
# It *must* be called AB_<name>.dask.yaml
# and *must* be accompanied by AB_<name>.conda.yaml
# Leave empty if you don't want to override anything.
distributed:
scheduler:
worker-saturation: 1.2
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The alternative to forcing the developer to create an empty file every time was to ignore the file if it doesn't exist, but the risk of misspellings producing unexpected results was too high. Explicit is better than implicit.

2 changes: 1 addition & 1 deletion ci/create_latest_runtime_meta.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ def main():
"channels": ["conda-forge"],
"dependencies": requirements,
}
with open("latest.yaml", "w") as f:
with open("coiled_software_environment.yaml", "w") as f:
yaml.dump(env, f)


Expand Down
38 changes: 38 additions & 0 deletions ci/scripts/dask_config_to_env.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
#!/usr/bin/env python
"""Read a dask config file and print it out in the format `-e ENV=VALUE ENV=VALUE ...`
This script is a work-around to not being able to upload dask config files to
`conda env create`.
"""
from __future__ import annotations

import sys
from typing import Iterator

import yaml


def main(fname: str) -> None:
with open(fname) as fh:
cfg = yaml.safe_load(fh)
# Print nothing in case of empty file, comments only, or empty dict
if cfg:
print("-e " + " ".join(traverse(cfg, [])))


def traverse(node: dict | list | str | float | None, path: list[str]) -> Iterator[str]:
if isinstance(node, dict):
for k, v in node.items():
k = k.upper().replace("-", "_")
yield from traverse(v, path + [k])
return

if not path:
raise ValueError("The top-level element must be a dict")
if isinstance(node, str) and "'" in node:
raise ValueError("Unsupported character: ' (single quote)")

yield "'DASK_" + "__".join(path) + f"={node}'"


if __name__ == "__main__":
main(sys.argv[1])
6 changes: 3 additions & 3 deletions ci/scripts/install_coiled_runtime.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ set -o errexit
set -o nounset
set -o xtrace

if [[ "$COILED_RUNTIME_VERSION" = 'latest' ]]
if [[ "$COILED_RUNTIME_VERSION" =~ latest|AB_ ]]
then
cat latest.yaml
mamba env update --file latest.yaml
cat coiled_software_environment.yaml
mamba env update --file coiled_software_environment.yaml
else
mamba install -c conda-forge coiled-runtime=$COILED_RUNTIME_VERSION
fi
Expand Down
2 changes: 1 addition & 1 deletion ci/scripts/run_tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ set -o xtrace
BENCHMARK="${BENCHMARK:-false}"

# Ensure we run additional tests when testing the latest coiled-runtime
if [[ $COILED_RUNTIME_VERSION = 'latest' ]]
if [[ "$COILED_RUNTIME_VERSION" =~ latest|AB_ ]]
then
EXTRA_OPTIONS="--run-latest"
export COILED_SOFTWARE_NAME=$(cat software_name.txt)
Expand Down