Skip to content

Automatic Environment Handling #6

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 12 commits into
base: main
Choose a base branch
from
27 changes: 21 additions & 6 deletions hposuite/study.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import hashlib
import logging
import subprocess
import warnings
from collections.abc import Iterable, Mapping
from dataclasses import dataclass, field
Expand Down Expand Up @@ -824,12 +825,26 @@ def optimize( # noqa: C901, PLR0912
for i, run in enumerate(self.experiments, start=1):
if auto_env_handling:
run.create_env(hposuite=f"-e {HPOSUITE_EDITABLE}")
logger.info(f"Running experiment {i}/{len(self.experiments)}")
run.run(
continuations=continuations,
overwrite=overwrite,
progress_bar=False
)
logger.info(f"Running experiment {i}/{len(self.experiments)}")
run_cmd = [
'from hposuite.run import Run; '
f'run = Run.from_yaml("{run.run_yaml_path}");'
f'run.run(continuations={continuations}, '
f'overwrite={overwrite}, auto_env_handling=True)'
]
cmd = [run.venv.python, "-c", *run_cmd]
logger.debug(f"Running command: {cmd}")
subprocess.run( # noqa: S603
cmd,
check=True,
)
else:
logger.info(f"Running experiment {i}/{len(self.experiments)}")
run.run(
continuations=continuations,
overwrite=overwrite,
progress_bar=False
)
case "parallel":
raise NotImplementedError("Parallel execution not implemented yet!")
case _:
Expand Down