Skip to content

Commit e92f45d

Browse files
author
Sarah Krebs
committed
Fix use of config
1 parent 25fb549 commit e92f45d

File tree

14 files changed

+48
-44
lines changed

14 files changed

+48
-44
lines changed

deepcave/__init__.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -137,15 +137,20 @@ 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
140141

141-
__all__ = ["version", "Recorder", "Objective"]
142+
config_name = None
143+
if "--config" in sys.argv:
144+
config_name = sys.argv[sys.argv.index("--config") + 1]
145+
config = parse_config(config_name)
146+
147+
__all__ = ["version", "Recorder", "Objective", "config"]
142148
except ModuleNotFoundError:
143149
__all__ = ["version"]
144150

145151

146152
_api_mode = False if "app" in globals() else True
147153

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

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: 3 additions & 4 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
@@ -220,7 +219,7 @@ def get_output_layout(register: Callable) -> List[Any]:
220219
[
221220
dbc.Tab(
222221
dcc.Graph(
223-
id=register("graph", "figure"), style={"height": Config.FIGURE_HEIGHT}
222+
id=register("graph", "figure"), style={"height": config.FIGURE_HEIGHT}
224223
),
225224
label="Graph",
226225
),
@@ -298,7 +297,7 @@ def load_outputs(run, _, outputs) -> List[Any]: # type: ignore
298297
layout = go.Layout(
299298
xaxis=dict(title="Budget"),
300299
yaxis=dict(title="Correlation"),
301-
margin=Config.FIGURE_MARGIN,
300+
margin=config.FIGURE_MARGIN,
302301
legend=dict(title="Budgets"),
303302
)
304303

deepcave/plugins/hyperparameter/importances.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.evaluators.fanova import fANOVA as GlobalEvaluator
2525
from deepcave.evaluators.lpi import LPI as LocalEvaluator
2626
from deepcave.plugins.static import StaticPlugin
@@ -357,7 +357,7 @@ def get_output_layout(register: Callable) -> dcc.Graph:
357357
dcc.Graph
358358
Layout for the output block.
359359
"""
360-
return dcc.Graph(register("graph", "figure"), style={"height": Config.FIGURE_HEIGHT})
360+
return dcc.Graph(register("graph", "figure"), style={"height": config.FIGURE_HEIGHT})
361361

362362
@staticmethod
363363
def load_outputs(run, inputs, outputs) -> go.Figure: # type: ignore
@@ -452,7 +452,7 @@ def load_outputs(run, inputs, outputs) -> go.Figure: # type: ignore
452452
barmode="group",
453453
yaxis_title="Importance",
454454
legend={"title": "Budget"},
455-
margin=Config.FIGURE_MARGIN,
455+
margin=config.FIGURE_MARGIN,
456456
xaxis=dict(tickangle=-45),
457457
)
458458
save_image(figure, "importances.pdf")

deepcave/plugins/hyperparameter/pdp.py

Lines changed: 3 additions & 3 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
@@ -366,7 +366,7 @@ def get_output_layout(register: Callable) -> dcc.Graph:
366366
dcc.Graph
367367
Layout for the output block.
368368
"""
369-
return dcc.Graph(register("graph", "figure"), style={"height": Config.FIGURE_HEIGHT})
369+
return dcc.Graph(register("graph", "figure"), style={"height": config.FIGURE_HEIGHT})
370370

371371
@staticmethod
372372
def get_pdp_figure( # type: ignore
@@ -503,7 +503,7 @@ def get_pdp_figure( # type: ignore
503503
dict(
504504
xaxis=dict(tickvals=x_tickvals, ticktext=x_ticktext, title=hp1_name),
505505
yaxis=dict(tickvals=y_tickvals, ticktext=y_ticktext, title=hp2_name),
506-
margin=Config.FIGURE_MARGIN,
506+
margin=config.FIGURE_MARGIN,
507507
title=title,
508508
)
509509
)

deepcave/plugins/hyperparameter/symbolic_explanations.py

Lines changed: 4 additions & 4 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
@@ -491,8 +491,8 @@ def get_output_layout(register: Callable) -> List[dcc.Graph]:
491491
Layout for the output block.
492492
"""
493493
return [
494-
dcc.Graph(register("symb_graph", "figure"), style={"height": Config.FIGURE_HEIGHT}),
495-
dcc.Graph(register("pdp_graph", "figure"), style={"height": Config.FIGURE_HEIGHT}),
494+
dcc.Graph(register("symb_graph", "figure"), style={"height": config.FIGURE_HEIGHT}),
495+
dcc.Graph(register("pdp_graph", "figure"), style={"height": config.FIGURE_HEIGHT}),
496496
]
497497

498498
@staticmethod
@@ -592,7 +592,7 @@ def load_outputs(run, inputs, outputs) -> List[go.Figure]: # type: ignore
592592
dict(
593593
xaxis=dict(tickvals=x_tickvals, ticktext=x_ticktext, title=hp1_name),
594594
yaxis=dict(tickvals=y_tickvals, ticktext=y_ticktext, title=hp2_name),
595-
margin=Config.FIGURE_MARGIN,
595+
margin=config.FIGURE_MARGIN,
596596
title=expr,
597597
)
598598
)

deepcave/plugins/objective/configuration_cube.py

Lines changed: 3 additions & 3 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
@@ -294,7 +294,7 @@ def get_output_layout(register: Callable) -> Tuple[dcc.Graph,]:
294294
Tuple[dcc.Graph,]
295295
Layout for the output block.
296296
"""
297-
return (dcc.Graph(register("graph", "figure"), style={"height": Config.FIGURE_HEIGHT}),)
297+
return (dcc.Graph(register("graph", "figure"), style={"height": config.FIGURE_HEIGHT}),)
298298

299299
@staticmethod
300300
def load_outputs(run, inputs, outputs) -> go.Figure: # type: ignore
@@ -417,7 +417,7 @@ def load_outputs(run, inputs, outputs) -> go.Figure: # type: ignore
417417
layout = go.Layout(**layout_kwargs)
418418

419419
figure = go.Figure(data=trace, layout=layout)
420-
figure.update_layout(dict(margin=Config.FIGURE_MARGIN))
420+
figure.update_layout(dict(margin=config.FIGURE_MARGIN))
421421
save_image(figure, "configuration_cube.pdf")
422422

423423
return figure

deepcave/plugins/objective/cost_over_time.py

Lines changed: 3 additions & 3 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, check_equality
2525
from deepcave.utils.layout import get_select_options, help_button
@@ -275,7 +275,7 @@ def get_output_layout(register: Callable) -> dcc.Graph:
275275
dcc.Graph
276276
The layouts for the output block.
277277
"""
278-
return dcc.Graph(register("graph", "figure"), style={"height": Config.FIGURE_HEIGHT})
278+
return dcc.Graph(register("graph", "figure"), style={"height": config.FIGURE_HEIGHT})
279279

280280
@staticmethod
281281
def load_outputs(runs, inputs, outputs) -> go.Figure: # type: ignore
@@ -393,7 +393,7 @@ def load_outputs(runs, inputs, outputs) -> go.Figure: # type: ignore
393393
layout = go.Layout(
394394
xaxis=dict(title=xaxis_label, type=type),
395395
yaxis=dict(title=objective.name),
396-
margin=Config.FIGURE_MARGIN,
396+
margin=config.FIGURE_MARGIN,
397397
)
398398

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

deepcave/plugins/objective/parallel_coordinates.py

Lines changed: 2 additions & 2 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
@@ -320,7 +320,7 @@ def get_output_layout(register: Callable) -> dcc.Graph:
320320
dcc.Graph
321321
The layouts for the output block.
322322
"""
323-
return dcc.Graph(register("graph", "figure"), style={"height": Config.FIGURE_HEIGHT})
323+
return dcc.Graph(register("graph", "figure"), style={"height": config.FIGURE_HEIGHT})
324324

325325
@staticmethod
326326
def load_outputs(run, inputs, outputs) -> go.Figure: # type: ignore

deepcave/plugins/objective/pareto_front.py

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

20-
from deepcave.config import Config
20+
from deepcave import config
2121
from deepcave.plugins.dynamic import DynamicPlugin
2222
from deepcave.runs import AbstractRun, Status, check_equality
2323
from deepcave.utils.layout import get_select_options, help_button
@@ -329,7 +329,7 @@ def get_output_layout(register: Callable) -> dcc.Graph:
329329
dcc.Graph
330330
The layout for the output block.
331331
"""
332-
return dcc.Graph(register("graph", "figure"), style={"height": Config.FIGURE_HEIGHT})
332+
return dcc.Graph(register("graph", "figure"), style={"height": config.FIGURE_HEIGHT})
333333

334334
@staticmethod
335335
def load_outputs(runs, inputs, outputs) -> go.Figure: # type: ignore
@@ -437,7 +437,7 @@ def load_outputs(runs, inputs, outputs) -> go.Figure: # type: ignore
437437
layout = go.Layout(
438438
xaxis=dict(title=objective_1.name),
439439
yaxis=dict(title=objective_2.name),
440-
margin=Config.FIGURE_MARGIN,
440+
margin=config.FIGURE_MARGIN,
441441
)
442442
else:
443443
layout = None

0 commit comments

Comments
 (0)