update: submit file
Browse files- src/submission/submit.py +32 -8
src/submission/submit.py
CHANGED
|
@@ -1,11 +1,10 @@
|
|
|
|
|
| 1 |
import json
|
| 2 |
import os
|
| 3 |
from datetime import datetime, timezone
|
| 4 |
-
|
| 5 |
from src.display.formatting import styled_error, styled_message
|
| 6 |
from src.envs import API, EVAL_REQUESTS_PATH, QUEUE_REPO
|
| 7 |
|
| 8 |
-
|
| 9 |
def add_new_eval(model: str, weight_type: str, gguf_filename=None):
|
| 10 |
user_name = ""
|
| 11 |
model_path = model
|
|
@@ -21,15 +20,12 @@ def add_new_eval(model: str, weight_type: str, gguf_filename=None):
|
|
| 21 |
except Exception:
|
| 22 |
return styled_error("Could not get your model information.")
|
| 23 |
|
| 24 |
-
# Block gguf_filename input if weight_type is safetensors
|
| 25 |
if weight_type == "safetensors":
|
| 26 |
if gguf_filename:
|
| 27 |
return styled_error("GGUF filename should not be provided when using safetensors.")
|
| 28 |
gguf_filename = None # Ensure gguf_filename is None when safetensors is selected
|
| 29 |
|
| 30 |
-
#
|
| 31 |
-
print("Adding new eval")
|
| 32 |
-
|
| 33 |
eval_entry = {
|
| 34 |
"model": model,
|
| 35 |
"weight_type": weight_type,
|
|
@@ -38,7 +34,7 @@ def add_new_eval(model: str, weight_type: str, gguf_filename=None):
|
|
| 38 |
"submitted_time": current_time,
|
| 39 |
}
|
| 40 |
|
| 41 |
-
|
| 42 |
OUT_DIR = f"{EVAL_REQUESTS_PATH}/{user_name}"
|
| 43 |
os.makedirs(OUT_DIR, exist_ok=True)
|
| 44 |
out_path = f"{OUT_DIR}/{model_path}_eval_request_{current_time}.json"
|
|
@@ -46,7 +42,7 @@ def add_new_eval(model: str, weight_type: str, gguf_filename=None):
|
|
| 46 |
with open(out_path, "w") as f:
|
| 47 |
f.write(json.dumps(eval_entry))
|
| 48 |
|
| 49 |
-
|
| 50 |
API.upload_file(
|
| 51 |
path_or_fileobj=out_path,
|
| 52 |
path_in_repo=out_path.split("eval-queue/")[1],
|
|
@@ -61,3 +57,31 @@ def add_new_eval(model: str, weight_type: str, gguf_filename=None):
|
|
| 61 |
return styled_message(
|
| 62 |
"Your request has been submitted to the evaluation queue!\nPlease wait for up to five minutes for the model to show in the PENDING list."
|
| 63 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
import json
|
| 3 |
import os
|
| 4 |
from datetime import datetime, timezone
|
|
|
|
| 5 |
from src.display.formatting import styled_error, styled_message
|
| 6 |
from src.envs import API, EVAL_REQUESTS_PATH, QUEUE_REPO
|
| 7 |
|
|
|
|
| 8 |
def add_new_eval(model: str, weight_type: str, gguf_filename=None):
|
| 9 |
user_name = ""
|
| 10 |
model_path = model
|
|
|
|
| 20 |
except Exception:
|
| 21 |
return styled_error("Could not get your model information.")
|
| 22 |
|
|
|
|
| 23 |
if weight_type == "safetensors":
|
| 24 |
if gguf_filename:
|
| 25 |
return styled_error("GGUF filename should not be provided when using safetensors.")
|
| 26 |
gguf_filename = None # Ensure gguf_filename is None when safetensors is selected
|
| 27 |
|
| 28 |
+
# Create the eval entry
|
|
|
|
|
|
|
| 29 |
eval_entry = {
|
| 30 |
"model": model,
|
| 31 |
"weight_type": weight_type,
|
|
|
|
| 34 |
"submitted_time": current_time,
|
| 35 |
}
|
| 36 |
|
| 37 |
+
# Create output directory and file
|
| 38 |
OUT_DIR = f"{EVAL_REQUESTS_PATH}/{user_name}"
|
| 39 |
os.makedirs(OUT_DIR, exist_ok=True)
|
| 40 |
out_path = f"{OUT_DIR}/{model_path}_eval_request_{current_time}.json"
|
|
|
|
| 42 |
with open(out_path, "w") as f:
|
| 43 |
f.write(json.dumps(eval_entry))
|
| 44 |
|
| 45 |
+
# Upload eval file
|
| 46 |
API.upload_file(
|
| 47 |
path_or_fileobj=out_path,
|
| 48 |
path_in_repo=out_path.split("eval-queue/")[1],
|
|
|
|
| 57 |
return styled_message(
|
| 58 |
"Your request has been submitted to the evaluation queue!\nPlease wait for up to five minutes for the model to show in the PENDING list."
|
| 59 |
)
|
| 60 |
+
|
| 61 |
+
def update_gguf_input(weight_type):
|
| 62 |
+
return gr.update(interactive=weight_type != "safetensors")
|
| 63 |
+
|
| 64 |
+
# Gradio interface
|
| 65 |
+
with gr.Blocks() as demo:
|
| 66 |
+
model_input = gr.Textbox(label="Model")
|
| 67 |
+
weight_type_input = gr.Dropdown(
|
| 68 |
+
label="Weight Type",
|
| 69 |
+
choices=["default", "safetensors", "other"],
|
| 70 |
+
value="default",
|
| 71 |
+
interactive=True,
|
| 72 |
+
elem_id="weight-type-dropdown"
|
| 73 |
+
)
|
| 74 |
+
gguf_filename_input = gr.Textbox(label="GGUF Filename", interactive=True)
|
| 75 |
+
submit_btn = gr.Button("Submit")
|
| 76 |
+
output = gr.Markdown()
|
| 77 |
+
|
| 78 |
+
# Update gguf_filename input based on weight_type selection
|
| 79 |
+
weight_type_input.change(fn=update_gguf_input, inputs=weight_type_input, outputs=gguf_filename_input)
|
| 80 |
+
|
| 81 |
+
submit_btn.click(
|
| 82 |
+
fn=add_new_eval,
|
| 83 |
+
inputs=[model_input, weight_type_input, gguf_filename_input],
|
| 84 |
+
outputs=output
|
| 85 |
+
)
|
| 86 |
+
|
| 87 |
+
demo.launch()
|