Skip to content

Commit 3abca57

Browse files
authored
Merge pull request #263 from optimas-org/feature/optional_ax
Use postponed annotations (PEP 563)
2 parents 73ceea1 + a2ac232 commit 3abca57

File tree

2 files changed

+55
-1
lines changed

2 files changed

+55
-1
lines changed

.github/workflows/unix-noax.yml

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
name: Unix-Without-Ax
2+
3+
on:
4+
pull_request:
5+
# Run daily at midnight (UTC).
6+
schedule:
7+
- cron: '0 0 * * *'
8+
9+
jobs:
10+
test:
11+
runs-on: ubuntu-latest
12+
strategy:
13+
matrix:
14+
python-version: ['3.10', 3.11, 3.12]
15+
16+
steps:
17+
- uses: actions/checkout@v4
18+
- uses: conda-incubator/setup-miniconda@v3
19+
name: Setup conda
20+
with:
21+
auto-update-conda: true
22+
activate-environment: testing
23+
auto-activate-base: false
24+
channels: defaults
25+
channel-priority: true
26+
python-version: ${{ matrix.python-version }}
27+
28+
- shell: bash -l {0}
29+
name: Install dependencies
30+
run: |
31+
conda install numpy pandas pytorch cpuonly -c pytorch
32+
conda install -c conda-forge mpi4py mpich
33+
pip install .[test]
34+
pip uninstall --yes ax-platform # Run without Ax
35+
- shell: bash -l {0}
36+
name: Run unit tests without Ax
37+
run: |
38+
python -m pytest tests/ --ignore=tests/test_ax_generators.py --ignore=tests/test_ax_model_manager.py --ignore=tests/test_gpu_resources.py
39+
mpirun -np 3 python -m pytest --with-mpi tests/test_grid_sampling_mpi.py

optimas/utils/ax/ax_model_manager.py

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,17 @@
11
"""Contains the definition of the AxModelManager class."""
22

3-
from typing import Optional, Union, List, Tuple, Dict, Any, Literal
3+
from __future__ import annotations
4+
5+
from typing import (
6+
Optional,
7+
Union,
8+
List,
9+
Tuple,
10+
Dict,
11+
Any,
12+
Literal,
13+
TYPE_CHECKING,
14+
)
415

516
import numpy as np
617
from numpy.typing import NDArray
@@ -34,6 +45,10 @@
3445
from optimas.core import VaryingParameter, Objective
3546
from optimas.utils.other import convert_to_dataframe
3647

48+
if TYPE_CHECKING:
49+
from ax.service.ax_client import AxClient
50+
from ax.modelbridge.torch import TorchModelBridge
51+
3752

3853
class AxModelManager:
3954
"""Class for building and exploring GP models using an ``AxClient``.

0 commit comments

Comments
 (0)