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

Merged
merged 20 commits into from
Jan 2, 2025
Merged

Streamlit to Dash #50

merged 20 commits into from
Jan 2, 2025

Conversation

k8culver
Copy link
Contributor

@k8culver k8culver commented Dec 7, 2024

  • Replace Streamlit UI with Dash UI
  • Move "Random Seed" setting to config file
  • Move "Save Input to File" to Input tab
  • Move "Color by Case ID" to Results tab
  • Update "Upload File" to use dcc.Upload

Note: It is expected for test-osx to fail because this demo uses mip

@k8culver k8culver self-assigned this Dec 7, 2024
@k8culver k8culver requested a review from thisac December 7, 2024 00:28
@k8culver k8culver marked this pull request as ready for review December 7, 2024 00:28
Copy link
Contributor

@thisac thisac left a comment

Choose a reason for hiding this comment

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

Looks great!

  • When saving a problem (Save Input Data to File), it wasn't clear that it was saved in the input folder. A clarification or note in the readme might be good.
  • Perhaps automatically add a .txt file ending to the stored inputs and solutions if not included in the filename?
  • I think it would feel more robust if the problem generation is disabled (i.e., the sliders are greyed out) while running. Otherwise it's easy to change the problem while getting a solution for the old, lost one. Same for disabling the results tab when generating a new problem.
  • Is it possible to have the upload-problem-file browser open at the input folder directly?

utils.py Outdated Show resolved Hide resolved
demo_configs.py Outdated
"value": 50,
}

ADVANCED_SETTINGS = ["Color by Case ID"]
Copy link
Contributor

Choose a reason for hiding this comment

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

What can this be changed to? Maybe add a comment?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated: d2c039e

@k8culver
Copy link
Contributor Author

  • Is it possible to have the upload-problem-file browser open at the input folder directly?

I don't think this is possible

@k8culver k8culver requested a review from thisac December 23, 2024 18:53
utils.py Outdated
Comment on lines 418 to 419
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
Contributor Author

Choose a reason for hiding this comment

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

Updated: 26cc4b4

@k8culver k8culver requested a review from thisac December 31, 2024 22:55
Copy link
Contributor

@thisac thisac left a comment

Choose a reason for hiding this comment

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

LGTM! Just a couple of minor comments.

There's a minor issue (which I think is probably fine to leave, but at least be aware of) when trying to upload a separate file with the same content but a different name. Nothing happens and the old name stays.

utils.py Outdated
Comment on lines 418 to 428
if input_filename is not None:
input_file = PurePath(input_filename)

input_string = f'# Max num of bins : {data["num_bins"]} \n'
input_string += (f'# Bin dimensions '
f'(L * W * H): {data["bin_dimensions"][0]} '
f'{data["bin_dimensions"][1]} '
f'{data["bin_dimensions"][2]} \n \n')
input_string += tabulate([header, *[v for v in case_info]],
headers="firstrow", colalign='right')
if input_file.suffix != ".txt":
input_file = input_file.with_suffix('.txt')

if input_filename is not None:
full_file_path = os.path.join("input", input_filename)
f = open(full_file_path, "w")
f.write(input_string)
f.close()
input_folder = Path(__file__).parent / "input"
file_path = input_folder / input_file.name

with Path(file_path).open("w") as f:
f.write(input_string)
Copy link
Contributor

Choose a reason for hiding this comment

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

If you want to go all in on pathlib:

if input_filename:
    file_path = "input" / Path(input_filename).with_suffix('.txt')
    file_path.write_text(input_string)

There's also Path.resolve() if the absolute path is required, but I don't think it's necessary here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated: 7f63250

demo_interface.py Outdated Show resolved Hide resolved
demo_interface.py Outdated Show resolved Hide resolved
k8culver and others added 2 commits December 31, 2024 15:07
Co-authored-by: Theodor Isacsson <theodor@isacsson.ca>
@k8culver k8culver force-pushed the update/streamlit-to-dash branch from b24d3f3 to 7f63250 Compare December 31, 2024 23:18
@k8culver k8culver merged commit b8ea8e5 into main Jan 2, 2025
2 of 3 checks passed
@k8culver k8culver deleted the update/streamlit-to-dash branch January 2, 2025 17:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants