Skip to content

Commit f4f4701

Browse files
authored
Refactor: Remove Cython - Reduce tech debt (#346)
* uncythonize, pytest update * tests passing; fix add_conditions * Fixup tests * refactor: UniformFloat * optim: UniformFloat get neighbors * refactor: deprecate UniformFloat is_legal_vector * big overhaul * fix: depercation wraning of `np.integer` for dtype * refactor: Big internal rewrite, passing tests * test passing checkpoint * pythonize conditionals * optim: Topological sort and vectorize cond/forbiddens * optim: Further small optimizations * optim: Transpose sampling matrix for cache locality * optim: Add test script for neighbor sampling * test: Repass tests * tmpcommmit - lets pray * refactor: Factor out DAG structure into dedicated class * refactor: Move things out of `c_util` * fix: Minimum spanning * fix: min-cond-span sorted by min(depth of all children) * refactor: All tests and benchmarks pass * refactor: Change deprecated test_util * Revert "refactor: Change deprecated test_util" This reverts commit da09f7813aaec6d65e510ae10907bf08bdf37da8. * doc: Remove mention of cython * build: Remove the use "build" in deps * ci: Update test workflow * ci: Remove conda tests since we no longer build w/ cython * fix(typing): Use typing extension for future TypeAlias * ci: Use caching for env across tests * fix(typing): Use `Union` instead of 3.10 syntax * ci: Remove git porcelain check * fix(typing): Use typing for inheritance to support <= 3.9 * fix: Remove `strict=True` from `zip` to support <= 3.10 * fix(typing): Using `typing.Mapping` for inheritance * fix: Move benchmarked functions as main functions to use * style: Update ruff to use numpy syntax * fix(functional): `linspace_chunked` acts more like `np.linspace` * doc: Run `ruff --fix` * style: Fix ruff checks * refactor: Convert to `src` layout * ci: Ignore use of `eval` in test * style: Fix remaning ruff errors * refactor: Json encoding * refactor: Sorry, big dump * optim: Further speedups to one exchange * optim: Further speedups * fix: Hyperparameter attributes are simple types * fix: Sampling from empty configuration spaces * fix: Revert changes from different branch * fix: Test for default_value type * fix: Deserialization with `"r"` * fix: Conjunctions match clauses for equality #334 * fix: Import TypeAlias from typing_extensions * fix: Remove unreliable __hash__ from ConfigurationSpace * fix: Ruff errors * typing: Soft deprecate `pcs` and `pcs_new` * typing: Fix decoder type for json read and write * ci: Move to ruff for linting * fix: Better condition cloning in replace hyperparameters * fix: Use 3.8 compatable isinstance checks * typing: `configuration_space.py` * typing: `dictionary.py` * typing: `_condition_tree.py` * typing: `forbidden.py` * ci: Add `scipy.*` to list of mypy ignore missing import * typing: `conditions.py` * typing: Fix hyperparameter related issues * test: Fixups * refactor: Remove `nx` vendored lib * test: Use new `add` as old was deprecated * refactor: Remove deprecations * fix: Use `isinstance(..., (type1, type2))` * fix: Better casting for reading from pcs * debug: Check windows issue of not legal * ci: Don't use cache for installation * fix: Change error type to IllegalVectorizedValue * debug: More debug prints for ci * ci: Exclude 3.8 3.9 mac * debug: More ci debugging statements * fix: UnitScaler promotes to 64bit to prevent overflow on windows * fix: Remove non assigned type * fix: Address minor comments * fix: Minor review comments * doc: Overhaul to mkdocs, partially complete * doc: Fix missing comma * doc: Typo fixes * doc: typo fix again... * doc: Major doc overhaul to mkdocs * fix: Add backwards compatible `check_forbidden` * fix: Allow backwards compat `"default"` key in encoded spaces * fix: Backwards compatible private methods * refactor: Use `check_` instead of `is_` as method raises * doc: Forbiddens * test: fix test funcion name * fix(Forbidden): Uncomment value checking on `ForbiddenEqualsClaus` * ci: Update doc and test workflows * test: Remove stray function * doc: Type fix * doc: Add note to `_unsafe` code in `hp_components` * doc: Typo fix * doc: Improve code doc attribute clarity * doc: Change `note` to `todo` * doc: Fix documentation for `continuous_neighborhood`
1 parent ce27ba2 commit f4f4701

File tree

141 files changed

+19177
-20589
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

141 files changed

+19177
-20589
lines changed

.github/workflows/docs.yml

Lines changed: 13 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -1,72 +1,27 @@
1+
# This workflow is just to test that the docs build successfully.
12
name: docs
2-
3+
concurrency:
4+
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
5+
cancel-in-progress: true
36
on:
4-
# Trigger manually
57
workflow_dispatch:
6-
7-
# Trigger on any push to the main
88
push:
99
branches:
1010
- main
11-
- development
12-
13-
# Trigger on any push to a PR that targets main
1411
pull_request:
1512
branches:
1613
- main
17-
- development
18-
1914
permissions:
2015
contents: write
21-
22-
env:
23-
name: "ConfigSpace"
24-
2516
jobs:
26-
build-and-deploy:
17+
build:
2718
runs-on: ubuntu-latest
2819
steps:
29-
- name: Checkout
30-
uses: actions/checkout@v3
31-
32-
- name: Setup Python
33-
uses: actions/setup-python@v3
34-
with:
35-
python-version: "3.8"
36-
37-
- name: Install dependencies
38-
run: |
39-
pip install build
40-
pip install ".[docs]"
41-
42-
- name: Make docs
43-
run: |
44-
make clean
45-
make docs
46-
47-
- name: Pull latest gh-pages
48-
if: (contains(github.ref, 'develop') || contains(github.ref, 'main')) && github.event_name == 'push'
49-
run: |
50-
cd ..
51-
git clone https://github.com/${{ github.repository }}.git --branch gh-pages --single-branch gh-pages
52-
53-
- name: Copy new docs into gh-pages
54-
if: (contains(github.ref, 'develop') || contains(github.ref, 'main')) && github.event_name == 'push'
55-
run: |
56-
branch_name=${GITHUB_REF##*/}
57-
cd ../gh-pages
58-
rm -rf $branch_name
59-
cp -r ../${{ env.name }}/docs/build/html $branch_name
60-
61-
- name: Push to gh-pages
62-
if: (contains(github.ref, 'develop') || contains(github.ref, 'main')) && github.event_name == 'push'
63-
run: |
64-
last_commit=$(git log --pretty=format:"%an: %s")
65-
cd ../gh-pages
66-
branch_name=${GITHUB_REF##*/}
67-
git add $branch_name/
68-
git config --global user.name 'Github Actions'
69-
git config --global user.email 'not@mail.com'
70-
git remote set-url origin https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/${{ github.repository }}
71-
git commit -am "$last_commit"
72-
git push
20+
- uses: actions/checkout@v4
21+
- uses: actions/setup-python@v5
22+
with:
23+
python-version: "3.10"
24+
- name: "Install dependancies"
25+
run: python -m pip install -e ".[dev]"
26+
- name: "Build Docs"
27+
run: mkdocs build --clean --strict

.github/workflows/pytest.yml

Lines changed: 10 additions & 150 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
name: Tests
2+
concurrency:
3+
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
4+
cancel-in-progress: true
25

36
on:
47
# Allow to manually trigger through github API
@@ -8,13 +11,11 @@ on:
811
push:
912
branches:
1013
- main
11-
- development
1214

1315
# Triggers with push to a pr aimed at master
1416
pull_request:
1517
branches:
1618
- main
17-
- development
1819

1920
schedule:
2021
# Every day at 7AM UTC
@@ -31,21 +32,9 @@ env:
3132
--durations=20
3233
-v
3334
34-
# Version to run code-cov on
35-
# NOTE: These are only acessible inside a jobs **steps** and not in the job setup,
36-
# Hence, some of these varialbes are copied and are just here for reference
37-
#
38-
code-cov-active: true # Copied in job setup
39-
code-cov-os: ubuntu-latest # Copied in job setup
40-
code-cov-python-version: "3.8"
41-
code-cov-args: >-
42-
--cov=ConfigSpace
43-
--cov-report=xml
44-
4535
jobs:
36+
test:
4637

47-
# General unit tests
48-
source-test:
4938
name: ${{ matrix.python-version }}-${{ matrix.os }}
5039

5140
runs-on: ${{ matrix.os }}
@@ -56,153 +45,24 @@ jobs:
5645
strategy:
5746
fail-fast: false
5847
matrix:
59-
python-version: ["3.7", "3.8", "3.9", "3.10", "3.11"]
48+
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]
6049
os: ["ubuntu-latest", "macos-latest", "windows-latest"]
6150

6251
steps:
6352
- name: Checkout
64-
uses: actions/checkout@v2
53+
uses: actions/checkout@v4
6554

6655
- name: Setup Python
67-
uses: actions/setup-python@v2
68-
with:
69-
python-version: ${{ matrix.python-version }}
70-
71-
- name: Install ${{ env.package-name }}
72-
run: |
73-
python -m pip install --upgrade pip
74-
python -m pip install -e ".${{ env.extra-requires }}"
75-
76-
- name: Store git status
77-
id: status-before
78-
shell: bash
79-
run: |
80-
echo "::set-output name=BEFORE::$(git status --porcelain -b)"
81-
82-
- name: Tests
83-
timeout-minutes: 45
84-
run: |
85-
pytest ${{ env.pytest-args }} ${{ env.test-dir }}
86-
87-
- name: Check for files left behind by test
88-
run: |
89-
before="${{ steps.status-before.outputs.BEFORE }}"
90-
after="$(git status --porcelain -b)"
91-
if [[ "$before" != "$after" ]]; then
92-
echo "git status from before: $before"
93-
echo "git status from after: $after"
94-
echo "Not all generated files have been deleted!"
95-
exit 1
96-
fi
97-
98-
# Testing with conda
99-
conda-tests:
100-
name: conda-${{ matrix.python-version }}-${{ matrix.os }}
101-
runs-on: ${{ matrix.os }}
102-
defaults:
103-
run:
104-
shell: bash -l {0} # Default to using bash on all and load (-l) .bashrc which miniconda uses
105-
106-
strategy:
107-
fail-fast: false
108-
matrix:
109-
python-version: ["3.7", "3.8", "3.9", "3.10", "3.11"]
110-
os: ["ubuntu-latest", "macos-latest", "windows-latest"]
111-
112-
steps:
113-
- name: Checkout
114-
uses: actions/checkout@v2
115-
116-
- name: Conda install
117-
uses: conda-incubator/setup-miniconda@v2
56+
uses: actions/setup-python@v5
11857
with:
119-
auto-update-conda: true
12058
python-version: ${{ matrix.python-version }}
59+
cache: pip
60+
cache-dependency-path: pyproject.toml
12161

12262
- name: Install ${{ env.package-name }}
12363
run: |
124-
python -V
125-
python -m pip install --upgrade pip
126-
python -m pip install wheel
12764
python -m pip install -e ".${{ env.extra-requires }}"
12865
12966
- name: Tests
130-
timeout-minutes: 45
13167
run: |
132-
pytest ${{ env.pytest-args }} ${{ env.test-dir }}
133-
#
134-
# Testing a dist install
135-
dist-test:
136-
name: dist-${{ matrix.python-version }}-${{ matrix.os }}
137-
138-
runs-on: ${{ matrix.os }}
139-
defaults:
140-
run:
141-
shell: bash
142-
143-
strategy:
144-
fail-fast: false
145-
matrix:
146-
python-version: ["3.7", "3.8", "3.9", "3.10", "3.11"]
147-
os: ["ubuntu-latest", "macos-latest", "windows-latest"]
148-
149-
steps:
150-
- name: Checkout
151-
uses: actions/checkout@v2
152-
153-
- name: Setup Python
154-
uses: actions/setup-python@v2
155-
with:
156-
python-version: ${{ matrix.python-version }}
157-
158-
- name: Create sdist
159-
id: sdist
160-
run: |
161-
python -m pip install --upgrade pip build
162-
python -m build --sdist
163-
echo "sdist_name=$(ls -t dist/${{ env.package-name }}-*.tar.gz | head -n 1)" >> "$GITHUB_ENV"
164-
165-
- name: Install ${{ env.package-name }}
166-
run: |
167-
python -m pip install ${{ env.sdist_name }}${{ env.extra-requires }}
168-
169-
- name: Tests
170-
timeout-minutes: 45
171-
run: |
172-
pytest ${{ env.pytest-args }} ${{ env.test-dir }}
173-
174-
175-
# Testing with codecov coverage uploaded
176-
codecov-test:
177-
name: codecov-test
178-
179-
runs-on: "ubuntu-latest"
180-
defaults:
181-
run:
182-
shell: bash
183-
184-
steps:
185-
- name: Checkout
186-
uses: actions/checkout@v2
187-
188-
- name: Setup Python
189-
uses: actions/setup-python@v2
190-
with:
191-
python-version: ${{ env.code-cov-python-version }}
192-
193-
- name: Install ${{ env.package-name }}
194-
run: |
195-
python -m pip install --upgrade pip
196-
python -m pip install wheel
197-
python -m pip install -e ".${{ env.extra-requires }}"
198-
199-
- name: Tests
200-
timeout-minutes: 45
201-
run: |
202-
pytest ${{ env.pytest-args }} ${{ env.code-cov-args }} ${{ env.test-dir }}
203-
204-
- name: Upload coverage
205-
uses: codecov/codecov-action@v2
206-
with:
207-
fail_ci_if_error: true
208-
verbose: true
68+
pytest ${{ env.test-dir }}

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ docs/examples/*
99
# C extensions
1010
*.so
1111
*.c
12+
*.jukit
1213

1314
# Packages
1415
*.egg
@@ -74,4 +75,5 @@ prof/
7475
.venv
7576

7677
# Running pre-commit seems to generate these
77-
.mypy_cache
78+
.mypy_cache
79+
*.speedscope

.pre-commit-config.yaml

Lines changed: 5 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -38,32 +38,15 @@ repos:
3838
hooks:
3939
- id: mypy
4040
files: '^ConfigSpace/.*\.py$'
41+
additional_dependencies:
42+
- "types-pyyaml"
4143
args:
4244
- "--no-warn-return-any" # Disable this because it doesn't know about 3rd party imports
4345
- "--ignore-missing-imports"
4446
- "--show-traceback"
45-
- id: mypy
46-
files: '^test/.*\.py$'
47-
args:
48-
- "--no-warn-return-any" # Disable this because it doesn't know about 3rd party imports
49-
- "--ignore-missing-imports"
50-
- "--show-traceback"
51-
- "--disable-error-code"
52-
- "no-untyped-def"
53-
54-
- repo: https://github.com/psf/black
55-
rev: 23.3.0
56-
hooks:
57-
- id: black
58-
args: ["--config=pyproject.toml"]
5947
- repo: https://github.com/charliermarsh/ruff-pre-commit
60-
rev: v0.0.263
48+
rev: v0.4.0
6149
hooks:
6250
- id: ruff
63-
args: ["--fix", "ConfigSpace", "test"]
64-
- repo: https://github.com/MarcoGorelli/cython-lint
65-
rev: v0.15.0
66-
hooks:
67-
- id: cython-lint
68-
args: [--ignore=E501]
69-
- id: double-quote-cython-strings
51+
args: [--fix, --exit-non-zero-on-fix, --no-cache]
52+
- id: ruff-format

0 commit comments

Comments
 (0)