Skip to content

Commit 8a94b9c

Browse files
0.14.58
New: load_and_run_spot_python_experiment()
1 parent c2ca9c5 commit 8a94b9c

2 files changed

Lines changed: 35 additions & 1 deletion

File tree

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ build-backend = "setuptools.build_meta"
77

88
[project]
99
name = "spotpython"
10-
version = "0.14.57"
10+
version = "0.14.58"
1111
authors = [
1212
{ name="T. Bartz-Beielstein", email="tbb@bartzundbartz.de" }
1313
]

src/spotPython/utils/file.py

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@
66
import sys
77
import importlib
88
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+
913

1014
# from torch.utils.tensorboard import SummaryWriter
1115

@@ -216,3 +220,33 @@ def get_experiment_from_PREFIX(PREFIX, return_dict=True) -> dict:
216220
}
217221
else:
218222
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

Comments
 (0)