From e2c6a6b7cbef2dc8d14187ae39fa2fe7f02895bc Mon Sep 17 00:00:00 2001 From: chico Date: Thu, 20 May 2021 11:25:05 +0200 Subject: [PATCH 1/6] [ADD] wheels --- .github/workflows/dist.yml | 31 -------- .github/workflows/wheels.yml | 147 +++++++++++++++++++++++++++++++++++ 2 files changed, 147 insertions(+), 31 deletions(-) delete mode 100644 .github/workflows/dist.yml create mode 100644 .github/workflows/wheels.yml diff --git a/.github/workflows/dist.yml b/.github/workflows/dist.yml deleted file mode 100644 index 71756159..00000000 --- a/.github/workflows/dist.yml +++ /dev/null @@ -1,31 +0,0 @@ -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/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 - cd .. # required to use the installed version of ConfigSpace - if ! python -c "import ConfigSpace"; then exit 1; fi diff --git a/.github/workflows/wheels.yml b/.github/workflows/wheels.yml new file mode 100644 index 00000000..fbe99ee3 --- /dev/null +++ b/.github/workflows/wheels.yml @@ -0,0 +1,147 @@ +# Workflow to build and test wheels +name: Wheel builder + +on: + push: + branches: + - master + # Release branches + - "[0-9]+.[0-9]+.X" + create: + tags: + - v* + +jobs: + # Build the wheels for Linux + build_wheels: + name: Build wheel for cp${{ matrix.python }}-${{ matrix.platform_id }}-${{ matrix.manylinux_image }} + runs-on: ${{ matrix.os }} + + strategy: + # Ensure that a wheel builder finishes even if another fails + fail-fast: false + matrix: + os: [ubuntu-latest] + python: [36, 37, 38, 39] + bitness: [32, 64] + manylinux_image: [manylinux2014] + include: + - os: ubuntu-latest + bitness: 64 + platform_id: manylinux_x86_64 + - os: ubuntu-latest + bitness: 32 + platform_id: manylinux_i686 + + steps: + - name: Checkout ConfigSpace + uses: actions/checkout@v1 + + - name: Setup Python + uses: actions/setup-python@v2 + + - name: Build and test wheels + env: + CIBW_BUILD: cp${{ matrix.python }}-${{ matrix.platform_id }} + 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 + + run: | + python -m pip install cibuildwheel + python -m cibuildwheel --output-dir wheelhouse + + - name: Store artifacts + uses: actions/upload-artifact@v2 + with: + path: wheelhouse/*.whl + + # Build the source distribution under Linux + build_sdist: + name: Source distribution + runs-on: ubuntu-latest + + steps: + - name: Checkout ConfigSpace + uses: actions/checkout@v1 + + - name: Setup Python + uses: actions/setup-python@v2 + + - name: Build source distribution + run: python setup.py sdist + + # Full unit-testing is handled in pytest.yml + - name: Twine check + run: | + pip install twine + 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 + cd .. # required to use the installed version of ConfigSpace + if ! python -c "import ConfigSpace"; then exit 1; fi + + - name: Store artifacts + uses: actions/upload-artifact@v2 + with: + path: dist/*.tar.gz + + # Upload the wheels and the source distribution + release_assets: + name: Upload Release + runs-on: ubuntu-latest + needs: [build_wheels, build_sdist] + # Only on a tagged release, push + if: startsWith(github.ref, 'refs/tags/v') && github.event_name != 'pull_request' + + steps: + - name: Checkout ConfigSpace + uses: actions/checkout@v1 + + - name: Download artifacts + uses: actions/download-artifact@v2 + with: + path: dist + + - name: Setup Python + uses: actions/setup-python@v2 + + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install setuptools wheel twine + + #- name: Publish python package + # id: publish_package + # env: + # TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }} + # TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }} + # run: | + # twine upload dist/* + + - name: Create Release + id: create_release + uses: actions/create-release@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + tag_name: ${{ github.ref }} + release_name: Release ${{ github.ref }} + draft: false + prerelease: false + - name: Upload Release Asset + id: upload-release-asset + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + tag_name="${GITHUB_REF##*/}" + echo Uploading `(find ./dist -type f -printf "-a %p ")` + hub release edit $(find ./dist -type f -printf "-a %p ") -m "" "$tag_name" From 1287656d94d5fbd620492dbbf86efe22656f6286 Mon Sep 17 00:00:00 2001 From: chico Date: Thu, 20 May 2021 21:19:34 +0200 Subject: [PATCH 2/6] Correct overflow for np.int --- ConfigSpace/hyperparameters.pxd | 2 +- ConfigSpace/hyperparameters.pyx | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/ConfigSpace/hyperparameters.pxd b/ConfigSpace/hyperparameters.pxd index 81653125..acb4f767 100644 --- a/ConfigSpace/hyperparameters.pxd +++ b/ConfigSpace/hyperparameters.pxd @@ -33,7 +33,7 @@ cdef class NumericalHyperparameter(Hyperparameter): cdef class IntegerHyperparameter(NumericalHyperparameter): cdef ufhp - cpdef long _transform_scalar(self, double scalar) + cpdef long long _transform_scalar(self, double scalar) cpdef np.ndarray _transform_vector(self, np.ndarray vector) cdef class FloatHyperparameter(NumericalHyperparameter): diff --git a/ConfigSpace/hyperparameters.pyx b/ConfigSpace/hyperparameters.pyx index 7c2b93b0..1eb08c5c 100644 --- a/ConfigSpace/hyperparameters.pyx +++ b/ConfigSpace/hyperparameters.pyx @@ -408,7 +408,7 @@ cdef class IntegerHyperparameter(NumericalHyperparameter): except ValueError: return None - cpdef long _transform_scalar(self, double scalar): + cpdef long long _transform_scalar(self, double scalar): raise NotImplementedError() cpdef np.ndarray _transform_vector(self, np.ndarray vector): @@ -900,7 +900,7 @@ cdef class UniformIntegerHyperparameter(IntegerHyperparameter): return np.rint(vector) - cpdef long _transform_scalar(self, double scalar): + cpdef long long _transform_scalar(self, double scalar): scalar = self.ufhp._transform_scalar(scalar) if self.q is not None: scalar = round((scalar - self.lower) / self.q) * self.q + self.lower @@ -1202,7 +1202,7 @@ cdef class NormalIntegerHyperparameter(IntegerHyperparameter): vector = self.nfhp._transform_vector(vector) return np.rint(vector) - cpdef long _transform_scalar(self, double scalar): + cpdef long long _transform_scalar(self, double scalar): scalar = self.nfhp._transform_scalar(scalar) return int(round(scalar)) From 6f4c9585cfab09c4095362da94653a841571dc4d Mon Sep 17 00:00:00 2001 From: chico Date: Thu, 20 May 2021 21:38:39 +0200 Subject: [PATCH 3/6] Temporary add wheels for testing --- .github/workflows/wheels.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/wheels.yml b/.github/workflows/wheels.yml index fbe99ee3..ab624c2a 100644 --- a/.github/workflows/wheels.yml +++ b/.github/workflows/wheels.yml @@ -5,6 +5,7 @@ on: push: branches: - master + - wheels # Release branches - "[0-9]+.[0-9]+.X" create: From 5f89a5650b8d864a8307cf1deaa49159f796a018 Mon Sep 17 00:00:00 2001 From: chico Date: Thu, 20 May 2021 21:48:02 +0200 Subject: [PATCH 4/6] Missed a long! --- ConfigSpace/hyperparameters.pyx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ConfigSpace/hyperparameters.pyx b/ConfigSpace/hyperparameters.pyx index 1eb08c5c..39581289 100644 --- a/ConfigSpace/hyperparameters.pyx +++ b/ConfigSpace/hyperparameters.pyx @@ -970,8 +970,8 @@ cdef class UniformIntegerHyperparameter(IntegerHyperparameter): neighbors = [] # type: List[int] cdef int sampled_neighbors = 0 _neighbors_as_int = set() # type: Set[int] - cdef long int_value = self._transform(value) - cdef long new_int_value = 0 + cdef long long int_value = self._transform(value) + cdef long long new_int_value = 0 cdef float new_value = 0.0 cdef np.ndarray samples cdef double[:] samples_view From 5b5c84af02de89f5c412dbd56c0700a288615196 Mon Sep 17 00:00:00 2001 From: chico Date: Fri, 21 May 2021 10:15:42 +0200 Subject: [PATCH 5/6] Docs to wheels.yaml --- .github/workflows/wheels.yml | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/.github/workflows/wheels.yml b/.github/workflows/wheels.yml index ab624c2a..38aa3ac4 100644 --- a/.github/workflows/wheels.yml +++ b/.github/workflows/wheels.yml @@ -1,11 +1,22 @@ # Workflow to build and test wheels +# ================================= +# This github action gets triggered whenever there +# is a push to the master branch. It generates both +# wheels and distributions files, making sure their +# contents are correct via unit-testing. +# +# However, artifacts are only uploaded to a release +# here: https://github.com/automl/ConfigSpace/releases +# When a release tag is created. For example, if +# a release is tagged with the tag v0.N.MM, this workflow +# will get triggered, and release assets (wheels and dist) +# will be appended to the release notes. name: Wheel builder on: push: branches: - master - - wheels # Release branches - "[0-9]+.[0-9]+.X" create: From 659bebf986c6cc9ee9491dc2c48f0181bcc44c16 Mon Sep 17 00:00:00 2001 From: chico Date: Wed, 26 May 2021 12:09:08 +0200 Subject: [PATCH 6/6] Improve doc and remove redundant code --- .github/workflows/wheels.yml | 51 +++++++++++++++++------------------- 1 file changed, 24 insertions(+), 27 deletions(-) diff --git a/.github/workflows/wheels.yml b/.github/workflows/wheels.yml index 38aa3ac4..b28bd3e2 100644 --- a/.github/workflows/wheels.yml +++ b/.github/workflows/wheels.yml @@ -1,16 +1,31 @@ # Workflow to build and test wheels # ================================= # This github action gets triggered whenever there -# is a push to the master branch. It generates both -# wheels and distributions files, making sure their -# contents are correct via unit-testing. +# 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, artifacts are only uploaded to a release -# here: https://github.com/automl/ConfigSpace/releases -# When a release tag is created. For example, if -# a release is tagged with the tag v0.N.MM, this workflow -# will get triggered, and release assets (wheels and dist) -# will be appended to the release notes. +# However, only in the case of a github release, the assets +# are uploaded and attached to a release. In other words, we +# expect the following workflow: +# 1- users adds new features to the master branch via PRs. Every +# time a new feature gets merged to the master branch, this github +# action gets triggered, and wheels/distribution files are generated +# to make sure this new change did not break the distribution files. +# 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.), +# 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 +# to your github release page. Check for example: +# https://github.com/automl/ConfigSpace/releases +# +# Please note that creating a git tag and pushing it (git tag <>; git push --tags) is not +# sufficient to append the wheels and distribution files to your release. +# You need to generate a new release using github, not git. + name: Wheel builder on: @@ -131,24 +146,6 @@ jobs: python -m pip install --upgrade pip pip install setuptools wheel twine - #- name: Publish python package - # id: publish_package - # env: - # TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }} - # TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }} - # run: | - # twine upload dist/* - - - name: Create Release - id: create_release - uses: actions/create-release@v1 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - with: - tag_name: ${{ github.ref }} - release_name: Release ${{ github.ref }} - draft: false - prerelease: false - name: Upload Release Asset id: upload-release-asset env: