daiteng01 commited on
Commit
6fee0c8
·
1 Parent(s): 4cc735e

add upload

Browse files
Files changed (2) hide show
  1. app.py +4 -0
  2. src/submission/submit.py +14 -1
app.py CHANGED
@@ -429,6 +429,8 @@ with demo:
429
  value=None,
430
  interactive=True,
431
  )
 
 
432
 
433
  with gr.Column():
434
  private = gr.Checkbox(False, label="Private", visible=not IS_PUBLIC)
@@ -464,6 +466,8 @@ with demo:
464
  private,
465
  weight_type,
466
  model_type,
 
 
467
  ],
468
  submission_result,
469
  )
 
429
  value=None,
430
  interactive=True,
431
  )
432
+ runsh = gr.File(label="上传 run.sh 文件", file_types=[".sh"])
433
+ adapter = gr.File(label="上传 model_adapter.py 文件", file_types=[".py"])
434
 
435
  with gr.Column():
436
  private = gr.Checkbox(False, label="Private", visible=not IS_PUBLIC)
 
466
  private,
467
  weight_type,
468
  model_type,
469
+ runsh,
470
+ adapter,
471
  ],
472
  submission_result,
473
  )
src/submission/submit.py CHANGED
@@ -26,6 +26,8 @@ def add_new_eval(
26
  private: str,
27
  weight_type: str,
28
  model_type: str,
 
 
29
  ):
30
  global REQUESTED_MODELS
31
  global USERS_TO_SUBMISSION_DATES
@@ -103,7 +105,16 @@ def add_new_eval(
103
 
104
  # Seems good, creating the eval
105
  print("Adding new eval")
106
-
 
 
 
 
 
 
 
 
 
107
  eval_entry = {
108
  "model": model,
109
  "model_api_url": model_api_url,
@@ -121,6 +132,8 @@ def add_new_eval(
121
  "params": model_size,
122
  #"license": license,
123
  "private": False,
 
 
124
  }
125
 
126
  supplementary_info = {
 
26
  private: str,
27
  weight_type: str,
28
  model_type: str,
29
+ runsh,
30
+ adapter
31
  ):
32
  global REQUESTED_MODELS
33
  global USERS_TO_SUBMISSION_DATES
 
105
 
106
  # Seems good, creating the eval
107
  print("Adding new eval")
108
+ max_size = 5 * 1024 * 1024 # 5MB
109
+ if os.path.getsize(runsh.name) > max_size:
110
+ return "错误:文件大小不能超过 5MB!"
111
+ if os.path.getsize(adapter.name) > max_size:
112
+ return "错误:文件大小不能超过 5MB!"
113
+
114
+ with open(runsh.name, "r") as f:
115
+ runsh = f.read()
116
+ with open(adapter.name, "r") as f:
117
+ adapter = f.read()
118
  eval_entry = {
119
  "model": model,
120
  "model_api_url": model_api_url,
 
132
  "params": model_size,
133
  #"license": license,
134
  "private": False,
135
+ "runsh": runsh,
136
+ "adapter": adapter,
137
  }
138
 
139
  supplementary_info = {