|
7 | 7 | import importlib |
8 | 8 | from spotpython.utils.eda import gen_design_table |
9 | 9 | from spotpython.utils.init import setup_paths |
| 10 | +import copy |
10 | 11 |
|
11 | 12 |
|
12 | 13 | # from torch.utils.tensorboard import SummaryWriter |
@@ -233,40 +234,28 @@ def load_core_model_from_file(coremodel, dirname="userModel"): |
233 | 234 | return core_model |
234 | 235 |
|
235 | 236 |
|
236 | | -def load_and_run_spot_python_experiment(spot_filename) -> tuple: |
| 237 | +def load_and_run_spot_python_experiment(PREFIX=None, filename=None) -> object: |
237 | 238 | """Loads and runs a spot experiment. |
238 | 239 |
|
239 | 240 | Args: |
240 | | - spot_filename (str): |
241 | | - The name of the spot experiment file. |
| 241 | + PREFIX (str, optional): Prefix of the experiment. Defaults to None. |
| 242 | + filename (str): Name of the pickle file. Defaults to None |
242 | 243 |
|
243 | 244 | Returns: |
244 | | - tuple: A tuple containing the spot tuner, fun control, |
245 | | - design control, surrogate control, optimizer control, |
246 | | - and the tensorboard process object (p_popen). |
247 | | -
|
248 | | - Notes: |
249 | | - p_open is deprecated and should be removed in future versions. |
250 | | - It returns None. |
| 245 | + spot_tuner (Spot): The spot tuner object. |
251 | 246 |
|
252 | 247 | Examples: |
253 | 248 | >>> from spotpython.utils.file import load_and_run_spot_python_experiment |
254 | | - >>> spot_tuner = load_and_run_spot_python_experiment("spot_branin_experiment.pickle") |
| 249 | + >>> spot_tuner = load_and_run_spot_python_experiment(filename="spot_branin_experiment.pickle") |
| 250 | + >>> # Or use PREFIX |
| 251 | + >>> spot_tuner = load_and_run_spot_python_experiment(PREFIX="spot_branin_experiment") |
255 | 252 |
|
256 | 253 | """ |
257 | | - p_open = None |
258 | | - (spot_tuner, fun_control, design_control, surrogate_control, optimizer_control) = load_experiment(spot_filename) |
259 | | - print("\nLoaded fun_control in spotRun():") |
260 | | - # pprint.pprint(fun_control) |
| 254 | + spot_tuner = load_experiment(PREFIX=PREFIX, filename=filename) |
| 255 | + fun_control = copy.copy(spot_tuner.fun_control) |
261 | 256 | print(gen_design_table(fun_control)) |
262 | 257 | setup_paths(fun_control["TENSORBOARD_CLEAN"]) |
263 | 258 | spot_tuner.init_spot_writer() |
264 | | - # if fun_control["tensorboard_start"]: |
265 | | - # p_open = start_tensorboard() |
266 | | - # else: |
267 | | - # p_open = None |
268 | 259 | spot_tuner.run() |
269 | | - # # tensorboard --logdir="runs/" |
270 | | - # stop_tensorboard(p_open) |
271 | 260 | print(gen_design_table(fun_control=fun_control, spot=spot_tuner)) |
272 | | - return spot_tuner, fun_control, design_control, surrogate_control, optimizer_control, p_open |
| 261 | + return spot_tuner |
0 commit comments