Skip to content

Commit

Permalink
Easy api (#255)
Browse files Browse the repository at this point in the history
* Add `py.typed`

* Trim whitespace

* Simple HP types interface

* Add dictionary parsing

* Add note about compiling from source

* Specified space types

* Added examples to readme and docs

* Add `py.typed`

* Trim whitespace

* Simple HP types interface

* Add dictionary parsing

* Add note about compiling from source

* Pre-commit fixes

* Specified space types

* Added examples to readme and docs

* Add requirement for `typing_extensions`

* Remove unknown `bibtex` lexer

* Fix doctests

* Add code doc for Int

* Docs for Float's

* Fix import bug

* Add doc for categoricals

* Add doc for distributions

* Integrated AutoML Sphinx Theme

* Add in some removed plugins

* Add a Makefile

* Increased veresion

* Big ol doc update

* Deflate API

* Code fix

* Comments

* Remove references to `examples` folder for docs

* Emphasise Ordinal and add more doc on diff for HP

* Change from Int to Integer

* Fix unused import

* Fix doctests, make reproducible

* Rename "master" to "main" around the place

* Update changelog

* Add tolerance to failing test

* Update docs workflow properly

* Revert back to v3

* Compile extra requirements into just "dev"

* Fix Makefile

* Fix install in pytest workflow

* Export types

* Make authors it's own file like version

* Add some more indicators of Mac/Windows support

* Fix doctest

Co-authored-by: René Sass <mail@renesass.de>
  • Loading branch information
eddiebergman and renesass authored Aug 15, 2022
1 parent e681dc9 commit 8d64a8d
Show file tree
Hide file tree
Showing 54 changed files with 2,508 additions and 1,494 deletions.
47 changes: 24 additions & 23 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
@@ -1,63 +1,64 @@
name: Docs
name: docs

on:

# Trigger manually
workflow_dispatch:

# Trigger on any push to the master
# Trigger on any push to the main
push:
branches:
- master
- main
- development

# Trigger on any push to a PR that targets master
# Trigger on any push to a PR that targets main
pull_request:
branches:
- master
- main
- development

jobs:
permissions:
contents: write

env:
name: "ConfigSpace"

jobs:
build-and-deploy:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v3

- name: Setup Python
uses: actions/setup-python@v2
uses: actions/setup-python@v3
with:
python-version: 3.8
python-version: "3.8"

- name: Install dependencies
run: |
pip install -e .[docs,examples,examples_unix]
pip install ".[dev]"
- name: Make docs
run: |
cd docs
make html
- name: Run doctests
run: |
cd docs
make doctest
make clean
make docs
- name: Pull latest gh-pages
if: (contains(github.ref, 'master')) && github.event_name == 'push'
if: (contains(github.ref, 'develop') || contains(github.ref, 'main')) && github.event_name == 'push'
run: |
cd ..
git clone https://github.com/automl/ConfigSpace.git --branch gh-pages --single-branch gh-pages
git clone https://github.com/${{ github.repository }}.git --branch gh-pages --single-branch gh-pages
- name: Copy new docs into gh-pages
if: (contains(github.ref, 'develop') || contains(github.ref, 'master')) && github.event_name == 'push'
if: (contains(github.ref, 'develop') || contains(github.ref, 'main')) && github.event_name == 'push'
run: |
branch_name=${GITHUB_REF##*/}
cd ../gh-pages
rm -rf $branch_name
cp -r ../ConfigSpace/docs/build/html $branch_name
cp -r ../${{ env.name }}/docs/build/html $branch_name
- name: Push to gh-pages
if: (contains(github.ref, 'master')) && github.event_name == 'push'
if: (contains(github.ref, 'develop') || contains(github.ref, 'main')) && github.event_name == 'push'
run: |
last_commit=$(git log --pretty=format:"%an: %s")
cd ../gh-pages
Expand Down
6 changes: 4 additions & 2 deletions .github/workflows/pre-commit.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,14 @@ on:
# Trigger on any push to the master
push:
branches:
- master
- main
- development

# Trigger on any push to a PR that targets master
pull_request:
branches:
- master
- main
- development

jobs:

Expand Down
8 changes: 5 additions & 3 deletions .github/workflows/pytest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,14 @@ on:
# Triggers with push to master
push:
branches:
- master
- main
- development

# Triggers with push to a pr aimed at master
pull_request:
branches:
- master
- main
- development

schedule:
# Every day at 7AM UTC
Expand All @@ -22,7 +24,7 @@ env:

package-name: ConfigSpace
test-dir: test
extra-requires: "[test]" # "" for no extra_requires
extra-requires: "[dev]" # "" for no extra_requires

# Arguments used for pytest
pytest-args: >-
Expand Down
7 changes: 3 additions & 4 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ on:

push:
branches:
- master
- main
# Release branches
- "[0-9]+.[0-9]+.X"

Expand All @@ -54,7 +54,7 @@ env:
test-dir: test
test-reqs: "pytest"
test-cmd: "pytest -v"
extra-requires: "[test]"
extra-requires: "[dev]"

jobs:

Expand All @@ -74,11 +74,10 @@ jobs:
# Not supported by numpy
- system: "musllinux"

# Scipy doesn't have a wheel for cp310 i686
# Scipy doesn't have a wheel for cp310 i686
- py: cp310
arch: "i686"


steps:
- name: Checkout ${{ env.package-name }}
uses: actions/checkout@v2
Expand Down
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
.DS_Store

# Documentation
docs/build/*
docs/examples/*

*.py[cod]

Expand Down Expand Up @@ -68,4 +71,4 @@ prof/
.vscode

# Running pre-commit seems to generate these
.mypy_cache
.mypy_cache
6 changes: 4 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,17 +1,19 @@
repos:
- repo: https://github.com/pre-commit/mirrors-mypy
rev: v0.761
rev: v0.961
hooks:
- id: mypy
args: [--show-error-codes, --ignore-missing-imports, --follow-imports, skip]
name: mypy ConfigSpace
files: ConfigSpace

- repo: https://gitlab.com/pycqa/flake8
rev: 3.8.3
rev: 4.0.1
hooks:
- id: flake8
name: flake8 ConfigSpace
files: ConfigSpace

- id: flake8
name: flake8 test
files: test
12 changes: 12 additions & 0 deletions ConfigSpace/__authors__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
__authors__ = [
"Matthias Feurer",
"Katharina Eggensperger",
"Syed Mohsin Ali",
"Christina Hernandez Wunsch",
"Julien-Charles Levesque",
"Jost Tobias Springenberg",
"Philipp Mueller",
"Marius Lindauer",
"Jorn Tuyls",
"Eddie Bergman",
]
90 changes: 63 additions & 27 deletions ConfigSpace/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,32 +27,68 @@
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

from ConfigSpace.__version__ import __version__
__authors__ = [
"Matthias Feurer", "Katharina Eggensperger", "Syed Mohsin Ali",
"Christina Hernandez Wunsch", "Julien-Charles Levesque",
"Jost Tobias Springenberg", "Philipp Mueller", "Marius Lindauer",
"Jorn Tuyls"
]
from ConfigSpace.__authors__ import __authors__

from ConfigSpace.configuration_space import Configuration, \
ConfigurationSpace
from ConfigSpace.hyperparameters import CategoricalHyperparameter, \
UniformFloatHyperparameter, UniformIntegerHyperparameter, Constant, \
UnParametrizedHyperparameter, OrdinalHyperparameter
from ConfigSpace.conditions import AndConjunction, OrConjunction, \
EqualsCondition, NotEqualsCondition, InCondition, GreaterThanCondition, LessThanCondition
from ConfigSpace.forbidden import ForbiddenAndConjunction, \
ForbiddenEqualsClause, ForbiddenInClause, ForbiddenLessThanRelation, ForbiddenEqualsRelation, \
ForbiddenGreaterThanRelation
import ConfigSpace.api.distributions as distributions
import ConfigSpace.api.types as types
from ConfigSpace.api import (Beta, Categorical, Distribution, Float, Integer,
Normal, Uniform)
from ConfigSpace.conditions import (AndConjunction, EqualsCondition,
GreaterThanCondition, InCondition,
LessThanCondition, NotEqualsCondition,
OrConjunction)
from ConfigSpace.configuration_space import Configuration, ConfigurationSpace
from ConfigSpace.forbidden import (ForbiddenAndConjunction,
ForbiddenEqualsClause,
ForbiddenEqualsRelation,
ForbiddenGreaterThanRelation,
ForbiddenInClause,
ForbiddenLessThanRelation)
from ConfigSpace.hyperparameters import (BetaFloatHyperparameter,
BetaIntegerHyperparameter,
CategoricalHyperparameter, Constant,
NormalFloatHyperparameter,
NormalIntegerHyperparameter,
OrdinalHyperparameter,
UniformFloatHyperparameter,
UniformIntegerHyperparameter,
UnParametrizedHyperparameter)

__all__ = ["__version__", "Configuration", "ConfigurationSpace",
"CategoricalHyperparameter", "UniformFloatHyperparameter",
"UniformIntegerHyperparameter", "Constant",
"UnParametrizedHyperparameter", "OrdinalHyperparameter",
"AndConjunction", "OrConjunction",
"EqualsCondition", "NotEqualsCondition",
"InCondition", "GreaterThanCondition",
"LessThanCondition", "ForbiddenAndConjunction",
"ForbiddenEqualsClause", "ForbiddenInClause",
"ForbiddenLessThanRelation", "ForbiddenEqualsRelation",
"ForbiddenGreaterThanRelation"]
__all__ = [
"__authors__",
"__version__",
"Configuration",
"ConfigurationSpace",
"CategoricalHyperparameter",
"UniformFloatHyperparameter",
"UniformIntegerHyperparameter",
"BetaFloatHyperparameter",
"BetaIntegerHyperparameter",
"NormalFloatHyperparameter",
"NormalIntegerHyperparameter",
"Constant",
"UnParametrizedHyperparameter",
"OrdinalHyperparameter",
"AndConjunction",
"OrConjunction",
"EqualsCondition",
"NotEqualsCondition",
"InCondition",
"GreaterThanCondition",
"LessThanCondition",
"ForbiddenAndConjunction",
"ForbiddenEqualsClause",
"ForbiddenInClause",
"ForbiddenLessThanRelation",
"ForbiddenEqualsRelation",
"ForbiddenGreaterThanRelation",
"Beta",
"Categorical",
"Distribution",
"Float",
"Integer",
"Normal",
"Uniform",
"distributions",
"types",
]
2 changes: 1 addition & 1 deletion ConfigSpace/__version__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
"""Version information."""

# The following line *must* be the last in the module, exactly as formatted:
__version__ = "0.5.0"
__version__ = "0.6.0"
16 changes: 16 additions & 0 deletions ConfigSpace/api/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import ConfigSpace.api.distributions as distributions
import ConfigSpace.api.types as types
from ConfigSpace.api.distributions import Beta, Distribution, Normal, Uniform
from ConfigSpace.api.types import Categorical, Float, Integer

__all__ = [
"types",
"distributions",
"Beta",
"Distribution",
"Normal",
"Uniform",
"Categorical",
"Float",
"Integer",
]
49 changes: 49 additions & 0 deletions ConfigSpace/api/distributions.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
from dataclasses import dataclass


@dataclass
class Distribution:
"""Base distribution type"""

pass


@dataclass
class Uniform(Distribution):
"""A uniform distribution"""

pass


@dataclass
class Normal(Distribution):
"""Represents a normal distribution.
Parameters
----------
mu: float
The mean of the distribution
sigma: float
The standard deviation of the float
"""

mu: float
sigma: float


@dataclass
class Beta(Distribution):
"""Represents a beta distribution.
Parameters
----------
alpha: float
The alpha parameter of a beta distribution
beta: float
The beta parameter of a beta distribution
"""

alpha: float
beta: float
5 changes: 5 additions & 0 deletions ConfigSpace/api/types/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
from ConfigSpace.api.types.categorical import Categorical
from ConfigSpace.api.types.float import Float
from ConfigSpace.api.types.integer import Integer

__all__ = ["Categorical", "Float", "Integer"]
Loading

0 comments on commit 8d64a8d

Please sign in to comment.