|
6 | 6 | import sys |
7 | 7 | import importlib |
8 | 8 | from spotPython.hyperparameters.values import get_tuned_architecture |
| 9 | +import pprint |
| 10 | +from spotPython.utils.eda import gen_design_table |
| 11 | +from spotPython.utils.tensorboard import start_tensorboard, stop_tensorboard |
| 12 | + |
9 | 13 |
|
10 | 14 | # from torch.utils.tensorboard import SummaryWriter |
11 | 15 |
|
@@ -216,3 +220,33 @@ def get_experiment_from_PREFIX(PREFIX, return_dict=True) -> dict: |
216 | 220 | } |
217 | 221 | else: |
218 | 222 | return config, fun_control, design_control, surrogate_control, optimizer_control |
| 223 | + |
| 224 | + |
| 225 | +def load_and_run_spot_python_experiment(spot_pkl_name) -> tuple: |
| 226 | + """Loads and runs a spot experiment. |
| 227 | +
|
| 228 | + Args: |
| 229 | + spot_pkl_name (str): |
| 230 | + The name of the spot experiment file. |
| 231 | +
|
| 232 | + Returns: |
| 233 | + tuple: A tuple containing the spot tuner, fun control, |
| 234 | + design control, surrogate control, optimizer control, |
| 235 | + and the tensorboard process |
| 236 | +
|
| 237 | + Examples: |
| 238 | + >>> from spotPython.utils.file import load_and_run_spot_python_experiment |
| 239 | + >>> spot_tuner = load_and_run_spot_python_experiment("spot_branin_experiment.pickle") |
| 240 | +
|
| 241 | + """ |
| 242 | + p_open = None |
| 243 | + (spot_tuner, fun_control, design_control, surrogate_control, optimizer_control) = load_experiment(spot_pkl_name) |
| 244 | + print("\nLoaded fun_control in spotRun():") |
| 245 | + pprint.pprint(fun_control) |
| 246 | + print(gen_design_table(fun_control)) |
| 247 | + p_open = start_tensorboard() |
| 248 | + spot_tuner.run() |
| 249 | + spot_tuner.save_experiment() |
| 250 | + # tensorboard --logdir="runs/" |
| 251 | + stop_tensorboard(p_open) |
| 252 | + return spot_tuner, fun_control, design_control, surrogate_control, optimizer_control, p_open |
0 commit comments