Skip to content

Commit

Permalink
Fix tests to point to new CLI entry func from dunder main
Browse files Browse the repository at this point in the history
  • Loading branch information
madeline-scyphers committed Jul 19, 2024
1 parent 21e3637 commit 979df83
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 14 deletions.
12 changes: 6 additions & 6 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@

import pytest

import boa.__main__ as dunder_main
import boa.scripts.moo as run_moo
import boa.scripts.run_branin as run_branin
from boa import BOAConfig, cd_and_cd_back, split_shell_command
from boa.cli import main as cli_main
from boa.definitions import ROOT, TEST_SCRIPTS_DIR

logger = logging.getLogger(__file__)
Expand Down Expand Up @@ -192,7 +192,7 @@ def denormed_custom_wrapper_run(tmp_path_factory, cd_to_root_and_back_session):
config_path = temp_dir / "different_name_config.json"
with open(Path(config_path), "w") as file:
json.dump(config, file)
scheduler = dunder_main.main(split_shell_command(f"--config-path {config_path} -td"), standalone_mode=False)
scheduler = cli_main(split_shell_command(f"--config-path {config_path} -td"), standalone_mode=False)
os.remove(config_path)
yield scheduler

Expand All @@ -211,25 +211,25 @@ def moo_main_run(tmp_path_factory, cd_to_root_and_back_session):
def stand_alone_opt_package_run(tmp_path_factory, cd_to_root_and_back_session):
config_path = TEST_DIR / "scripts/stand_alone_opt_package/stand_alone_pkg_config.yaml"
args = f"--config-path {config_path} -td"
yield dunder_main.main(split_shell_command(args), standalone_mode=False)
yield cli_main(split_shell_command(args), standalone_mode=False)


@pytest.fixture(scope="session")
def r_full(tmp_path_factory, cd_to_root_and_back_session):
config_path = TEST_DIR / f"scripts/other_langs/r_package_full/config.yaml"

yield dunder_main.main(split_shell_command(f"--config-path {config_path} -td"), standalone_mode=False)
yield cli_main(split_shell_command(f"--config-path {config_path} -td"), standalone_mode=False)


@pytest.fixture(scope="session")
def r_light(tmp_path_factory, cd_to_root_and_back_session):
config_path = TEST_DIR / f"scripts/other_langs/r_package_light/config.yaml"

yield dunder_main.main(split_shell_command(f"--config-path {config_path} -td"), standalone_mode=False)
yield cli_main(split_shell_command(f"--config-path {config_path} -td"), standalone_mode=False)


@pytest.fixture(scope="session")
def r_streamlined(tmp_path_factory, cd_to_root_and_back_session):
config_path = TEST_DIR / f"scripts/other_langs/r_package_streamlined/config.yaml"

yield dunder_main.main(split_shell_command(f"--config-path {config_path} -td"), standalone_mode=False)
yield cli_main(split_shell_command(f"--config-path {config_path} -td"), standalone_mode=False)
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import pytest
from ax.service.scheduler import FailureRateExceededError

import boa.__main__ as dunder_main
from boa import (
BaseWrapper,
BOAConfig,
Expand All @@ -16,6 +15,7 @@
scheduler_to_json_file,
split_shell_command,
)
from boa.cli import main as cli_main
from boa.definitions import ROOT

try:
Expand Down Expand Up @@ -110,22 +110,22 @@ def test_calling_command_line_r_test_scripts(r_scripts_run, request):
def test_cli_interface_with_failing_test_that_sends_back_failed_trial_status():
with pytest.raises(FailureRateExceededError):
config_path = ROOT / "tests" / f"scripts/other_langs/r_package_streamlined/config_fail.yaml"
dunder_main.main(split_shell_command(f"--config-path {config_path} -td"), standalone_mode=False)
cli_main(split_shell_command(f"--config-path {config_path} -td"), standalone_mode=False)


@pytest.mark.skipif(not R_INSTALLED, reason="requires R to be installed")
def test_cli_interface_with_failing_test_that_sends_back_failed_trial_status():
with pytest.raises(FailureRateExceededError):
config_path = ROOT / "tests" / f"scripts/other_langs/r_pass_back_fail_trial_status/config.yaml"
dunder_main.main(split_shell_command(f"--config-path {config_path} -td"), standalone_mode=False)
cli_main(split_shell_command(f"--config-path {config_path} -td"), standalone_mode=False)


def test_wrapper_with_custom_load_config():
# This should fail with a failing config
config_path = ROOT / "tests" / f"scripts/other_langs/r_package_streamlined/config_fail.yaml"
# But we override the failing config in our wrapper with a working one in a custom load_config
wrapper_path = Path(__file__)
dunder_main.main(
cli_main(
split_shell_command(
f"--config-path {config_path}"
f" --wrapper-path {wrapper_path}"
Expand Down Expand Up @@ -153,10 +153,10 @@ def test_parallelism(r_light, caplog):
def test_non_zero_exit_code_fails_trial():
with pytest.raises(FailureRateExceededError):
config_path = ROOT / "tests" / f"scripts/other_langs/r_failure_exit_code/config.yaml"
dunder_main.main(split_shell_command(f"--config-path {config_path} -td"), standalone_mode=False)
cli_main(split_shell_command(f"--config-path {config_path} -td"), standalone_mode=False)


def test_return_nan_fails_trial():
with pytest.raises(FailureRateExceededError):
config_path = ROOT / "tests" / f"scripts/other_langs/r_failure_nan/config.yaml"
dunder_main.main(split_shell_command(f"--config-path {config_path} -td"), standalone_mode=False)
cli_main(split_shell_command(f"--config-path {config_path} -td"), standalone_mode=False)
4 changes: 2 additions & 2 deletions tests/integration_tests/test_storage.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
CORE_ENCODER_REGISTRY,
)

import boa.__main__ as dunder_main
from boa import (
BaseWrapper,
BOAConfig,
Expand All @@ -31,6 +30,7 @@
split_shell_command,
)
from boa.__version__ import __version__
from boa.cli import main as cli_main
from boa.definitions import ROOT

TEST_DIR = ROOT / "tests"
Expand Down Expand Up @@ -200,7 +200,7 @@ def test_can_pass_custom_wrapper_path_when_loading_scheduler_from_cli(stand_alon

pre_num_trials = len(scheduler.experiment.trials)

scheduler = dunder_main.main(
scheduler = cli_main(
split_shell_command(f"--scheduler-path {file_out} --wrapper-path {orig_wrapper_path} -td"),
standalone_mode=False,
)
Expand Down

6 comments on commit 979df83

@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.py76396%73, 84, 176
definitions.py80100% 
instantiation_base.py45197%48
metaclasses.py72395%50–51, 57
plot.py12120%15, 17–18, 20–21, 24, 27, 34, 40–41, 44–45
plotting.py1412880%51–52, 59, 94–95, 251–253, 301–305, 345, 429–432, 434–441, 443, 448
registry.py80100% 
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.py781383%14, 25, 44, 49–51, 54–55, 68, 70, 76, 84, 100
metrics
   metric_funcs.py34488%58, 80–81, 83
   metrics.py1011585%127, 304–305, 310–311, 314, 320, 331–333, 337–341
   modular_metric.py1382184%40–43, 45–52, 66, 137, 148, 172, 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.py1953084%63–64, 89–92, 94, 102, 110, 115, 147, 156, 167, 215–216, 218, 267, 269, 271, 275, 330, 402, 416, 589, 591–594, 602, 612
   script_wrapper.py1191190%196, 207–208, 276, 279–281, 285, 326, 345, 350
   synthetic_wrapper.py16287%16, 28
   wrapper_utils.py150994%148–149, 247, 299, 423–425, 433–434
TOTAL220027687% 

@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.py76396%73, 84, 176
definitions.py80100% 
instantiation_base.py45197%48
metaclasses.py72395%50–51, 57
plot.py12120%15, 17–18, 20–21, 24, 27, 34, 40–41, 44–45
plotting.py1412880%51–52, 59, 94–95, 251–253, 301–305, 345, 429–432, 434–441, 443, 448
registry.py80100% 
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.py781383%14, 25, 44, 49–51, 54–55, 68, 70, 76, 84, 100
metrics
   metric_funcs.py34488%58, 80–81, 83
   metrics.py1011585%127, 304–305, 310–311, 314, 320, 331–333, 337–341
   modular_metric.py1382184%40–43, 45–52, 66, 137, 148, 172, 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.py1953084%63–64, 89–92, 94, 102, 110, 115, 147, 156, 167, 215–216, 218, 267, 269, 271, 275, 330, 402, 416, 589, 591–594, 602, 612
   script_wrapper.py1191190%196, 207–208, 276, 279–281, 285, 326, 345, 350
   synthetic_wrapper.py16287%16, 28
   wrapper_utils.py150994%148–149, 247, 299, 423–425, 433–434
TOTAL220027687% 

@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.py76396%73, 84, 176
definitions.py80100% 
instantiation_base.py45197%48
metaclasses.py72395%50–51, 57
plot.py12120%15, 17–18, 20–21, 24, 27, 34, 40–41, 44–45
plotting.py1412880%51–52, 59, 94–95, 251–253, 301–305, 345, 429–432, 434–441, 443, 448
registry.py80100% 
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.py781383%14, 25, 44, 49–51, 54–55, 68, 70, 76, 84, 100
metrics
   metric_funcs.py34488%58, 80–81, 83
   metrics.py1011585%127, 304–305, 310–311, 314, 320, 331–333, 337–341
   modular_metric.py1382184%40–43, 45–52, 66, 137, 148, 172, 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.py1953084%63–64, 89–92, 94, 102, 110, 115, 147, 156, 167, 215–216, 218, 267, 269, 271, 275, 330, 402, 416, 589, 591–594, 602, 612
   script_wrapper.py1191190%196, 207–208, 276, 279–281, 285, 326, 345, 350
   synthetic_wrapper.py16287%16, 28
   wrapper_utils.py150994%148–149, 247, 299, 423–425, 433–434
TOTAL220027687% 

@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.py76396%73, 84, 176
definitions.py80100% 
instantiation_base.py45197%48
metaclasses.py72395%50–51, 57
plot.py12120%15, 17–18, 20–21, 24, 27, 34, 40–41, 44–45
plotting.py1412880%51–52, 59, 94–95, 251–253, 301–305, 345, 429–432, 434–441, 443, 448
registry.py80100% 
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.py781383%14, 25, 44, 49–51, 54–55, 68, 70, 76, 84, 100
metrics
   metric_funcs.py34488%58, 80–81, 83
   metrics.py1011585%127, 304–305, 310–311, 314, 320, 331–333, 337–341
   modular_metric.py1382184%40–43, 45–52, 66, 137, 148, 172, 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.py1953084%63–64, 89–92, 94, 102, 110, 115, 147, 156, 167, 215–216, 218, 267, 269, 271, 275, 330, 402, 416, 589, 591–594, 602, 612
   script_wrapper.py1191190%196, 207–208, 276, 279–281, 285, 326, 345, 350
   synthetic_wrapper.py16287%16, 28
   wrapper_utils.py150994%148–149, 247, 299, 423–425, 433–434
TOTAL220027587% 

@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.py76396%73, 84, 176
definitions.py80100% 
instantiation_base.py45197%48
metaclasses.py72395%50–51, 57
plot.py12120%15, 17–18, 20–21, 24, 27, 34, 40–41, 44–45
plotting.py1412880%51–52, 59, 94–95, 251–253, 301–305, 345, 429–432, 434–441, 443, 448
registry.py80100% 
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.py781383%14, 25, 44, 49–51, 54–55, 68, 70, 76, 84, 100
metrics
   metric_funcs.py34488%58, 80–81, 83
   metrics.py1011585%127, 304–305, 310–311, 314, 320, 331–333, 337–341
   modular_metric.py1382184%40–43, 45–52, 66, 137, 148, 172, 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.py1953084%63–64, 89–92, 94, 102, 110, 115, 147, 156, 167, 215–216, 218, 267, 269, 271, 275, 330, 402, 416, 589, 591–594, 602, 612
   script_wrapper.py1191190%196, 207–208, 276, 279–281, 285, 326, 345, 350
   synthetic_wrapper.py16287%16, 28
   wrapper_utils.py150994%148–149, 247, 299, 423–425, 433–434
TOTAL220027687% 

@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.py76396%73, 84, 176
definitions.py80100% 
instantiation_base.py45197%48
metaclasses.py72395%50–51, 57
plot.py12120%15, 17–18, 20–21, 24, 27, 34, 40–41, 44–45
plotting.py1412880%51–52, 59, 94–95, 251–253, 301–305, 345, 429–432, 434–441, 443, 448
registry.py80100% 
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.py781383%14, 25, 44, 49–51, 54–55, 68, 70, 76, 84, 100
metrics
   metric_funcs.py34488%58, 80–81, 83
   metrics.py1011585%127, 304–305, 310–311, 314, 320, 331–333, 337–341
   modular_metric.py1382184%40–43, 45–52, 66, 137, 148, 172, 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.py1953084%63–64, 89–92, 94, 102, 110, 115, 147, 156, 167, 215–216, 218, 267, 269, 271, 275, 330, 402, 416, 589, 591–594, 602, 612
   script_wrapper.py1191190%196, 207–208, 276, 279–281, 285, 326, 345, 350
   synthetic_wrapper.py16287%16, 28
   wrapper_utils.py150994%148–149, 247, 299, 423–425, 433–434
TOTAL220027587% 

Please sign in to comment.