Skip to content

Commit

Permalink
Merge branch 'master' into fix_triggers_of_workflows
Browse files Browse the repository at this point in the history
  • Loading branch information
eddiebergman authored Dec 15, 2021
2 parents 84252b7 + 4d69931 commit bdf995d
Show file tree
Hide file tree
Showing 10 changed files with 309 additions and 34 deletions.
5 changes: 5 additions & 0 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,11 @@ jobs:
cd docs
make html
- name: Run doctests
run: |
cd docs
make doctest
- name: Pull latest gh-pages
if: (contains(github.ref, 'master')) && github.event_name == 'push'
run: |
Expand Down
155 changes: 144 additions & 11 deletions .github/workflows/wheels.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# Workflow to build and test wheels
# =================================
# This github action gets triggered whenever there
# is a push to the master branch or a release is created.
# It generates both wheels and distributions files,
# is a push to the master branch or a release is created.
# It generates both wheels and distributions files,
# making sure their contents are correct via unit-testing.
#
# However, only in the case of a github release, the assets
Expand All @@ -15,10 +15,10 @@
# 2- Whenever there is enough PRs in the master branch, we expect the user
# to create a release following github guidelines from here:
# https://docs.github.com/en/github/administering-a-repository/releasing-projects-on-github/managing-releases-in-a-repository
# During a github release, you create a tagged-version (something like v2.3.4.),
# During a github release, you create a tagged-version (something like v2.3.4.),
# add a title to the release and a description. Then you publish the release via the
# publish-button. This effectively creates a github release, triggering this action.
# When this triggered action finished, the release files are automatically uploaded
# When this triggered action finished, the release files are automatically uploaded
# to your github release page. Check for example:
# https://github.com/automl/ConfigSpace/releases
#
Expand All @@ -29,6 +29,8 @@
name: Wheel builder

on:
workflow_dispatch:

push:
branches:
- master
Expand All @@ -38,6 +40,7 @@ on:
tags:
- v*


jobs:
# Build the wheels for Linux
build_wheels:
Expand All @@ -48,21 +51,149 @@ jobs:
# Ensure that a wheel builder finishes even if another fails
fail-fast: false
matrix:
os: [ubuntu-latest]
python: [37, 38, 39]
bitness: [32, 64]
manylinux_image: [manylinux2014]
include:
# Window 64 bit
- os: windows-latest
python: 37
bitness: 64
platform_id: win_amd64
- os: windows-latest
python: 38
bitness: 64
platform_id: win_amd64
- os: windows-latest
python: 39
bitness: 64
platform_id: win_amd64
- os: windows-latest
python: 310
bitness: 64
platform_id: win_amd64

# Window 32 bit
- os: windows-latest
python: 37
bitness: 32
platform_id: win32
- os: windows-latest
python: 38
bitness: 32
platform_id: win32
- os: windows-latest
python: 39
bitness: 32
platform_id: win32

# Linux 64 bit manylinux1
- os: ubuntu-latest
python: 37
bitness: 64
platform_id: manylinux_x86_64
manylinux_image: manylinux1
- os: ubuntu-latest
python: 38
bitness: 64
platform_id: manylinux_x86_64
manylinux_image: manylinux1
- os: ubuntu-latest
python: 39
bitness: 64
platform_id: manylinux_x86_64
manylinux_image: manylinux1

# Linux 64 bit manylinux2010
- os: ubuntu-latest
python: 37
bitness: 64
platform_id: manylinux_x86_64
manylinux_image: manylinux2010
- os: ubuntu-latest
python: 38
bitness: 64
platform_id: manylinux_x86_64
manylinux_image: manylinux2010
- os: ubuntu-latest
python: 39
bitness: 64
platform_id: manylinux_x86_64
manylinux_image: manylinux2010

# NumPy on Python 3.10 only supports 64bit and is only available with manylinux2014
- os: ubuntu-latest
python: 310
bitness: 64
platform_id: manylinux_x86_64
manylinux_image: manylinux2014

# Linux 32 bit manylinux1
- os: ubuntu-latest
python: 37
bitness: 32
platform_id: manylinux_i686
manylinux_image: manylinux1
- os: ubuntu-latest
python: 38
bitness: 32
platform_id: manylinux_i686
manylinux_image: manylinux1
- os: ubuntu-latest
python: 39
bitness: 32
platform_id: manylinux_i686
manylinux_image: manylinux1

# Linux 32 bit manylinux2010
- os: ubuntu-latest
python: 37
bitness: 32
platform_id: manylinux_i686
manylinux_image: manylinux2010
- os: ubuntu-latest
python: 38
bitness: 32
platform_id: manylinux_i686
manylinux_image: manylinux2010
- os: ubuntu-latest
python: 39
bitness: 32
platform_id: manylinux_i686
manylinux_image: manylinux2010

# MacOS x86_64
- os: macos-latest
bitness: 64
python: 37
platform_id: macosx_x86_64
- os: macos-latest
bitness: 64
python: 38
platform_id: macosx_x86_64
- os: macos-latest
bitness: 64
python: 39
platform_id: macosx_x86_64
- os: macos-latest
bitness: 64
python: 310
platform_id: macosx_x86_64

# MacOS arm64
#- os: macos-latest
# bitness: 64
# python: 38
# platform_id: macosx_arm64
#- os: macos-latest
# bitness: 64
# python: 39
# platform_id: macosx_arm64
#- os: macos-latest
# bitness: 64
# python: 310
# platform_id: macosx_arm64

steps:
- name: Checkout ConfigSpace
uses: actions/checkout@v1
uses: actions/checkout@v2

- name: Setup Python
uses: actions/setup-python@v2
Expand All @@ -73,7 +204,7 @@ jobs:
CIBW_MANYLINUX_X86_64_IMAGE: ${{ matrix.manylinux_image }}
CIBW_MANYLINUX_I686_IMAGE: ${{ matrix.manylinux_image }}
CIBW_TEST_REQUIRES: pytest threadpoolctl numpy
CIBW_TEST_COMMAND: pytest -v /project/test
CIBW_TEST_COMMAND: pytest -v {project}/test

run: |
python -m pip install cibuildwheel
Expand All @@ -91,7 +222,7 @@ jobs:

steps:
- name: Checkout ConfigSpace
uses: actions/checkout@v1
uses: actions/checkout@v2

- name: Setup Python
uses: actions/setup-python@v2
Expand All @@ -106,10 +237,12 @@ jobs:
last_dist=$(ls -t dist/ConfigSpace-*.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/ConfigSpace-*.tar.gz | head -n 1)
pip install $last_dist
- name: PEP 561 Compliance
run: |
pip install mypy
Expand Down
36 changes: 29 additions & 7 deletions ConfigSpace/configuration_space.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -1341,6 +1341,32 @@ class ConfigurationSpace(collections.abc.Mapping):
"""
self.random = np.random.RandomState(seed)

def estimate_size(self) -> Union[float, int]:
"""
Estimate the size of the current configuration space (i.e. unique configurations).

This is ``np.inf`` in case if there is a single hyperparameter of size ``np.inf`` (i.e. a
:class:`~ConfigSpace.hyperparameters.UniformFloatHyperparameter`), otherwise
it is the product of the size of all hyperparameters. The function correctly guesses the
number of unique configurations if there are no condition and forbidden statements in the
configuration spaces. Otherwise, this is an upper bound. Use
:func:`~ConfigSpace.util.generate_grid` to generate all valid configurations if required.

Returns
-------
Union[float, int]
"""
sizes = []
for hp in self._hyperparameters.values():
sizes.append(hp.get_size())
if len(sizes) == 0:
return 0.0
else:
size = sizes[0]
for i in range(1, len(sizes)):
size = size * sizes[i]
return size


class Configuration(collections.abc.Mapping):
def __init__(self, configuration_space: ConfigurationSpace,
Expand Down Expand Up @@ -1573,22 +1599,18 @@ class Configuration(collections.abc.Mapping):
self._populate_values()

representation = io.StringIO()
representation.write("Configuration:\n")
representation.write("Configuration(values={\n")

hyperparameters = self.configuration_space.get_hyperparameters()
hyperparameters.sort(key=lambda t: t.name)
for hyperparameter in hyperparameters:
hp_name = hyperparameter.name
if hp_name in self._values and self._values[hp_name] is not None:
representation.write(" ")

value = repr(self._values[hp_name])
if isinstance(hyperparameter, Constant):
representation.write("%s, Constant: %s" % (hp_name, value))
else:
representation.write("%s, Value: %s" % (hp_name, value))
representation.write("\n")
representation.write("'%s': %s,\n" % (hp_name, value))

representation.write("})\n")
return representation.getvalue()

def __iter__(self) -> Iterable:
Expand Down
Loading

0 comments on commit bdf995d

Please sign in to comment.