Skip to content

Commit

Permalink
Clean up file logic
Browse files Browse the repository at this point in the history
  • Loading branch information
k8culver committed Dec 31, 2024
1 parent b3011e3 commit 7f63250
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 13 deletions.
2 changes: 1 addition & 1 deletion demo_interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ def generate_settings_form() -> html.Div:
dcc.Upload(
id="input-file",
children=html.Div(
["Drag and Drop or ", html.A("Select File"), html.Div(id="filename")]
["Drag and Drop or ", html.A("Select a File"), html.Div(id="filename")]
),
),
],
Expand Down
16 changes: 4 additions & 12 deletions utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
# limitations under the License.

import os
from pathlib import Path, PurePath
from pathlib import Path
from typing import TYPE_CHECKING, List, Optional

import dimod
Expand Down Expand Up @@ -415,16 +415,8 @@ def write_input_data(data: dict, input_filename: Optional[str] = None) -> str:
[TABLE_HEADERS, *[v for v in case_info]], headers="firstrow", colalign="right"
)

if input_filename is not None:
input_file = PurePath(input_filename)

if input_file.suffix != ".txt":
input_file = input_file.with_suffix('.txt')

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)
if input_filename:
file_path = "input" / Path(input_filename).with_suffix('.txt')
file_path.write_text(input_string)

return input_string

0 comments on commit 7f63250

Please sign in to comment.