Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Streamlit to Dash #50

Open
wants to merge 20 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions demo_callbacks.py
Original file line number Diff line number Diff line change
Expand Up @@ -323,6 +323,13 @@ def update_graph_colors(
(Output("results-tab", "disabled"), True, False), # Disables results tab while running.
(Output("results-tab", "label"), "Loading...", "Results"),
(Output("tabs", "value"), "input-tab", "input-tab"), # Switch to input tab while running.
(Output("problem-type", "disabled"), True, False),
(Output("num-cases", "disabled"), True, False),
(Output("case-dim", "disabled"), True, False),
(Output("num-bins", "disabled"), True, False),
(Output("bin-length", "disabled"), True, False),
(Output("bin-width", "disabled"), True, False),
(Output("bin-height", "disabled"), True, False),
],
cancel=[Input("cancel-button", "n_clicks")],
prevent_initial_call=True,
Expand Down
3 changes: 2 additions & 1 deletion demo_configs.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,8 @@
"value": 50,
}

ADVANCED_SETTINGS = ["Color by Case ID"]
# checklist to color by case id or color each case separately
COLOR_BY_CASE = ["Color by Case ID"]

# solver time limits in seconds (value means default)
SOLVER_TIME = {
Expand Down
6 changes: 3 additions & 3 deletions demo_interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
from dash import dcc, html

from demo_configs import (
ADVANCED_SETTINGS,
COLOR_BY_CASE,
BIN_DIM,
CASE_DIM,
DESCRIPTION,
Expand Down Expand Up @@ -405,7 +405,7 @@ def problem_details(index: int) -> html.Div:

def create_interface():
"""Set the application HTML."""
checklist_options = generate_options(ADVANCED_SETTINGS)
checklist_options = generate_options(COLOR_BY_CASE)

return html.Div(
id="app-container",
Expand Down Expand Up @@ -507,7 +507,7 @@ def create_interface():
n_clicks=0,
),
html.P(
"Saved!",
"Saved to /input folder",
k8culver marked this conversation as resolved.
Show resolved Hide resolved
className="display-none",
id="saved",
),
Expand Down
5 changes: 4 additions & 1 deletion utils.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2024 D-Wave
# Copyright 2022 D-Wave
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -415,6 +415,9 @@ def write_input_data(data: dict, input_filename: Optional[str] = None) -> str:
)

if input_filename is not None:
if len(input_filename.split(".")) < 2:
input_filename = input_filename + ".txt"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be OK to have filenames with dots in, no? This would cause an issue if there's a dot in the name.

I quite like using pathlib, which can be used quite nicely here: https://docs.python.org/3/library/pathlib.html#pathlib.PurePath.with_suffix, and also for joining and reading/writing files.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated: 26cc4b4


full_file_path = os.path.join("input", input_filename)
f = open(full_file_path, "w")
f.write(input_string)
Expand Down