richiam commited on
Commit
ca3575f
·
verified ·
1 Parent(s): 1273c21

Upload folder using huggingface_hub

Browse files
Files changed (2) hide show
  1. app.py +33 -21
  2. upload_to_hf.py +26 -3
app.py CHANGED
@@ -91,19 +91,32 @@ TABLE_FIELDS = EXTRACTION_FIELDS + PAPER_FIELDS + UNIPROT_FIELDS
91
  # ---------------------------------------------------------------------------
92
  def scan_grid():
93
  models, mins, thresholds, fields = set(), set(), set(), set()
94
- pattern = os.path.join(GRID_BASE, "model=*", "min=*", "t=*_cluster.html")
95
- for fpath in glob.glob(pattern):
96
- parts = fpath.split(os.sep)
97
- for p in parts:
98
- if p.startswith("model="):
99
- models.add(p.replace("model=", ""))
100
- elif p.startswith("min="):
101
- mins.add(p.replace("min=", ""))
102
- fname = os.path.basename(fpath)
103
- m = re.match(r"t=([\d.]+)_(.+)_cluster\.html$", fname)
104
- if m:
105
- thresholds.add(m.group(1))
106
- fields.add(m.group(2))
 
 
 
 
 
 
 
 
 
 
 
 
 
107
  return (
108
  sorted(models),
109
  sorted(mins, key=float),
@@ -556,6 +569,7 @@ def proteins_tab():
556
  page_size=25,
557
  page_action="native",
558
  sort_action="native",
 
559
  filter_action="none",
560
  row_selectable="single",
561
  selected_rows=[],
@@ -593,10 +607,10 @@ def proteins_tab():
593
  def clustering_tab():
594
  return dbc.Container([
595
  dbc.Row([
596
- make_dropdown("Model", "dd-model", MODELS, value=MODELS[0] if MODELS else None),
597
- make_dropdown("Min community size", "dd-min", MINS, value=MINS[0] if MINS else None),
598
- make_dropdown("Threshold", "dd-threshold", THRESHOLDS, value=THRESHOLDS[0] if THRESHOLDS else None),
599
- make_dropdown("Field", "dd-field", CLUSTER_FIELDS, value=CLUSTER_FIELDS[0] if CLUSTER_FIELDS else None),
600
  ], className="mb-3 g-3"),
601
  dbc.Row([
602
  dbc.Col([
@@ -1066,7 +1080,7 @@ def evaluation_tab():
1066
  {"label": " Azoreductases", "value": "azoreductases"},
1067
  {"label": " SAMs", "value": "sams"},
1068
  ],
1069
- value="sams",
1070
  inline=True,
1071
  inputStyle={"marginRight": "4px"},
1072
  labelStyle={"marginRight": "16px"},
@@ -1976,7 +1990,7 @@ _CONDITION_COLS = [
1976
  )
1977
  def show_cluster_point_detail(click_data, field, model, min_val, threshold, plot_type):
1978
  if not click_data:
1979
- return html.Div(), None
1980
 
1981
  point = click_data["points"][0]
1982
 
@@ -2452,7 +2466,6 @@ def _eval_bar_figure(stats_df, y_col, err_col, y_label, models):
2452
  Output("eval-llm-graph", "figure"),
2453
  Input("eval-group", "value"),
2454
  Input("eval-model-checklist", "value"),
2455
- prevent_initial_call=True,
2456
  )
2457
  def update_eval_llm(group, models):
2458
  if EVAL_LLM_DF.empty or not group or not models:
@@ -2474,7 +2487,6 @@ def update_eval_llm(group, models):
2474
  Input("eval-group", "value"),
2475
  Input("eval-model-checklist", "value"),
2476
  Input("eval-nlp-metric", "value"),
2477
- prevent_initial_call=True,
2478
  )
2479
  def update_eval_nlp(group, models, metric):
2480
  if EVAL_NLP_DF.empty or not group or not models or not metric:
 
91
  # ---------------------------------------------------------------------------
92
  def scan_grid():
93
  models, mins, thresholds, fields = set(), set(), set(), set()
94
+ for pattern in (
95
+ os.path.join(GRID_BASE, "model=*", "min=*", "t=*_ALL_FIELDS.csv.gz"),
96
+ os.path.join(GRID_BASE, "model=*", "min=*", "t=*_ALL_FIELDS.csv"),
97
+ ):
98
+ for fpath in glob.glob(pattern):
99
+ parts = fpath.split(os.sep)
100
+ for p in parts:
101
+ if p.startswith("model="):
102
+ models.add(p.replace("model=", ""))
103
+ elif p.startswith("min="):
104
+ mins.add(p.replace("min=", ""))
105
+ fname = os.path.basename(fpath)
106
+ m = re.match(r"t=([\d.]+)_ALL_FIELDS\.csv", fname)
107
+ if m:
108
+ thresholds.add(m.group(1))
109
+ # Discover fields from a sample ALL_FIELDS file
110
+ sample = next(iter(
111
+ glob.glob(os.path.join(GRID_BASE, "model=*", "min=*", "t=*_ALL_FIELDS.csv.gz")) +
112
+ glob.glob(os.path.join(GRID_BASE, "model=*", "min=*", "t=*_ALL_FIELDS.csv"))
113
+ ), None)
114
+ if sample:
115
+ try:
116
+ ext = ".gz" if sample.endswith(".gz") else None
117
+ fields = set(pd.read_csv(sample, compression="gzip" if ext else None, usecols=["field"])["field"].unique())
118
+ except Exception:
119
+ pass
120
  return (
121
  sorted(models),
122
  sorted(mins, key=float),
 
569
  page_size=25,
570
  page_action="native",
571
  sort_action="native",
572
+ sort_by=[{"column_id": "pmid", "direction": "asc"}],
573
  filter_action="none",
574
  row_selectable="single",
575
  selected_rows=[],
 
607
  def clustering_tab():
608
  return dbc.Container([
609
  dbc.Row([
610
+ make_dropdown("Model", "dd-model", MODELS, value="cambridgeltl__SapBERT-from-PubMedBERT-fulltext" if "cambridgeltl__SapBERT-from-PubMedBERT-fulltext" in MODELS else (MODELS[0] if MODELS else None)),
611
+ make_dropdown("Min community size", "dd-min", MINS, value="2" if "2" in MINS else (MINS[0] if MINS else None)),
612
+ make_dropdown("Threshold", "dd-threshold", THRESHOLDS, value="0.8" if "0.8" in THRESHOLDS else (THRESHOLDS[0] if THRESHOLDS else None)),
613
+ make_dropdown("Field", "dd-field", CLUSTER_FIELDS, value="organism_source" if "organism_source" in CLUSTER_FIELDS else (CLUSTER_FIELDS[0] if CLUSTER_FIELDS else None)),
614
  ], className="mb-3 g-3"),
615
  dbc.Row([
616
  dbc.Col([
 
1080
  {"label": " Azoreductases", "value": "azoreductases"},
1081
  {"label": " SAMs", "value": "sams"},
1082
  ],
1083
+ value="azoreductases",
1084
  inline=True,
1085
  inputStyle={"marginRight": "4px"},
1086
  labelStyle={"marginRight": "16px"},
 
1990
  )
1991
  def show_cluster_point_detail(click_data, field, model, min_val, threshold, plot_type):
1992
  if not click_data:
1993
+ return dash.no_update, dash.no_update
1994
 
1995
  point = click_data["points"][0]
1996
 
 
2466
  Output("eval-llm-graph", "figure"),
2467
  Input("eval-group", "value"),
2468
  Input("eval-model-checklist", "value"),
 
2469
  )
2470
  def update_eval_llm(group, models):
2471
  if EVAL_LLM_DF.empty or not group or not models:
 
2487
  Input("eval-group", "value"),
2488
  Input("eval-model-checklist", "value"),
2489
  Input("eval-nlp-metric", "value"),
 
2490
  )
2491
  def update_eval_nlp(group, models, metric):
2492
  if EVAL_NLP_DF.empty or not group or not models or not metric:
upload_to_hf.py CHANGED
@@ -1,10 +1,33 @@
1
  from huggingface_hub import HfApi
2
 
3
  api = HfApi()
 
 
 
 
4
  api.upload_folder(
5
  folder_path="/data/ralmadamonter/llm_dashboard",
6
- repo_id="richiam/ProtoPure",
7
  repo_type="space",
8
- ignore_patterns=["*.pyc", "__pycache__", ".git", "data/clustering/"],
9
  )
10
- print("Done")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  from huggingface_hub import HfApi
2
 
3
  api = HfApi()
4
+ REPO = "richiam/ProtoPure"
5
+ BASE_IGNORE = ["*.pyc", "__pycache__", ".git", "*.html", "data/clustering/**/*.png"]
6
+
7
+ # Upload everything except clustering data
8
  api.upload_folder(
9
  folder_path="/data/ralmadamonter/llm_dashboard",
10
+ repo_id=REPO,
11
  repo_type="space",
12
+ ignore_patterns=BASE_IGNORE + ["data/clustering/"],
13
  )
14
+ print("Phase 1 done (app + non-clustering data)")
15
+
16
+ # Upload clustering data in per-model batches
17
+ import os
18
+ CLUSTERING_DIR = "/data/ralmadamonter/llm_dashboard/data/clustering"
19
+ for entry in sorted(os.listdir(CLUSTERING_DIR)):
20
+ entry_path = os.path.join(CLUSTERING_DIR, entry)
21
+ if not os.path.isdir(entry_path):
22
+ continue
23
+ print(f"Uploading {entry}...")
24
+ api.upload_folder(
25
+ folder_path=entry_path,
26
+ repo_id=REPO,
27
+ repo_type="space",
28
+ path_in_repo=f"data/clustering/{entry}",
29
+ ignore_patterns=["*.html", "*.png"],
30
+ )
31
+ print(f" Done: {entry}")
32
+
33
+ print("All done")