Spaces:
Running
on
CPU Upgrade
Running
on
CPU Upgrade
Clémentine
commited on
Commit
·
9e36858
1
Parent(s):
807783e
fix file manager
Browse files- yourbench_space/app.py +3 -3
- yourbench_space/utils.py +3 -3
yourbench_space/app.py
CHANGED
|
@@ -174,9 +174,9 @@ with gr.Blocks(theme=gr.themes.Default()) as app:
|
|
| 174 |
)
|
| 175 |
output = gr.Textbox(label="Log")
|
| 176 |
file_input.upload(
|
| 177 |
-
|
| 178 |
-
file_input,
|
| 179 |
-
output,
|
| 180 |
)
|
| 181 |
|
| 182 |
preview_button = gr.Button("Generate New Config", interactive=False)
|
|
|
|
| 174 |
)
|
| 175 |
output = gr.Textbox(label="Log")
|
| 176 |
file_input.upload(
|
| 177 |
+
save_files,
|
| 178 |
+
inputs=[session_state, file_input],
|
| 179 |
+
outputs = output,
|
| 180 |
)
|
| 181 |
|
| 182 |
preview_button = gr.Button("Generate New Config", interactive=False)
|
yourbench_space/utils.py
CHANGED
|
@@ -24,14 +24,14 @@ STAGES = [
|
|
| 24 |
]
|
| 25 |
|
| 26 |
|
| 27 |
-
def save_files(
|
| 28 |
"""Save uploaded files to the UPLOAD_DIRECTORY/uuid safely"""
|
| 29 |
saved_paths = []
|
| 30 |
|
| 31 |
-
for file in files:
|
| 32 |
try:
|
| 33 |
source_path = pathlib.Path(file)
|
| 34 |
-
upload_directory_uuid = pathlib.Path(f"/app/{
|
| 35 |
# Ensure the upload directory exists
|
| 36 |
upload_directory_uuid.mkdir(parents=True, exist_ok=True)
|
| 37 |
destination_path = upload_directory_uuid / source_path.name
|
|
|
|
| 24 |
]
|
| 25 |
|
| 26 |
|
| 27 |
+
def save_files(session_state: gr.State, files: List[pathlib.Path]) -> str:
|
| 28 |
"""Save uploaded files to the UPLOAD_DIRECTORY/uuid safely"""
|
| 29 |
saved_paths = []
|
| 30 |
|
| 31 |
+
for file in [file.name for file in files]:
|
| 32 |
try:
|
| 33 |
source_path = pathlib.Path(file)
|
| 34 |
+
upload_directory_uuid = pathlib.Path(f"/app/{session_state.value}/uploaded_files")
|
| 35 |
# Ensure the upload directory exists
|
| 36 |
upload_directory_uuid.mkdir(parents=True, exist_ok=True)
|
| 37 |
destination_path = upload_directory_uuid / source_path.name
|