Skip to content

Commit

Permalink
Merge pull request #746 from automl/development
Browse files Browse the repository at this point in the history
Development
  • Loading branch information
mfeurer authored Jul 27, 2021
2 parents 6058475 + 12b3a5b commit 3df3a74
Show file tree
Hide file tree
Showing 81 changed files with 1,347 additions and 962 deletions.
14 changes: 14 additions & 0 deletions .flake8
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
[flake8]
max-line-length = 120
ignore = W605,E402,W503
show-source = True
application-import-names = smac
exclude =
venv
build
.git
__pycache__
doc
build
dist
examples/spear_qcp/*
31 changes: 31 additions & 0 deletions .github/workflows/dist.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: dist-check

on: [push, pull_request]

jobs:
dist:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Setup Python
uses: actions/setup-python@v2
with:
python-version: 3.8
- name: Build dist
run: |
python setup.py sdist
- name: Twine check
run: |
pip install twine
last_dist=$(ls -t dist/smac-*.tar.gz | head -n 1)
twine_output=`twine check "$last_dist"`
if [[ "$twine_output" != "Checking $last_dist: PASSED" ]]; then echo $twine_output && exit 1;fi
- name: Install dist
run: |
last_dist=$(ls -t dist/smac-*.tar.gz | head -n 1)
pip install $last_dist
- name: PEP 561 Compliance
run: |
pip install mypy
cd .. # required to use the installed version of smac
if ! python -c "import smac"; then exit 1; fi
44 changes: 44 additions & 0 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
name: Docs
on: [pull_request, push]

jobs:
build-and-deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Setup Python
uses: actions/setup-python@v2
with:
python-version: 3.8
- name: Install dependencies
run: |
pip install -e .[all]
- name: Make docs
run: |
cd doc
make buildapi
make html
- name: Pull latest gh-pages
if: (contains(github.ref, 'develop') || contains(github.ref, 'master')) && github.event_name == 'push'
run: |
cd ..
git clone https://github.com/automl/SMAC3.git --branch gh-pages --single-branch gh-pages
- name: Copy new doc into gh-pages
if: (contains(github.ref, 'develop') || contains(github.ref, 'master')) && github.event_name == 'push'
run: |
branch_name=${GITHUB_REF##*/}
cd ../gh-pages
rm -rf $branch_name
cp -r ../SMAC3/doc/build/html $branch_name
- name: Push to gh-pages
if: (contains(github.ref, 'develop') || contains(github.ref, 'master')) && github.event_name == 'push'
run: |
last_commit=$(git log --pretty=format:"%an: %s")
cd ../gh-pages
branch_name=${GITHUB_REF##*/}
git add $branch_name/
git config --global user.name 'Github Actions'
git config --global user.email '[email protected]'
git remote set-url origin https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/${{ github.repository }}
git commit -am "$last_commit"
git push
20 changes: 20 additions & 0 deletions .github/workflows/pre-commit.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
name: pre-commit

on: [push, pull_request]

jobs:
run-all-files:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Setup Python 3.7
uses: actions/setup-python@v2
with:
python-version: 3.7
- name: Install pre-commit
run: |
pip install pre-commit
pre-commit install
- name: Run pre-commit
run: |
pre-commit run --all-files
102 changes: 102 additions & 0 deletions .github/workflows/pytest.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
name: Tests

on:
push:
pull_request:
schedule:
# Every Monday at 7AM UTC
- cron: '0 07 * * 1'

jobs:
ubuntu:

runs-on: ubuntu-18.04
strategy:
matrix:
python-version: [3.7, 3.8, 3.9]
use-conda: [true, false]
use-dist: [false]
include:
- python-version: 3.8
code-cov: true
- python-version: 3.7
use-conda: false
use-dist: true
fail-fast: false

steps:
- uses: actions/checkout@v2
- name: Setup Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
# A note on checkout: When checking out the repository that
# triggered a workflow, this defaults to the reference or SHA for that event.
# Otherwise, uses the default branch (master) is used.
with:
python-version: ${{ matrix.python-version }}
- name: Conda Install test dependencies
if: matrix.use-conda == true
run: |
# Miniconda is available in $CONDA env var
$CONDA/bin/conda create -n testenv --yes pip wheel gxx_linux-64 gcc_linux-64 swig python=${{ matrix.python-version }}
$CONDA/envs/testenv/bin/python3 -m pip install --upgrade pip
$CONDA/envs/testenv/bin/pip3 install -e .[all]
- name: Install test dependencies
if: matrix.use-conda == false && matrix.use-dist == false
run: |
python -m pip install --upgrade pip
if [[ `python -c 'import platform; print(platform.python_version())' | cut -d '.' -f 2` -eq 6 ]]; then
# Numpy 1.20 dropped suppert for Python3.6
pip install "numpy<=1.19"
fi
sudo apt-get update
sudo apt-get remove swig
sudo apt-get install swig3.0
sudo ln -s /usr/bin/swig3.0 /usr/bin/swig
pip install -e .[all]
- name: Dist Install test dependencies
if: matrix.use-conda == false && matrix.use-dist == true
run: |
python -m pip install --upgrade pip
sudo apt-get update
sudo apt-get remove swig
sudo apt-get install swig3.0
sudo ln -s /usr/bin/swig3.0 /usr/bin/swig
# We need to install for the dependencies, like pytest
python setup.py sdist
last_dist=$(ls -t dist/smac-*.tar.gz | head -n 1)
pip install $last_dist[all]
- name: Store repository status
id: status-before
run: |
echo "::set-output name=BEFORE::$(git status --porcelain -b)"
- name: Conda Run tests
timeout-minutes: 45
if: matrix.use-conda == true
run: |
# Activate anaconda so default python is from conda
export PATH="$CONDA/envs/testenv/bin:$PATH"
if [ ${{ matrix.code-cov }} ]; then codecov='--cov=smac --cov-report=xml'; fi
$CONDA/envs/testenv/bin/python3 -m pytest --forked --durations=20 --timeout=300 --timeout-method=thread --fulltrace --full-trace -sv $codecov test
- name: Run tests
timeout-minutes: 45
if: matrix.use-conda == false
run: |
if [ ${{ matrix.code-cov }} ]; then codecov='--cov=smac --cov-report=xml'; fi
pytest --forked --durations=20 --timeout=300 --timeout-method=thread --fulltrace --full-trace -sv $codecov test
- name: Check for files left behind by test
if: ${{ always() }}
run: |
before="${{ steps.status-before.outputs.BEFORE }}"
after="$(git status --porcelain -b)"
if [[ "$before" != "$after" ]]; then
echo "git status from before: $before"
echo "git status from after: $after"
echo "Not all generated files have been deleted!"
exit 1
fi
- name: Upload coverage
if: matrix.code-cov && always()
uses: codecov/codecov-action@v1
with:
fail_ci_if_error: true
verbose: true
53 changes: 53 additions & 0 deletions .github/workflows/terminal_examples.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
name: examples

on: [push, pull_request]

jobs:
ubuntu:

runs-on: ubuntu-18.04
strategy:
matrix:
python-version: [3.8]
fail-fast: false

steps:
- uses: actions/checkout@v2
- name: Setup Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: Conda Install test dependencies
run: |
# Miniconda is available in $CONDA env var
$CONDA/bin/conda create -n testenv --yes pip wheel gxx_linux-64 gcc_linux-64 swig python=${{ matrix.python-version }}
$CONDA/envs/testenv/bin/python3 -m pip install --upgrade pip
$CONDA/envs/testenv/bin/pip3 install -e .[all]
- name: Spear QCP SMAC
timeout-minutes: 20
run: |
# Activate anaconda so default python is from conda
export PATH="$CONDA/envs/testenv/bin:$PATH"
cd examples/spear_qcp
bash run_SMAC.sh
- name: Spear QCP ROAR
timeout-minutes: 20
run: |
# Activate anaconda so default python is from conda
export PATH="$CONDA/envs/testenv/bin:$PATH"
cd examples/spear_qcp
bash run_ROAR.sh
- name: Spear QCP Successive halving
timeout-minutes: 20
run: |
# Activate anaconda so default python is from conda
export PATH="$CONDA/envs/testenv/bin:$PATH"
cd examples/spear_qcp
python SMAC4AC_SH_spear_qcp.py
- name: Branin from the command line
timeout-minutes: 20
run: |
# Activate anaconda so default python is from conda
export PATH="$CONDA/envs/testenv/bin:$PATH"
cd examples/branin
python ../../scripts/smac --scenario scenario.txt
22 changes: 21 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ target_algo_runs.json

# Other
.tox
.coverage
.pypirc
.ipynb_checkpoints/
*.ipynb
Expand All @@ -33,3 +32,24 @@ doc/main_options.rst
doc/scenario_options.rst
doc/smac_options.rst
doc/apidoc

# Dask created work space
dask-worker-space

# Python distribution generated files
.eggs

# Unit test / coverage reports
htmlcov/
cover
coverage
htmlcov
.tox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*,cover
.hypothesis/
prof/
31 changes: 31 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
repos:
- repo: https://github.com/pre-commit/mirrors-mypy
rev: v0.761
hooks:
- id: mypy
# We would like to have the following options set,
# but for now we have to use the ones above to get started
# --ignore-missing-imports --strict"
# --disallow-any-unimported"
# --disallow-any-expr"
# --disallow-any-decorated"
# --disallow-any-explicit"
# --disallow-any-generics"
# Add the following once the scenario is removed from the main code or typed
# https://mypy.readthedocs.io/en/stable/command_line.html#configuring-warnings
# --warn-unused-ignores"
args: [--show-error-codes, --ignore-missing-imports, --disallow-untyped-decorators, --disallow-incomplete-defs, --disallow-untyped-defs, --follow-imports, skip]
name: mypy SMAC
files: smac/.*
- repo: https://gitlab.com/pycqa/flake8
rev: 3.8.3
hooks:
- id: flake8
name: flake8 SMAC
files: smac
- id: flake8
name: flake8 test
files: test
- id: flake8
name: flake8 examples
files: examples
Loading

0 comments on commit 3df3a74

Please sign in to comment.