Skip to content

Commit f639133

Browse files
Enable wheels for 32/64 architecture (#184)
* [ADD] wheels * Correct overflow for np.int * Temporary add wheels for testing * Missed a long! * Docs to wheels.yaml * Improve doc and remove redundant code
1 parent 390263e commit f639133

4 files changed

Lines changed: 162 additions & 37 deletions

File tree

.github/workflows/dist.yml

Lines changed: 0 additions & 31 deletions
This file was deleted.

.github/workflows/wheels.yml

Lines changed: 156 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,156 @@
1+
# Workflow to build and test wheels
2+
# =================================
3+
# This github action gets triggered whenever there
4+
# is a push to the master branch or a release is created.
5+
# It generates both wheels and distributions files,
6+
# making sure their contents are correct via unit-testing.
7+
#
8+
# However, only in the case of a github release, the assets
9+
# are uploaded and attached to a release. In other words, we
10+
# expect the following workflow:
11+
# 1- users adds new features to the master branch via PRs. Every
12+
# time a new feature gets merged to the master branch, this github
13+
# action gets triggered, and wheels/distribution files are generated
14+
# to make sure this new change did not break the distribution files.
15+
# 2- Whenever there is enough PRs in the master branch, we expect the user
16+
# to create a release following github guidelines from here:
17+
# https://docs.github.com/en/github/administering-a-repository/releasing-projects-on-github/managing-releases-in-a-repository
18+
# During a github release, you create a tagged-version (something like v2.3.4.),
19+
# add a title to the release and a description. Then you publish the release via the
20+
# publish-button. This effectively creates a github release, triggering this action.
21+
# When this triggered action finished, the release files are automatically uploaded
22+
# to your github release page. Check for example:
23+
# https://github.com/automl/ConfigSpace/releases
24+
#
25+
# Please note that creating a git tag and pushing it (git tag <>; git push --tags) is not
26+
# sufficient to append the wheels and distribution files to your release.
27+
# You need to generate a new release using github, not git.
28+
29+
name: Wheel builder
30+
31+
on:
32+
push:
33+
branches:
34+
- master
35+
# Release branches
36+
- "[0-9]+.[0-9]+.X"
37+
create:
38+
tags:
39+
- v*
40+
41+
jobs:
42+
# Build the wheels for Linux
43+
build_wheels:
44+
name: Build wheel for cp${{ matrix.python }}-${{ matrix.platform_id }}-${{ matrix.manylinux_image }}
45+
runs-on: ${{ matrix.os }}
46+
47+
strategy:
48+
# Ensure that a wheel builder finishes even if another fails
49+
fail-fast: false
50+
matrix:
51+
os: [ubuntu-latest]
52+
python: [36, 37, 38, 39]
53+
bitness: [32, 64]
54+
manylinux_image: [manylinux2014]
55+
include:
56+
- os: ubuntu-latest
57+
bitness: 64
58+
platform_id: manylinux_x86_64
59+
- os: ubuntu-latest
60+
bitness: 32
61+
platform_id: manylinux_i686
62+
63+
steps:
64+
- name: Checkout ConfigSpace
65+
uses: actions/checkout@v1
66+
67+
- name: Setup Python
68+
uses: actions/setup-python@v2
69+
70+
- name: Build and test wheels
71+
env:
72+
CIBW_BUILD: cp${{ matrix.python }}-${{ matrix.platform_id }}
73+
CIBW_MANYLINUX_X86_64_IMAGE: ${{ matrix.manylinux_image }}
74+
CIBW_MANYLINUX_I686_IMAGE: ${{ matrix.manylinux_image }}
75+
CIBW_TEST_REQUIRES: pytest threadpoolctl numpy
76+
CIBW_TEST_COMMAND: pytest -v /project/test
77+
78+
run: |
79+
python -m pip install cibuildwheel
80+
python -m cibuildwheel --output-dir wheelhouse
81+
82+
- name: Store artifacts
83+
uses: actions/upload-artifact@v2
84+
with:
85+
path: wheelhouse/*.whl
86+
87+
# Build the source distribution under Linux
88+
build_sdist:
89+
name: Source distribution
90+
runs-on: ubuntu-latest
91+
92+
steps:
93+
- name: Checkout ConfigSpace
94+
uses: actions/checkout@v1
95+
96+
- name: Setup Python
97+
uses: actions/setup-python@v2
98+
99+
- name: Build source distribution
100+
run: python setup.py sdist
101+
102+
# Full unit-testing is handled in pytest.yml
103+
- name: Twine check
104+
run: |
105+
pip install twine
106+
last_dist=$(ls -t dist/ConfigSpace-*.tar.gz | head -n 1)
107+
twine_output=`twine check "$last_dist"`
108+
if [[ "$twine_output" != "Checking $last_dist: PASSED" ]]; then echo $twine_output && exit 1;fi
109+
- name: Install dist
110+
run: |
111+
last_dist=$(ls -t dist/ConfigSpace-*.tar.gz | head -n 1)
112+
pip install $last_dist
113+
- name: PEP 561 Compliance
114+
run: |
115+
pip install mypy
116+
cd .. # required to use the installed version of ConfigSpace
117+
if ! python -c "import ConfigSpace"; then exit 1; fi
118+
119+
- name: Store artifacts
120+
uses: actions/upload-artifact@v2
121+
with:
122+
path: dist/*.tar.gz
123+
124+
# Upload the wheels and the source distribution
125+
release_assets:
126+
name: Upload Release
127+
runs-on: ubuntu-latest
128+
needs: [build_wheels, build_sdist]
129+
# Only on a tagged release, push
130+
if: startsWith(github.ref, 'refs/tags/v') && github.event_name != 'pull_request'
131+
132+
steps:
133+
- name: Checkout ConfigSpace
134+
uses: actions/checkout@v1
135+
136+
- name: Download artifacts
137+
uses: actions/download-artifact@v2
138+
with:
139+
path: dist
140+
141+
- name: Setup Python
142+
uses: actions/setup-python@v2
143+
144+
- name: Install dependencies
145+
run: |
146+
python -m pip install --upgrade pip
147+
pip install setuptools wheel twine
148+
149+
- name: Upload Release Asset
150+
id: upload-release-asset
151+
env:
152+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
153+
run: |
154+
tag_name="${GITHUB_REF##*/}"
155+
echo Uploading `(find ./dist -type f -printf "-a %p ")`
156+
hub release edit $(find ./dist -type f -printf "-a %p ") -m "" "$tag_name"

ConfigSpace/hyperparameters.pxd

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ cdef class NumericalHyperparameter(Hyperparameter):
3333

3434
cdef class IntegerHyperparameter(NumericalHyperparameter):
3535
cdef ufhp
36-
cpdef long _transform_scalar(self, double scalar)
36+
cpdef long long _transform_scalar(self, double scalar)
3737
cpdef np.ndarray _transform_vector(self, np.ndarray vector)
3838

3939
cdef class FloatHyperparameter(NumericalHyperparameter):

ConfigSpace/hyperparameters.pyx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -399,7 +399,7 @@ cdef class IntegerHyperparameter(NumericalHyperparameter):
399399
except ValueError:
400400
return None
401401

402-
cpdef long _transform_scalar(self, double scalar):
402+
cpdef long long _transform_scalar(self, double scalar):
403403
raise NotImplementedError()
404404

405405
cpdef np.ndarray _transform_vector(self, np.ndarray vector):
@@ -891,7 +891,7 @@ cdef class UniformIntegerHyperparameter(IntegerHyperparameter):
891891

892892
return np.rint(vector)
893893

894-
cpdef long _transform_scalar(self, double scalar):
894+
cpdef long long _transform_scalar(self, double scalar):
895895
scalar = self.ufhp._transform_scalar(scalar)
896896
if self.q is not None:
897897
scalar = round((scalar - self.lower) / self.q) * self.q + self.lower
@@ -961,8 +961,8 @@ cdef class UniformIntegerHyperparameter(IntegerHyperparameter):
961961
neighbors = [] # type: List[int]
962962
cdef int sampled_neighbors = 0
963963
_neighbors_as_int = set() # type: Set[int]
964-
cdef long int_value = self._transform(value)
965-
cdef long new_int_value = 0
964+
cdef long long int_value = self._transform(value)
965+
cdef long long new_int_value = 0
966966
cdef float new_value = 0.0
967967
cdef np.ndarray samples
968968
cdef double[:] samples_view
@@ -1193,7 +1193,7 @@ cdef class NormalIntegerHyperparameter(IntegerHyperparameter):
11931193
vector = self.nfhp._transform_vector(vector)
11941194
return np.rint(vector)
11951195

1196-
cpdef long _transform_scalar(self, double scalar):
1196+
cpdef long long _transform_scalar(self, double scalar):
11971197
scalar = self.nfhp._transform_scalar(scalar)
11981198
return int(round(scalar))
11991199

0 commit comments

Comments
 (0)