JVice commited on
Commit
b4ff9e0
·
verified ·
1 Parent(s): 3db9bfe

hf_hub_download

Browse files
Files changed (1) hide show
  1. model_comparison.py +24 -24
model_comparison.py CHANGED
@@ -5,7 +5,7 @@ import plotly.express as px
5
  from yaml import safe_load
6
  import user_evaluation_variables
7
  from pathlib import Path
8
- from huggingface_hub import snapshot_download, CommitScheduler, login
9
  from profanity_check import predict
10
 
11
  databaseDF = None
@@ -18,13 +18,13 @@ EVAL_DATABASE_DIR.mkdir(parents=True, exist_ok=True)
18
  GEN_EVAL_DATABASE_PATH = EVAL_DATABASE_DIR / f"general_eval_database.yaml"
19
  TASK_EVAL_DATABASE_PATH = EVAL_DATABASE_DIR / f"task_oriented_eval_database.yaml"
20
 
21
- EVAL_DATABASE_UPDATE_SCHEDULER = CommitScheduler(
22
- repo_id="try-before-you-bias-data",
23
- repo_type="dataset",
24
- folder_path=EVAL_DATABASE_DIR,
25
- path_in_repo="data",
26
- every=2,
27
- )
28
 
29
  # def get_evaluation_id(evalType, debugging):
30
  # global GEN_EVAL_DATABASE_PATH
@@ -75,22 +75,22 @@ def dataframe_with_selections(df):
75
  selected_rows = edited_df[edited_df.Select]
76
  return selected_rows.drop('Select', axis=1)
77
  def add_user_evalID_columns_to_df(df, evalDataPath):
78
- with EVAL_DATABASE_UPDATE_SCHEDULER.lock:
79
- with open(evalDataPath, 'r') as f:
80
- yamlData = safe_load(f)
81
- for user in yamlData['evaluations']['username']:
82
- if df is None:
83
- df = pd.DataFrame(yamlData['evaluations']['username'][user]).T
84
- df.insert(0, "Eval. ID", list(yamlData['evaluations']['username'][user].keys()), True)
85
- else:
86
- df = pd.concat([df, pd.DataFrame(yamlData['evaluations']['username'][user]).T],
87
- ignore_index=True)
88
- evalIDIterator = 0
89
- for index, row in df.iterrows():
90
- if row['Eval. ID'] is np.nan:
91
- df.loc[index, 'Eval. ID'] = list(yamlData['evaluations']['username'][user].keys())[
92
- evalIDIterator]
93
- evalIDIterator += 1
94
  return df
95
 
96
  def initialise_page(tab):
 
5
  from yaml import safe_load
6
  import user_evaluation_variables
7
  from pathlib import Path
8
+ from huggingface_hub import hf_hub_download, CommitScheduler, login
9
  from profanity_check import predict
10
 
11
  databaseDF = None
 
18
  GEN_EVAL_DATABASE_PATH = EVAL_DATABASE_DIR / f"general_eval_database.yaml"
19
  TASK_EVAL_DATABASE_PATH = EVAL_DATABASE_DIR / f"task_oriented_eval_database.yaml"
20
 
21
+ # EVAL_DATABASE_UPDATE_SCHEDULER = CommitScheduler(
22
+ # repo_id="try-before-you-bias-data",
23
+ # repo_type="dataset",
24
+ # folder_path=EVAL_DATABASE_DIR,
25
+ # path_in_repo="data",
26
+ # every=2,
27
+ # )
28
 
29
  # def get_evaluation_id(evalType, debugging):
30
  # global GEN_EVAL_DATABASE_PATH
 
75
  selected_rows = edited_df[edited_df.Select]
76
  return selected_rows.drop('Select', axis=1)
77
  def add_user_evalID_columns_to_df(df, evalDataPath):
78
+ # with open(evalDataPath, 'r') as f:
79
+ # yamlData = safe_load(f)
80
+ yamlData = hf_hub_download(repo_id="try-before-you-bias-data", filename=evalDataPath, repo_type="dataset")
81
+ for user in yamlData['evaluations']['username']:
82
+ if df is None:
83
+ df = pd.DataFrame(yamlData['evaluations']['username'][user]).T
84
+ df.insert(0, "Eval. ID", list(yamlData['evaluations']['username'][user].keys()), True)
85
+ else:
86
+ df = pd.concat([df, pd.DataFrame(yamlData['evaluations']['username'][user]).T],
87
+ ignore_index=True)
88
+ evalIDIterator = 0
89
+ for index, row in df.iterrows():
90
+ if row['Eval. ID'] is np.nan:
91
+ df.loc[index, 'Eval. ID'] = list(yamlData['evaluations']['username'][user].keys())[
92
+ evalIDIterator]
93
+ evalIDIterator += 1
94
  return df
95
 
96
  def initialise_page(tab):