Skip to content

Commit 71ad083

Browse files
authored
Merge pull request #133 from automl/fix-config-usage
Fix use of config
2 parents 9439b97 + a3d3690 commit 71ad083

File tree

14 files changed

+67
-61
lines changed

14 files changed

+67
-61
lines changed

deepcave/__init__.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -137,15 +137,24 @@ def get_app(title: str) -> Any:
137137
try:
138138
from deepcave.runs.objective import Objective # noqa
139139
from deepcave.runs.recorder import Recorder # noqa
140+
from deepcave.utils.configs import parse_config
141+
from deepcave.utils.notification import Notification
140142

141-
__all__ = ["version", "Recorder", "Objective"]
143+
config_name = None
144+
if "--config" in sys.argv:
145+
config_name = sys.argv[sys.argv.index("--config") + 1]
146+
config = parse_config(config_name)
147+
148+
# Notifications
149+
notification = Notification()
150+
151+
__all__ = ["version", "Recorder", "Objective", "notification", "config"]
142152
except ModuleNotFoundError:
143153
__all__ = ["version"]
144154

145155

146156
_api_mode = False if "app" in globals() else True
147157

148-
149158
# This TypeVar is necessary to ensure that the decorator works with arbitrary signatures.
150159
F = TypeVar("F", bound=Callable[..., Any])
151160

deepcave/plugins/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,9 +115,9 @@ def get_base_url(cls) -> str:
115115
str
116116
Url for the plugin as string.
117117
"""
118-
from deepcave.config import Config
118+
from deepcave import config
119119

120-
return f"http://{Config.DASH_ADDRESS}:{Config.DASH_PORT}/plugins/{cls.id}"
120+
return f"http://{config.DASH_ADDRESS}:{config.DASH_PORT}/plugins/{cls.id}"
121121

122122
@staticmethod
123123
def check_run_compatibility(run: AbstractRun) -> bool:

deepcave/plugins/budget/budget_correlation.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,7 @@
1919
from dash import dcc, html
2020
from scipy import stats
2121

22-
from deepcave import notification
23-
from deepcave.config import Config
22+
from deepcave import config, notification
2423
from deepcave.plugins.dynamic import DynamicPlugin
2524
from deepcave.runs import AbstractRun, Status
2625
from deepcave.utils.layout import create_table, get_select_options
@@ -229,9 +228,9 @@ def get_output_layout(register: Callable) -> List[Any]:
229228
dbc.Tab(
230229
dcc.Graph(
231230
id=register("graph", "figure"),
232-
style={"height": Config.FIGURE_HEIGHT},
231+
style={"height": config.FIGURE_HEIGHT},
233232
config={
234-
"toImageButtonOptions": {"scale": Config.FIGURE_DOWNLOAD_SCALE}
233+
"toImageButtonOptions": {"scale": config.FIGURE_DOWNLOAD_SCALE}
235234
},
236235
),
237236
label="Graph",
@@ -310,7 +309,7 @@ def load_outputs(run, _, outputs) -> List[Any]: # type: ignore
310309
layout = go.Layout(
311310
xaxis=dict(title="Budget"),
312311
yaxis=dict(title="Correlation"),
313-
margin=Config.FIGURE_MARGIN,
312+
margin=config.FIGURE_MARGIN,
314313
legend=dict(title="Budgets"),
315314
)
316315

deepcave/plugins/hyperparameter/importances.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
from dash import dcc, html
2121
from dash.exceptions import PreventUpdate
2222

23-
from deepcave.config import Config
23+
from deepcave import config
2424
from deepcave.evaluators.fanova import fANOVA as GlobalEvaluator
2525
from deepcave.evaluators.lpi import LPI as LocalEvaluator
2626
from deepcave.plugins.static import StaticPlugin
@@ -359,8 +359,8 @@ def get_output_layout(register: Callable) -> dcc.Graph:
359359
"""
360360
return dcc.Graph(
361361
register("graph", "figure"),
362-
style={"height": Config.FIGURE_HEIGHT},
363-
config={"toImageButtonOptions": {"scale": Config.FIGURE_DOWNLOAD_SCALE}},
362+
style={"height": config.FIGURE_HEIGHT},
363+
config={"toImageButtonOptions": {"scale": config.FIGURE_DOWNLOAD_SCALE}},
364364
)
365365

366366
@staticmethod
@@ -456,7 +456,7 @@ def load_outputs(run, inputs, outputs) -> go.Figure: # type: ignore
456456
barmode="group",
457457
yaxis_title="Importance",
458458
legend={"title": "Budget"},
459-
margin=Config.FIGURE_MARGIN,
459+
margin=config.FIGURE_MARGIN,
460460
xaxis=dict(tickangle=-45),
461461
)
462462
save_image(figure, "importances.pdf")

deepcave/plugins/hyperparameter/pdp.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
from dash import dcc, html
2626
from pyPDP.algorithms.pdp import PDP
2727

28-
from deepcave.config import Config
28+
from deepcave import config
2929
from deepcave.evaluators.epm.random_forest_surrogate import RandomForestSurrogate
3030
from deepcave.plugins.static import StaticPlugin
3131
from deepcave.runs import Status
@@ -368,8 +368,8 @@ def get_output_layout(register: Callable) -> dcc.Graph:
368368
"""
369369
return dcc.Graph(
370370
register("graph", "figure"),
371-
style={"height": Config.FIGURE_HEIGHT},
372-
config={"toImageButtonOptions": {"scale": Config.FIGURE_DOWNLOAD_SCALE}},
371+
style={"height": config.FIGURE_HEIGHT},
372+
config={"toImageButtonOptions": {"scale": config.FIGURE_DOWNLOAD_SCALE}},
373373
)
374374

375375
@staticmethod
@@ -507,7 +507,7 @@ def get_pdp_figure( # type: ignore
507507
dict(
508508
xaxis=dict(tickvals=x_tickvals, ticktext=x_ticktext, title=hp1_name),
509509
yaxis=dict(tickvals=y_tickvals, ticktext=y_ticktext, title=hp2_name),
510-
margin=Config.FIGURE_MARGIN,
510+
margin=config.FIGURE_MARGIN,
511511
title=title,
512512
)
513513
)

deepcave/plugins/hyperparameter/symbolic_explanations.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
from gplearn.genetic import SymbolicRegressor
2828
from pyPDP.algorithms.pdp import PDP
2929

30-
from deepcave.config import Config
30+
from deepcave import config
3131
from deepcave.evaluators.epm.random_forest_surrogate import RandomForestSurrogate
3232
from deepcave.plugins.hyperparameter.pdp import PartialDependencies
3333
from deepcave.plugins.static import StaticPlugin
@@ -493,13 +493,13 @@ def get_output_layout(register: Callable) -> List[dcc.Graph]:
493493
return [
494494
dcc.Graph(
495495
register("symb_graph", "figure"),
496-
style={"height": Config.FIGURE_HEIGHT},
497-
config={"toImageButtonOptions": {"scale": Config.FIGURE_DOWNLOAD_SCALE}},
496+
style={"height": config.FIGURE_HEIGHT},
497+
config={"toImageButtonOptions": {"scale": config.FIGURE_DOWNLOAD_SCALE}},
498498
),
499499
dcc.Graph(
500500
register("pdp_graph", "figure"),
501-
style={"height": Config.FIGURE_HEIGHT},
502-
config={"toImageButtonOptions": {"scale": Config.FIGURE_DOWNLOAD_SCALE}},
501+
style={"height": config.FIGURE_HEIGHT},
502+
config={"toImageButtonOptions": {"scale": config.FIGURE_DOWNLOAD_SCALE}},
503503
),
504504
]
505505

@@ -600,7 +600,7 @@ def load_outputs(run, inputs, outputs) -> List[go.Figure]: # type: ignore
600600
dict(
601601
xaxis=dict(tickvals=x_tickvals, ticktext=x_ticktext, title=hp1_name),
602602
yaxis=dict(tickvals=y_tickvals, ticktext=y_ticktext, title=hp2_name),
603-
margin=Config.FIGURE_MARGIN,
603+
margin=config.FIGURE_MARGIN,
604604
title=expr,
605605
)
606606
)

deepcave/plugins/objective/configuration_cube.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
from dash import dcc, html
2020
from dash.exceptions import PreventUpdate
2121

22-
from deepcave.config import Config
22+
from deepcave import config
2323
from deepcave.plugins.dynamic import DynamicPlugin
2424
from deepcave.runs import AbstractRun, Status
2525
from deepcave.utils.compression import deserialize, serialize
@@ -297,8 +297,8 @@ def get_output_layout(register: Callable) -> Tuple[dcc.Graph,]:
297297
return (
298298
dcc.Graph(
299299
register("graph", "figure"),
300-
style={"height": Config.FIGURE_HEIGHT},
301-
config={"toImageButtonOptions": {"scale": Config.FIGURE_DOWNLOAD_SCALE}},
300+
style={"height": config.FIGURE_HEIGHT},
301+
config={"toImageButtonOptions": {"scale": config.FIGURE_DOWNLOAD_SCALE}},
302302
),
303303
)
304304

@@ -428,7 +428,7 @@ def load_outputs(run, inputs, outputs) -> go.Figure: # type: ignore
428428
layout = go.Layout(**layout_kwargs)
429429

430430
figure = go.Figure(data=trace, layout=layout)
431-
figure.update_layout(dict(margin=Config.FIGURE_MARGIN))
431+
figure.update_layout(dict(margin=config.FIGURE_MARGIN))
432432
save_image(figure, "configuration_cube.pdf")
433433

434434
return figure

deepcave/plugins/objective/cost_over_time.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,7 @@
1919
from dash import dcc, html
2020
from dash.exceptions import PreventUpdate
2121

22-
from deepcave import notification
23-
from deepcave.config import Config
22+
from deepcave import config, notification
2423
from deepcave.plugins.dynamic import DynamicPlugin
2524
from deepcave.runs import AbstractRun, check_equality
2625
from deepcave.runs.exceptions import NotMergeableError, RunInequality
@@ -300,8 +299,8 @@ def get_output_layout(register: Callable) -> dcc.Graph:
300299
"""
301300
return dcc.Graph(
302301
register("graph", "figure"),
303-
style={"height": Config.FIGURE_HEIGHT},
304-
config={"toImageButtonOptions": {"scale": Config.FIGURE_DOWNLOAD_SCALE}},
302+
style={"height": config.FIGURE_HEIGHT},
303+
config={"toImageButtonOptions": {"scale": config.FIGURE_DOWNLOAD_SCALE}},
305304
)
306305

307306
@staticmethod
@@ -423,7 +422,7 @@ def load_outputs(runs, inputs, outputs) -> go.Figure: # type: ignore
423422
layout = go.Layout(
424423
xaxis=dict(title=xaxis_label, type=type),
425424
yaxis=dict(title=objective.name),
426-
margin=Config.FIGURE_MARGIN,
425+
margin=config.FIGURE_MARGIN,
427426
)
428427

429428
figure = go.Figure(data=traces, layout=layout)

deepcave/plugins/objective/parallel_coordinates.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
from dash import dcc, html
2121
from dash.exceptions import PreventUpdate
2222

23-
from deepcave.config import Config
23+
from deepcave import config
2424
from deepcave.constants import VALUE_RANGE
2525
from deepcave.evaluators.fanova import fANOVA
2626
from deepcave.plugins.static import StaticPlugin
@@ -326,8 +326,8 @@ def get_output_layout(register: Callable) -> dcc.Graph:
326326
"""
327327
return dcc.Graph(
328328
register("graph", "figure"),
329-
style={"height": Config.FIGURE_HEIGHT},
330-
config={"toImageButtonOptions": {"scale": Config.FIGURE_DOWNLOAD_SCALE}},
329+
style={"height": config.FIGURE_HEIGHT},
330+
config={"toImageButtonOptions": {"scale": config.FIGURE_DOWNLOAD_SCALE}},
331331
)
332332

333333
@staticmethod

deepcave/plugins/objective/pareto_front.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,7 @@
1717
import plotly.graph_objs as go
1818
from dash import dcc, html
1919

20-
from deepcave import notification
21-
from deepcave.config import Config
20+
from deepcave import config, notification
2221
from deepcave.plugins.dynamic import DynamicPlugin
2322
from deepcave.runs import AbstractRun, Status, check_equality
2423
from deepcave.runs.exceptions import NotMergeableError, RunInequality
@@ -381,8 +380,8 @@ def get_output_layout(register: Callable) -> dcc.Graph:
381380
"""
382381
return dcc.Graph(
383382
register("graph", "figure"),
384-
style={"height": Config.FIGURE_HEIGHT},
385-
config={"toImageButtonOptions": {"scale": Config.FIGURE_DOWNLOAD_SCALE}},
383+
style={"height": config.FIGURE_HEIGHT},
384+
config={"toImageButtonOptions": {"scale": config.FIGURE_DOWNLOAD_SCALE}},
386385
)
387386

388387
@staticmethod
@@ -524,7 +523,7 @@ def load_outputs(runs, inputs, outputs) -> go.Figure: # type: ignore
524523
layout = go.Layout(
525524
xaxis=dict(title=objective_1.name),
526525
yaxis=dict(title=objective_2.name),
527-
margin=Config.FIGURE_MARGIN,
526+
margin=config.FIGURE_MARGIN,
528527
)
529528
else:
530529
layout = None

0 commit comments

Comments
 (0)