Skip to content

Commit

Permalink
Merge pull request #375 from c-bata/enhance-artifact-backend-support
Browse files Browse the repository at this point in the history
Fix bug of custom user widgets and enhance artifact support.
  • Loading branch information
c-bata authored Jan 27, 2023
2 parents 61452e3 + 53a6e71 commit 433f177
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 8 deletions.
14 changes: 10 additions & 4 deletions optuna_dashboard/_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -516,19 +516,25 @@ def get_storage(storage: Union[str, BaseStorage]) -> BaseStorage:


def run_server(
storage: Union[str, BaseStorage], host: str = "localhost", port: int = 8080
storage: Union[str, BaseStorage],
host: str = "localhost",
port: int = 8080,
artifact_backend: Optional[ArtifactBackend] = None,
) -> None:
"""Start running optuna-dashboard and blocks until the server terminates.
This function uses wsgiref module which is not intended for the production
use. If you want to run optuna-dashboard more secure and/or more fast,
please use WSGI server like Gunicorn or uWSGI via `wsgi()` function.
"""
app = create_app(get_storage(storage))
app = create_app(get_storage(storage), artifact_backend=artifact_backend)
run(app, host=host, port=port)


def wsgi(storage: Union[str, BaseStorage]) -> WSGIApplication:
def wsgi(
storage: Union[str, BaseStorage],
artifact_backend: Optional[ArtifactBackend] = None,
) -> WSGIApplication:
"""This function exposes WSGI interface for people who want to run on the
production-class WSGI servers like Gunicorn or uWSGI.
"""
return create_app(get_storage(storage))
return create_app(get_storage(storage), artifact_backend=artifact_backend)
22 changes: 19 additions & 3 deletions optuna_dashboard/ts/components/ObjectiveForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -175,11 +175,23 @@ export const ObjectiveForm: FC<{
{getObjectiveName(i)} - {widget.description}
</FormLabel>
<RadioGroup row defaultValue={widget.values.at(0)}>
{widget.choices.map((c, i) => (
{widget.choices.map((c, j) => (
<FormControlLabel
key={c}
value={widget.values.at(i)}
control={<Radio />}
control={
<Radio
checked={value === widget.values.at(j)}
onChange={(e) => {
const selected = widget.values.at(j)
if (e.target.checked) {
setValue(
i,
selected === undefined ? null : selected
)
}
}}
/>
}
label={c}
/>
))}
Expand All @@ -194,6 +206,10 @@ export const ObjectiveForm: FC<{
</FormLabel>
<Box sx={{ padding: theme.spacing(0, 2) }}>
<Slider
onChange={(e) => {
// @ts-ignore
setValue(i, e.target.value as number)
}}
defaultValue={widget.min}
min={widget.min}
max={widget.max}
Expand Down
2 changes: 1 addition & 1 deletion optuna_dashboard/ts/components/StudyDetailBeta.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ export const StudyDetailBeta: FC<{
}, [])

useEffect(() => {
if (reloadInterval < 0 || page === "trialTable" || page === "trialList") {
if (reloadInterval < 0 || page === "trialTable") {
return
}
const intervalId = setInterval(function () {
Expand Down

0 comments on commit 433f177

Please sign in to comment.