Pratyush Maini commited on
Commit
f17679f
1 Parent(s): e9c0aea
.DS_Store ADDED
Binary file (6.15 kB). View file
 
__pycache__/uploads.cpython-312.pyc ADDED
Binary file (3.76 kB). View file
 
uploads.py CHANGED
@@ -24,6 +24,21 @@ def model_hyperlink(link, model_name):
24
  return f'<a target="_blank" href="{link}" style="color: var(--link-text-color); text-decoration: underline;text-decoration-style: dotted;">{model_name}</a>'
25
 
26
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
27
 
28
  def add_new_eval(
29
  model: str,
@@ -34,20 +49,11 @@ def add_new_eval(
34
  organisation: str,
35
  mail: str,
36
  ):
37
- # Very basic email parsing
38
- _, parsed_mail = parseaddr(mail)
39
- if not "@" in parsed_mail:
40
- return format_warning("Please provide a valid email adress.")
41
-
42
- return format_log(f"Model {model} submitted by {organisation} successfully. \nPlease refresh the leaderboard, and wait a bit to see the score displayed")
43
- file_value = path_to_file.value
44
- if file_value is None:
45
- return format_warning("Please attach a file.")
46
 
 
47
 
48
-
49
  # load the file
50
- df = pd.read_csv(file_value)
51
 
52
  # modify the df to include metadata
53
  df["model"] = model
@@ -55,7 +61,7 @@ def add_new_eval(
55
  df["forget_rate"] = forget_rate
56
  df["url"] = url
57
  df["organisation"] = organisation
58
- df["mail"] = mail
59
  df["timestamp"] = datetime.datetime.now()
60
 
61
  #upload to spaces using the hf api at
@@ -64,14 +70,20 @@ def add_new_eval(
64
  file_name = f"{model}-{organisation}-{datetime.datetime.now().strftime('%Y-%m-%d')}.csv"
65
 
66
  # upload the df to spaces
67
- new_file = df.to_csv(index=False)
 
 
 
 
68
 
69
  api.upload_file(
70
  repo_id = RESULTS_PATH,
71
  path_in_repo = f"{path_in_repo}/{file_name}",
72
- file_name = file_value,
73
  token=TOKEN,
74
  repo_type="space",
75
  )
76
 
 
 
77
 
 
24
  return f'<a target="_blank" href="{link}" style="color: var(--link-text-color); text-decoration: underline;text-decoration-style: dotted;">{model_name}</a>'
25
 
26
 
27
+ def input_verification(model, model_family, forget_rate, url, path_to_file, organisation, mail):
28
+ for input in [model, model_family, forget_rate, url, organisation]:
29
+ if input is "":
30
+ return format_warning("Please fill all the fields.")
31
+
32
+ # Very basic email parsing
33
+ _, parsed_mail = parseaddr(mail)
34
+ if not "@" in parsed_mail:
35
+ return format_warning("Please provide a valid email adress.")
36
+
37
+
38
+ if path_to_file is None:
39
+ return format_warning("Please attach a file.")
40
+
41
+ return parsed_mail
42
 
43
  def add_new_eval(
44
  model: str,
 
49
  organisation: str,
50
  mail: str,
51
  ):
 
 
 
 
 
 
 
 
 
52
 
53
+ parsed_mail = input_verification(model, model_family, forget_rate, url, path_to_file, organisation, mail)
54
 
 
55
  # load the file
56
+ df = pd.read_csv(path_to_file)
57
 
58
  # modify the df to include metadata
59
  df["model"] = model
 
61
  df["forget_rate"] = forget_rate
62
  df["url"] = url
63
  df["organisation"] = organisation
64
+ df["mail"] = parsed_mail
65
  df["timestamp"] = datetime.datetime.now()
66
 
67
  #upload to spaces using the hf api at
 
70
  file_name = f"{model}-{organisation}-{datetime.datetime.now().strftime('%Y-%m-%d')}.csv"
71
 
72
  # upload the df to spaces
73
+ import io
74
+
75
+ buffer = io.BytesIO()
76
+ df.to_csv(buffer, index=False) # Write the DataFrame to a buffer in CSV format
77
+ buffer.seek(0) # Rewind the buffer to the beginning
78
 
79
  api.upload_file(
80
  repo_id = RESULTS_PATH,
81
  path_in_repo = f"{path_in_repo}/{file_name}",
82
+ path_or_fileobj = buffer,
83
  token=TOKEN,
84
  repo_type="space",
85
  )
86
 
87
+ return format_log(f"Model {model} submitted by {organisation} successfully. \nPlease refresh the leaderboard, and wait a bit to see the score displayed")
88
+
89
 
versions/.DS_Store ADDED
Binary file (6.15 kB). View file