Skip to content

Commit

Permalink
Fix pypi publication and remove smac from tests for MacOS and py3.6
Browse files Browse the repository at this point in the history
  • Loading branch information
noscode committed Sep 20, 2023
1 parent 3d653bf commit 0866d91
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 16 deletions.
59 changes: 45 additions & 14 deletions .github/workflows/publication_to_pypi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,46 +8,77 @@ on:
types: [published]

jobs:
build-n-publish:
build:
name: Build and publish Python distributions to PyPI and TestPyPI
runs-on: ubuntu-20.04

steps:
- uses: actions/checkout@master
- name: Set up Python 3.8
uses: actions/setup-python@v2
uses: actions/setup-python@v4
with:
python-version: 3.8
if: github.repository_owner == 'ctlab'

- name: Check out src from Git
uses: actions/checkout@v2
uses: actions/checkout@v4
- name: Get history and tags for SCM versioning to work
run: |
git fetch --prune --unshallow
git fetch --depth=1 origin +refs/tags/*:refs/tags/*
if: github.repository_owner == 'ctlab'

- name: Install GADMA and its dependencies and create dist.
- name: Install GADMA and its dependencies.
run: |
pip install setuptools --upgrade
pip install numpy
pip install Cython
pip install dadi
python3 setup.py install
python3 -m pip install setuptools --upgrade
python3 -m pip install numpy
python3 -m pip install Cython
python3 -m pip install dadi
#python3 setup.py install
python3 -m pip install --user --upgrade setuptools wheel
python3 setup.py sdist bdist_wheel
#python3 setup.py sdist bdist_wheel
if: github.repository_owner == 'ctlab'

- name: Install pypa/build
run: python3 -m pip install build --user

- name: Build a binary wheel and a source tarball
run: python3 -m build
- name: Store the distribution packages
uses: actions/upload-artifact@v3
with:
name: python-package-distributions
path: dist/

publish-to-testpypi:
name: Publish Python 🐍 distribution 📦 to TestPyPI
needs:
- build
runs-on: ubuntu-20.04

environment:
name: publish-testpypi
url: https://test.pypi.org/p/gadma

permissions:
id-token: write # IMPORTANT: mandatory for trusted publishing

steps:
- name: Download all the dists
uses: actions/download-artifact@v3
with:
name: python-package-distributions
path: dist/

- name: Publish distribution 📦 to Test PyPI
uses: pypa/gh-action-pypi-publish@master
uses: pypa/gh-action-pypi-publish@release/v1
with:
password: ${{ secrets.TEST_PYPI_API_TOKEN }}
repository_url: https://test.pypi.org/legacy/
repository-url: https://test.pypi.org/legacy/
if: github.repository_owner == 'ctlab'

- name: Publish distribution 📦 to PyPI
if: github.repository_owner == 'ctlab' && github.event.release
uses: pypa/gh-action-pypi-publish@master
uses: pypa/gh-action-pypi-publish@release/v1
with:
password: ${{ secrets.PYPI_API_TOKEN }}
verbose: true
4 changes: 4 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,10 @@ jobs:
run: |
pip3 uninstall -y smac
- name: Uninstall SMAC (MacOS py3.6)
if: runner.os == 'MacOS' && matrix.python-version == '3.6'
run: pip3 uninstall -y smac

- name: Install momentsLD engine.
run: |
pip3 uninstall -y moments
Expand Down
6 changes: 4 additions & 2 deletions gadma/optimizers/bayesian_optimization.py
Original file line number Diff line number Diff line change
Expand Up @@ -341,12 +341,13 @@ def get_configs(self, variables):
api_config[var.name] = {'type': 'real',
'space': 'linear',
'range': var.domain}
middle_point = (var.domain[0] + var.domain[1]) / 2
hp_list.append(
UniformFloatHyperparameter(
name=var.name,
lower=float(var.domain[0]),
upper=float(var.domain[1]),
default_value=None,
default_value=float(middle_point),
log=False
)
)
Expand Down Expand Up @@ -639,12 +640,13 @@ def get_config_space(self, variables):
hp_list = []
for var in variables:
if isinstance(var, ContinuousVariable):
middle_point = (var.domain[0] + var.domain[1]) / 2
hp_list.append(
UniformFloatHyperparameter(
name=var.name,
lower=float(var.domain[0]),
upper=float(var.domain[1]),
default_value=None,
default_value=float(middle_point),
log=False
)
)
Expand Down

0 comments on commit 0866d91

Please sign in to comment.