Skip to content

Commit

Permalink
Make modular botorch config require Ax 0.3.5 and above
Browse files Browse the repository at this point in the history
  • Loading branch information
madeline-scyphers committed Jul 22, 2024
1 parent 3d32571 commit de06e69
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 2 deletions.
8 changes: 8 additions & 0 deletions boa/config/converters.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
from ax.service.utils.instantiation import TParameterRepresentation
from ax.service.utils.scheduler_options import SchedulerOptions

from boa.utils import check_min_package_version

if TYPE_CHECKING:
from .config import BOAMetric

Expand Down Expand Up @@ -54,6 +56,12 @@ def _gen_strat_converter(gs: Optional[dict] = None) -> dict:
gs["steps"][i] = step
steps.append(step)
continue
if step["model"] == "BOTORCH_MODULAR" and not check_min_package_version("ax-platform", "0.3.5"):
raise ValueError(
"BOTORCH_MODULAR model is not available in BOA with Ax version < 0.3.5. "
"Please upgrade to a newer version of Ax."
)

if "model_kwargs" in step:
if "botorch_acqf_class" in step["model_kwargs"] and not isinstance(
step["model_kwargs"]["botorch_acqf_class"], botorch.acquisition.AcquisitionFunction
Expand Down
4 changes: 4 additions & 0 deletions tests/1unit_tests/test_generation_strategy.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import botorch.models
import gpytorch.kernels
import gpytorch.mlls
import pytest
from ax.modelbridge.generation_strategy import GenerationStep, GenerationStrategy
from ax.modelbridge.registry import Models

Expand Down Expand Up @@ -47,6 +48,9 @@ def test_auto_gen_use_saasbo(saasbo_config, tmp_path):
assert "FullyBayesian" in gs.name


@pytest.importorskip(
"ax-platform", minversion="0.3.5", reason="BOTORCH_MODULAR model is not available in BOA with Ax version < 0.3.5."
)
def test_modular_botorch(gen_strat_modular_botorch_config, tmp_path):
controller = Controller(
config=gen_strat_modular_botorch_config,
Expand Down
16 changes: 14 additions & 2 deletions tests/integration_tests/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
get_trial_dir,
load_jsonlike,
scheduler_from_json_file,
scheduler_to_json_file,
split_shell_command,
)
from boa.cli import main as cli_main
Expand Down Expand Up @@ -80,7 +79,20 @@ def test_calling_command_line_test_script_doesnt_error_out_and_produces_correct_
# (which can customize the GP process even more)
@pytest.mark.parametrize(
"r_scripts_run",
["r_full", "r_light", "r_streamlined", "r_streamlined_botorch_modular"],
[
"r_full",
"r_light",
"r_streamlined",
"r_streamlined_botorch_modular",
pytest.param(
"r_streamlined_botorch_modular",
marks=pytest.importorskip(
"ax-platform",
minversion="0.3.5",
reason="BOTORCH_MODULAR model is not available in BOA with Ax version < 0.3.5.",
),
),
],
)
@pytest.mark.skipif(not R_INSTALLED, reason="requires R to be installed")
def test_calling_command_line_r_test_scripts(r_scripts_run, request):
Expand Down

6 comments on commit de06e69

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Coverage

Coverage Report
FileStmtsMissCoverMissing
__main__.py550%1–2, 7, 10–11
async_opt.py1051882%137, 181, 188, 191, 211–212, 218–219, 221–222, 224, 231–236, 240
ax_instantiation_utils.py47197%120
controller.py76790%73, 84, 176, 183–186
definitions.py80100% 
instantiation_base.py45393%24–25, 48
metaclasses.py72395%50–51, 57
plot.py12120%17, 19–20, 22–23, 26, 29, 36, 42–43, 46–47
plotting.py1412880%51–52, 59, 94–95, 251–253, 301–305, 345, 429–432, 434–441, 443, 448
registry.py260100% 
runner.py53492%54, 88–90
scheduler.py811482%38, 128–131, 138–139, 153, 160–161, 168–169, 264–265
storage.py1241587%83, 115–117, 177, 195, 273–281
template.py31583%52–56
utils.py992079%179, 193–194, 219, 229–233, 235–237, 239, 241, 245–250
config
   __main__.py00100% 
   config.py3073488%33, 211, 217, 221, 223–224, 226, 282, 409, 412, 420–421, 429, 603, 605, 607, 613–617, 619, 690, 723, 744, 751–752, 760, 773, 783–784, 796, 821, 824
   converters.py972475%21, 32, 51, 56–58, 60, 66, 69, 73–74, 77, 80, 83, 86, 89, 93, 97–98, 111, 113, 119, 127, 143
metrics
   metric_funcs.py34488%58, 80–81, 83
   metrics.py1011585%127, 304–305, 310–311, 314, 320, 331–333, 337–341
   modular_metric.py1382482%40–43, 45–52, 66, 137, 148, 172, 188, 197–198, 210, 265–266, 287–288
   synthetic_funcs.py39489%31, 35, 58, 65
scripts
   moo.py30196%44
   run_branin.py34197%56
   script_wrappers.py31293%57–58
   synth_func_cli.py210100% 
wrappers
   base_wrapper.py1953283%63–64, 89–92, 94, 102, 110, 115, 132–133, 147, 156, 167, 215–216, 218, 267, 269, 271, 275, 330, 402, 416, 589, 591–594, 602, 612
   script_wrapper.py1199619%64–66, 91–93, 182–193, 195–197, 199–200, 202–203, 205–208, 262–266, 271–276, 279–286, 309–315, 318, 320–324, 326–330, 332–333, 336–340, 343–355, 363–370, 372–373
   synthetic_wrapper.py16287%16, 28
   wrapper_utils.py1503080%148–149, 247, 299, 415–434, 438–439, 448, 452–453, 456
TOTAL223740481% 

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Coverage

Coverage Report
FileStmtsMissCoverMissing
__main__.py550%1–2, 7, 10–11
async_opt.py1051882%137, 181, 188, 191, 211–212, 218–219, 221–222, 224, 231–236, 240
ax_instantiation_utils.py47197%120
controller.py76790%73, 84, 176, 183–186
definitions.py80100% 
instantiation_base.py45393%24–25, 48
metaclasses.py72395%50–51, 57
plot.py12120%17, 19–20, 22–23, 26, 29, 36, 42–43, 46–47
plotting.py1412880%51–52, 59, 94–95, 251–253, 301–305, 345, 429–432, 434–441, 443, 448
registry.py260100% 
runner.py53492%54, 88–90
scheduler.py811482%38, 128–131, 138–139, 153, 160–161, 168–169, 264–265
storage.py1241587%83, 115–117, 177, 195, 273–281
template.py31583%52–56
utils.py992079%179, 193–194, 219, 229–233, 235–237, 239, 241, 245–250
config
   __main__.py00100% 
   config.py3073488%33, 211, 217, 221, 223–224, 226, 282, 409, 412, 420–421, 429, 603, 605, 607, 613–617, 619, 690, 723, 744, 751–752, 760, 773, 783–784, 796, 821, 824
   converters.py972475%21, 32, 51, 56–58, 60, 66, 69, 73–74, 77, 80, 83, 86, 89, 93, 97–98, 111, 113, 119, 127, 143
metrics
   metric_funcs.py34488%58, 80–81, 83
   metrics.py1011585%127, 304–305, 310–311, 314, 320, 331–333, 337–341
   modular_metric.py1382482%40–43, 45–52, 66, 137, 148, 172, 188, 197–198, 210, 265–266, 287–288
   synthetic_funcs.py39489%31, 35, 58, 65
scripts
   moo.py30196%44
   run_branin.py34197%56
   script_wrappers.py31293%57–58
   synth_func_cli.py210100% 
wrappers
   base_wrapper.py1953283%63–64, 89–92, 94, 102, 110, 115, 132–133, 147, 156, 167, 215–216, 218, 267, 269, 271, 275, 330, 402, 416, 589, 591–594, 602, 612
   script_wrapper.py1199619%64–66, 91–93, 182–193, 195–197, 199–200, 202–203, 205–208, 262–266, 271–276, 279–286, 309–315, 318, 320–324, 326–330, 332–333, 336–340, 343–355, 363–370, 372–373
   synthetic_wrapper.py16287%16, 28
   wrapper_utils.py1503080%148–149, 247, 299, 415–434, 438–439, 448, 452–453, 456
TOTAL223740481% 

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Coverage

Coverage Report
FileStmtsMissCoverMissing
__main__.py550%1–2, 7, 10–11
async_opt.py1051882%137, 181, 188, 193, 211–212, 218–219, 221–222, 224, 231–236, 240
ax_instantiation_utils.py47197%120
controller.py76790%73, 84, 176, 183–186
definitions.py80100% 
instantiation_base.py45393%24–25, 48
metaclasses.py72395%50–51, 57
plot.py12120%17, 19–20, 22–23, 26, 29, 36, 42–43, 46–47
plotting.py1412880%51–52, 59, 94–95, 251–253, 301–305, 345, 429–432, 434–441, 443, 448
registry.py260100% 
runner.py53492%54, 88–90
scheduler.py811482%38, 128–131, 138–139, 153, 160–161, 168–169, 264–265
storage.py1241587%83, 115–117, 177, 195, 273–281
template.py31583%52–56
utils.py992079%179, 193–194, 219, 229–233, 235–237, 239, 241, 245–250
config
   __main__.py00100% 
   config.py3073488%33, 211, 217, 221, 223–224, 226, 282, 409, 412, 420–421, 429, 603, 605, 607, 613–617, 619, 690, 723, 744, 751–752, 760, 773, 783–784, 796, 821, 824
   converters.py972475%21, 32, 51, 56–58, 60, 66, 69, 73–74, 77, 80, 83, 86, 89, 93, 97–98, 111, 113, 119, 127, 143
metrics
   metric_funcs.py34488%58, 80–81, 83
   metrics.py1011585%127, 304–305, 310–311, 314, 320, 331–333, 337–341
   modular_metric.py1382482%40–43, 45–52, 66, 137, 148, 172, 188, 197–198, 210, 265–266, 287–288
   synthetic_funcs.py39489%31, 35, 58, 65
scripts
   moo.py30196%44
   run_branin.py34197%56
   script_wrappers.py31293%57–58
   synth_func_cli.py210100% 
wrappers
   base_wrapper.py1953283%63–64, 89–92, 94, 102, 110, 115, 132–133, 147, 156, 167, 215–216, 218, 267, 269, 271, 275, 330, 402, 416, 589, 591–594, 602, 612
   script_wrapper.py1199619%64–66, 91–93, 182–193, 195–197, 199–200, 202–203, 205–208, 262–266, 271–276, 279–286, 309–315, 318, 320–324, 326–330, 332–333, 336–340, 343–355, 363–370, 372–373
   synthetic_wrapper.py16287%16, 28
   wrapper_utils.py1503080%148–149, 247, 299, 415–434, 438–439, 448, 452–453, 456
TOTAL223740481% 

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Coverage

Coverage Report
FileStmtsMissCoverMissing
__main__.py550%1–2, 7, 10–11
async_opt.py1051882%137, 181, 188, 193, 211–212, 218–219, 221–222, 224, 231–236, 240
ax_instantiation_utils.py470100% 
controller.py76790%73, 84, 176, 183–186
definitions.py80100% 
instantiation_base.py45393%24–25, 48
metaclasses.py72395%50–51, 57
plot.py12120%17, 19–20, 22–23, 26, 29, 36, 42–43, 46–47
plotting.py1412880%51–52, 59, 94–95, 251–253, 301–305, 345, 429–432, 434–441, 443, 448
registry.py260100% 
runner.py53492%54, 88–90
scheduler.py811482%38, 128–131, 138–139, 153, 160–161, 168–169, 264–265
storage.py1241587%83, 115–117, 177, 195, 273–281
template.py31583%52–56
utils.py992079%179, 193–194, 219, 229–233, 235–237, 239, 241, 245–250
config
   __main__.py00100% 
   config.py3073488%33, 211, 217, 221, 223–224, 226, 282, 409, 412, 420–421, 429, 603, 605, 607, 613–617, 619, 690, 723, 744, 751–752, 760, 773, 783–784, 796, 821, 824
   converters.py972475%21, 32, 51, 56–58, 60, 66, 69, 73–74, 77, 80, 83, 86, 89, 93, 97–98, 111, 113, 119, 127, 143
metrics
   metric_funcs.py34488%58, 80–81, 83
   metrics.py1011585%127, 304–305, 310–311, 314, 320, 331–333, 337–341
   modular_metric.py1382482%40–43, 45–52, 66, 137, 148, 172, 188, 197–198, 210, 265–266, 287–288
   synthetic_funcs.py39489%31, 35, 58, 65
scripts
   moo.py30196%44
   run_branin.py34197%56
   script_wrappers.py31293%57–58
   synth_func_cli.py210100% 
wrappers
   base_wrapper.py1953283%63–64, 89–92, 94, 102, 110, 115, 132–133, 147, 156, 167, 215–216, 218, 267, 269, 271, 275, 330, 402, 416, 589, 591–594, 602, 612
   script_wrapper.py1199619%64–66, 91–93, 182–193, 195–197, 199–200, 202–203, 205–208, 262–266, 271–276, 279–286, 309–315, 318, 320–324, 326–330, 332–333, 336–340, 343–355, 363–370, 372–373
   synthetic_wrapper.py16287%16, 28
   wrapper_utils.py1503080%148–149, 247, 299, 415–434, 438–439, 448, 452–453, 456
TOTAL223740381% 

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Coverage

Coverage Report
FileStmtsMissCoverMissing
__main__.py550%1–2, 7, 10–11
async_opt.py1051882%137, 181, 188, 193, 211–212, 218–219, 221–222, 224, 231–236, 240
ax_instantiation_utils.py470100% 
controller.py76790%73, 84, 176, 183–186
definitions.py80100% 
instantiation_base.py45393%24–25, 48
metaclasses.py72395%50–51, 57
plot.py12120%17, 19–20, 22–23, 26, 29, 36, 42–43, 46–47
plotting.py1412880%51–52, 59, 94–95, 251–253, 301–305, 345, 429–432, 434–441, 443, 448
registry.py260100% 
runner.py53492%54, 88–90
scheduler.py811482%38, 128–131, 138–139, 153, 160–161, 168–169, 264–265
storage.py1241587%83, 115–117, 177, 195, 273–281
template.py31583%52–56
utils.py992079%179, 193–194, 219, 229–233, 235–237, 239, 241, 245–250
config
   __main__.py00100% 
   config.py3073488%33, 211, 217, 221, 223–224, 226, 282, 409, 412, 420–421, 429, 603, 605, 607, 613–617, 619, 690, 723, 744, 751–752, 760, 773, 783–784, 796, 821, 824
   converters.py972475%21, 32, 51, 56–58, 60, 66, 69, 73–74, 77, 80, 83, 86, 89, 93, 97–98, 111, 113, 119, 127, 143
metrics
   metric_funcs.py34488%58, 80–81, 83
   metrics.py1011585%127, 304–305, 310–311, 314, 320, 331–333, 337–341
   modular_metric.py1382482%40–43, 45–52, 66, 137, 148, 172, 188, 197–198, 210, 265–266, 287–288
   synthetic_funcs.py39489%31, 35, 58, 65
scripts
   moo.py30196%44
   run_branin.py34197%56
   script_wrappers.py31293%57–58
   synth_func_cli.py210100% 
wrappers
   base_wrapper.py1953283%63–64, 89–92, 94, 102, 110, 115, 132–133, 147, 156, 167, 215–216, 218, 267, 269, 271, 275, 330, 402, 416, 589, 591–594, 602, 612
   script_wrapper.py1199619%64–66, 91–93, 182–193, 195–197, 199–200, 202–203, 205–208, 262–266, 271–276, 279–286, 309–315, 318, 320–324, 326–330, 332–333, 336–340, 343–355, 363–370, 372–373
   synthetic_wrapper.py16287%16, 28
   wrapper_utils.py1503080%148–149, 247, 299, 415–434, 438–439, 448, 452–453, 456
TOTAL223740381% 

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Coverage

Coverage Report
FileStmtsMissCoverMissing
__main__.py550%1–2, 7, 10–11
async_opt.py1051882%137, 181, 188, 193, 211–212, 218–219, 221–222, 224, 231–236, 240
ax_instantiation_utils.py47197%120
controller.py76790%73, 84, 176, 183–186
definitions.py80100% 
instantiation_base.py45393%24–25, 48
metaclasses.py72395%50–51, 57
plot.py12120%17, 19–20, 22–23, 26, 29, 36, 42–43, 46–47
plotting.py1412880%51–52, 59, 94–95, 251–253, 301–305, 345, 429–432, 434–441, 443, 448
registry.py260100% 
runner.py53492%54, 88–90
scheduler.py811482%38, 128–131, 138–139, 153, 160–161, 168–169, 264–265
storage.py1241587%83, 115–117, 177, 195, 273–281
template.py31583%52–56
utils.py992079%179, 193–194, 219, 229–233, 235–237, 239, 241, 245–250
config
   __main__.py00100% 
   config.py3073488%33, 211, 217, 221, 223–224, 226, 282, 409, 412, 420–421, 429, 603, 605, 607, 613–617, 619, 690, 723, 744, 751–752, 760, 773, 783–784, 796, 821, 824
   converters.py972475%21, 32, 51, 56–58, 60, 66, 69, 73–74, 77, 80, 83, 86, 89, 93, 97–98, 111, 113, 119, 127, 143
metrics
   metric_funcs.py34488%58, 80–81, 83
   metrics.py1011585%127, 304–305, 310–311, 314, 320, 331–333, 337–341
   modular_metric.py1382482%40–43, 45–52, 66, 137, 148, 172, 188, 197–198, 210, 265–266, 287–288
   synthetic_funcs.py39489%31, 35, 58, 65
scripts
   moo.py30196%44
   run_branin.py34197%56
   script_wrappers.py31293%57–58
   synth_func_cli.py210100% 
wrappers
   base_wrapper.py1953283%63–64, 89–92, 94, 102, 110, 115, 132–133, 147, 156, 167, 215–216, 218, 267, 269, 271, 275, 330, 402, 416, 589, 591–594, 602, 612
   script_wrapper.py1199619%64–66, 91–93, 182–193, 195–197, 199–200, 202–203, 205–208, 262–266, 271–276, 279–286, 309–315, 318, 320–324, 326–330, 332–333, 336–340, 343–355, 363–370, 372–373
   synthetic_wrapper.py16287%16, 28
   wrapper_utils.py1503080%148–149, 247, 299, 415–434, 438–439, 448, 452–453, 456
TOTAL223740481% 

Please sign in to comment.