Spaces:
Running
on
CPU Upgrade
Running
on
CPU Upgrade
Clémentine
commited on
Commit
·
9b8c53c
1
Parent(s):
2671d62
fixed submission - can no longer resubmit a model already submitted!
Browse files- src/submission/submit.py +12 -31
src/submission/submit.py
CHANGED
|
@@ -16,7 +16,6 @@ from src.submission.check_validity import (
|
|
| 16 |
already_submitted_models,
|
| 17 |
check_model_card,
|
| 18 |
get_model_size,
|
| 19 |
-
get_model_tags,
|
| 20 |
is_model_on_hub,
|
| 21 |
user_submission_permission,
|
| 22 |
)
|
|
@@ -66,40 +65,37 @@ def add_new_eval(
|
|
| 66 |
# Does the model actually exist?
|
| 67 |
if revision == "":
|
| 68 |
revision = "main"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 69 |
|
|
|
|
| 70 |
# Is the model on the hub?
|
| 71 |
if weight_type in ["Delta", "Adapter"]:
|
| 72 |
base_model_on_hub, error, _ = is_model_on_hub(
|
| 73 |
-
model_name=base_model, revision=
|
| 74 |
)
|
| 75 |
if not base_model_on_hub:
|
| 76 |
return styled_error(f'Base model "{base_model}" {error}')
|
| 77 |
-
|
| 78 |
-
architecture = "?"
|
| 79 |
-
downloads = 0
|
| 80 |
-
created_at = ""
|
| 81 |
if not weight_type == "Adapter":
|
| 82 |
-
model_on_hub, error, model_config = is_model_on_hub(model_name=model, revision=
|
| 83 |
if not model_on_hub or model_config is None:
|
| 84 |
return styled_error(f'Model "{model}" {error}')
|
| 85 |
if model_config is not None:
|
| 86 |
architectures = getattr(model_config, "architectures", None)
|
| 87 |
if architectures:
|
| 88 |
architecture = ";".join(architectures)
|
| 89 |
-
downloads = getattr(model_config, "downloads", 0)
|
| 90 |
-
created_at = getattr(model_config, "created_at", "")
|
| 91 |
-
|
| 92 |
-
# Is the model info correctly filled?
|
| 93 |
-
try:
|
| 94 |
-
model_info = API.model_info(repo_id=model, revision=revision)
|
| 95 |
-
except Exception:
|
| 96 |
-
return styled_error("Could not get your model information. Please fill it up properly.")
|
| 97 |
|
| 98 |
model_size = get_model_size(model_info=model_info, precision=precision)
|
| 99 |
|
| 100 |
# Were the model card and license filled?
|
| 101 |
try:
|
| 102 |
-
|
| 103 |
except Exception:
|
| 104 |
return styled_error("Please select a license for your model")
|
| 105 |
|
|
@@ -107,8 +103,6 @@ def add_new_eval(
|
|
| 107 |
if not modelcard_OK:
|
| 108 |
return styled_error(error_msg)
|
| 109 |
|
| 110 |
-
tags = get_model_tags(model_card, model)
|
| 111 |
-
|
| 112 |
# Seems good, creating the eval
|
| 113 |
print("Adding new eval")
|
| 114 |
|
|
@@ -128,19 +122,6 @@ def add_new_eval(
|
|
| 128 |
"use_chat_template": use_chat_template,
|
| 129 |
}
|
| 130 |
|
| 131 |
-
supplementary_info = {
|
| 132 |
-
"likes": model_info.likes,
|
| 133 |
-
"license": license,
|
| 134 |
-
"still_on_hub": True,
|
| 135 |
-
"tags": tags,
|
| 136 |
-
"downloads": downloads,
|
| 137 |
-
"created_at": created_at,
|
| 138 |
-
}
|
| 139 |
-
|
| 140 |
-
# Check for duplicate submission
|
| 141 |
-
if f"{model}_{revision}_{precision}" in REQUESTED_MODELS:
|
| 142 |
-
return styled_warning("This model has been already submitted.")
|
| 143 |
-
|
| 144 |
print("Creating eval file")
|
| 145 |
OUT_DIR = f"{EVAL_REQUESTS_PATH}/{user_name}"
|
| 146 |
os.makedirs(OUT_DIR, exist_ok=True)
|
|
|
|
| 16 |
already_submitted_models,
|
| 17 |
check_model_card,
|
| 18 |
get_model_size,
|
|
|
|
| 19 |
is_model_on_hub,
|
| 20 |
user_submission_permission,
|
| 21 |
)
|
|
|
|
| 65 |
# Does the model actually exist?
|
| 66 |
if revision == "":
|
| 67 |
revision = "main"
|
| 68 |
+
try:
|
| 69 |
+
model_info = API.model_info(repo_id=model, revision=revision)
|
| 70 |
+
except Exception as e:
|
| 71 |
+
return styled_error("Could not get your model information. Please fill it up properly.")
|
| 72 |
+
|
| 73 |
+
# Check for duplicate submission
|
| 74 |
+
if f"{model}_{model_info.sha}_{precision}" in REQUESTED_MODELS:
|
| 75 |
+
return styled_warning("This model has been already submitted.")
|
| 76 |
|
| 77 |
+
architecture = "?"
|
| 78 |
# Is the model on the hub?
|
| 79 |
if weight_type in ["Delta", "Adapter"]:
|
| 80 |
base_model_on_hub, error, _ = is_model_on_hub(
|
| 81 |
+
model_name=base_model, revision=model_info.sha, token=HF_TOKEN, test_tokenizer=True
|
| 82 |
)
|
| 83 |
if not base_model_on_hub:
|
| 84 |
return styled_error(f'Base model "{base_model}" {error}')
|
|
|
|
|
|
|
|
|
|
|
|
|
| 85 |
if not weight_type == "Adapter":
|
| 86 |
+
model_on_hub, error, model_config = is_model_on_hub(model_name=model, revision=model_info.sha, test_tokenizer=True)
|
| 87 |
if not model_on_hub or model_config is None:
|
| 88 |
return styled_error(f'Model "{model}" {error}')
|
| 89 |
if model_config is not None:
|
| 90 |
architectures = getattr(model_config, "architectures", None)
|
| 91 |
if architectures:
|
| 92 |
architecture = ";".join(architectures)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 93 |
|
| 94 |
model_size = get_model_size(model_info=model_info, precision=precision)
|
| 95 |
|
| 96 |
# Were the model card and license filled?
|
| 97 |
try:
|
| 98 |
+
model_info.cardData["license"]
|
| 99 |
except Exception:
|
| 100 |
return styled_error("Please select a license for your model")
|
| 101 |
|
|
|
|
| 103 |
if not modelcard_OK:
|
| 104 |
return styled_error(error_msg)
|
| 105 |
|
|
|
|
|
|
|
| 106 |
# Seems good, creating the eval
|
| 107 |
print("Adding new eval")
|
| 108 |
|
|
|
|
| 122 |
"use_chat_template": use_chat_template,
|
| 123 |
}
|
| 124 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 125 |
print("Creating eval file")
|
| 126 |
OUT_DIR = f"{EVAL_REQUESTS_PATH}/{user_name}"
|
| 127 |
os.makedirs(OUT_DIR, exist_ok=True)
|