Spaces:
Running
Running
Update app.py
Browse filesupdated the app.py for try except
app.py
CHANGED
|
@@ -18,11 +18,12 @@ from huggingface_hub import login
|
|
| 18 |
# Define the function to process the input file and model selection
|
| 19 |
|
| 20 |
api = HfApi(token=os.getenv("HF_TOKEN"))
|
|
|
|
| 21 |
DATASET_REPO = "suryadev1/generated-csvs"
|
| 22 |
def delete_files():
|
| 23 |
repo_files = api.list_repo_files(repo_id=DATASET_REPO, repo_type="dataset")
|
| 24 |
|
| 25 |
-
#
|
| 26 |
for f in repo_files:
|
| 27 |
if f.endswith(".csv"):
|
| 28 |
try:
|
|
@@ -34,6 +35,7 @@ def delete_files():
|
|
| 34 |
print(f"Deleted old file: {f}")
|
| 35 |
except Exception as e:
|
| 36 |
print(f"Could not delete {f}: {e}")
|
|
|
|
| 37 |
def upload_to_dataset(filepath):
|
| 38 |
|
| 39 |
api.upload_file(
|
|
@@ -243,7 +245,10 @@ def process_file(model_name,inc_slider,progress=Progress(track_tqdm=True)):
|
|
| 243 |
|
| 244 |
print(f"CSV file '{filename}' created successfully.")
|
| 245 |
full_path = os.path.join("fileHandler", filename)
|
| 246 |
-
|
|
|
|
|
|
|
|
|
|
| 247 |
|
| 248 |
|
| 249 |
task_type_map = {0: "ER", 1: "ME"}
|
|
@@ -858,7 +863,7 @@ content = """
|
|
| 858 |
|
| 859 |
<h3 style="color: white; text-align: center">
|
| 860 |
<a href="https://drive.google.com/file/d/1lbEpg8Se1ugTtkjreD8eXIg7qrplhWan/view" style="color: gr.themes.colors.red; text-decoration: none;">Link To Paper</a> |
|
| 861 |
-
<a href="https://
|
| 862 |
<a href="https://drive.google.com/file/d/1wussSAYV5WfRSgYNEDgxWNqMUNoiu65u/view" style="color: #1E90FF; text-decoration: none;">User Guide</a>
|
| 863 |
|
| 864 |
|
|
@@ -1325,7 +1330,7 @@ with gr.Blocks(theme='gstaff/sketch', css=custom_css) as demo:
|
|
| 1325 |
|
| 1326 |
with gr.Row():
|
| 1327 |
with gr.Column():
|
| 1328 |
-
redirect_button = gr.Button("Click to
|
| 1329 |
|
| 1330 |
redirect_button.click(
|
| 1331 |
None,
|
|
|
|
| 18 |
# Define the function to process the input file and model selection
|
| 19 |
|
| 20 |
api = HfApi(token=os.getenv("HF_TOKEN"))
|
| 21 |
+
|
| 22 |
DATASET_REPO = "suryadev1/generated-csvs"
|
| 23 |
def delete_files():
|
| 24 |
repo_files = api.list_repo_files(repo_id=DATASET_REPO, repo_type="dataset")
|
| 25 |
|
| 26 |
+
# delete all CSV files
|
| 27 |
for f in repo_files:
|
| 28 |
if f.endswith(".csv"):
|
| 29 |
try:
|
|
|
|
| 35 |
print(f"Deleted old file: {f}")
|
| 36 |
except Exception as e:
|
| 37 |
print(f"Could not delete {f}: {e}")
|
| 38 |
+
# upload files to the dataset
|
| 39 |
def upload_to_dataset(filepath):
|
| 40 |
|
| 41 |
api.upload_file(
|
|
|
|
| 245 |
|
| 246 |
print(f"CSV file '{filename}' created successfully.")
|
| 247 |
full_path = os.path.join("fileHandler", filename)
|
| 248 |
+
try:
|
| 249 |
+
upload_to_dataset(full_path)
|
| 250 |
+
except Exception as e:
|
| 251 |
+
print(f"Failed: Timeout or error occurred - {e}")
|
| 252 |
|
| 253 |
|
| 254 |
task_type_map = {0: "ER", 1: "ME"}
|
|
|
|
| 863 |
|
| 864 |
<h3 style="color: white; text-align: center">
|
| 865 |
<a href="https://drive.google.com/file/d/1lbEpg8Se1ugTtkjreD8eXIg7qrplhWan/view" style="color: gr.themes.colors.red; text-decoration: none;">Link To Paper</a> |
|
| 866 |
+
<a href="https://huggingface.co/spaces/suryadev1/astra/tree/main" style="color: #1E90FF; text-decoration: none;">Repo Link</a> |
|
| 867 |
<a href="https://drive.google.com/file/d/1wussSAYV5WfRSgYNEDgxWNqMUNoiu65u/view" style="color: #1E90FF; text-decoration: none;">User Guide</a>
|
| 868 |
|
| 869 |
|
|
|
|
| 1330 |
|
| 1331 |
with gr.Row():
|
| 1332 |
with gr.Column():
|
| 1333 |
+
redirect_button = gr.Button("Click to Visualize Strategies", visible=False)
|
| 1334 |
|
| 1335 |
redirect_button.click(
|
| 1336 |
None,
|