lewtun HF staff commited on
Commit
1e40fe5
β€’
1 Parent(s): 32b967f

Better handling for metadata

Browse files
Files changed (3) hide show
  1. app.py +11 -6
  2. requirements.txt +10 -4
  3. utils.py +2 -2
app.py CHANGED
@@ -5,9 +5,10 @@ from pathlib import Path
5
 
6
  import pandas as pd
7
  import streamlit as st
8
- from datasets import get_dataset_config_names, list_metrics, load_metric
9
  from dotenv import load_dotenv
10
- from huggingface_hub import list_datasets
 
11
  from tqdm import tqdm
12
 
13
  from evaluation import filter_evaluated_models
@@ -62,7 +63,7 @@ def get_supported_metrics():
62
  supported_metrics = []
63
  for metric in tqdm(metrics):
64
  try:
65
- metric_func = load_metric(metric)
66
  except Exception as e:
67
  print(e)
68
  print("Skipping the following metric, which cannot load:", metric)
@@ -144,10 +145,14 @@ with st.expander("Advanced configuration"):
144
  if split["config"] == selected_config:
145
  split_names.append(split["split"])
146
 
 
 
 
 
147
  selected_split = st.selectbox(
148
  "Select a split",
149
  split_names,
150
- index=split_names.index(metadata[0]["splits"]["eval_split"]) if metadata is not None else 0,
151
  )
152
 
153
  # Select columns
@@ -322,8 +327,8 @@ with st.expander("Advanced configuration"):
322
  list(set(supported_metrics) - set(TASK_TO_DEFAULT_METRICS[selected_task])),
323
  )
324
  st.info(
325
- "Note: user-selected metrics will be run with their default arguments from "
326
- + "[here](https://github.com/huggingface/evaluate/tree/main/metrics)"
327
  )
328
 
329
  with st.form(key="form"):
5
 
6
  import pandas as pd
7
  import streamlit as st
8
+ from datasets import get_dataset_config_names
9
  from dotenv import load_dotenv
10
+ from evaluate import load
11
+ from huggingface_hub import list_datasets, list_metrics
12
  from tqdm import tqdm
13
 
14
  from evaluation import filter_evaluated_models
63
  supported_metrics = []
64
  for metric in tqdm(metrics):
65
  try:
66
+ metric_func = load(metric)
67
  except Exception as e:
68
  print(e)
69
  print("Skipping the following metric, which cannot load:", metric)
145
  if split["config"] == selected_config:
146
  split_names.append(split["split"])
147
 
148
+ if metadata is not None:
149
+ eval_split = metadata[0]["splits"].get("eval_split", None)
150
+ else:
151
+ eval_split = None
152
  selected_split = st.selectbox(
153
  "Select a split",
154
  split_names,
155
+ index=split_names.index(eval_split) if eval_split is not None else 0,
156
  )
157
 
158
  # Select columns
327
  list(set(supported_metrics) - set(TASK_TO_DEFAULT_METRICS[selected_task])),
328
  )
329
  st.info(
330
+ """"Note: user-selected metrics will be run with their default arguments. \
331
+ Check out the [available metrics](https://huggingface.co/metrics) for more details."""
332
  )
333
 
334
  with st.form(key="form"):
requirements.txt CHANGED
@@ -1,6 +1,12 @@
1
- huggingface-hub==0.4.0
2
  python-dotenv
3
  streamlit==1.2.0
4
- datasets
5
- py7zr
6
- sklearn
 
 
 
 
 
 
1
+ huggingface-hub<0.8
2
  python-dotenv
3
  streamlit==1.2.0
4
+ datasets<2.3
5
+ evaluate<0.2
6
+ # Dataset specific deps
7
+ py7zr<0.19
8
+ openpyxl<3.1
9
+ # Metric specific deps
10
+ scikit-learn<1.2
11
+ # Dirty bug from Google
12
+ protobuf<=3.20.1
utils.py CHANGED
@@ -40,7 +40,7 @@ def http_post(path: str, token: str, payload=None, domain: str = None, params=No
40
 
41
 
42
  def http_get(path: str, domain: str, token: str = None, params: dict = None) -> requests.Response:
43
- """HTTP POST request to the AutoNLP API, raises UnreachableAPIError if the API cannot be reached"""
44
  try:
45
  response = requests.get(
46
  url=domain + path,
@@ -49,7 +49,7 @@ def http_get(path: str, domain: str, token: str = None, params: dict = None) ->
49
  params=params,
50
  )
51
  except requests.exceptions.ConnectionError:
52
- print("❌ Failed to reach AutoNLP API, check your internet connection")
53
  response.raise_for_status()
54
  return response
55
 
40
 
41
 
42
  def http_get(path: str, domain: str, token: str = None, params: dict = None) -> requests.Response:
43
+ """HTTP POST request to `path`, raises UnreachableAPIError if the API cannot be reached"""
44
  try:
45
  response = requests.get(
46
  url=domain + path,
49
  params=params,
50
  )
51
  except requests.exceptions.ConnectionError:
52
+ print(f"❌ Failed to reach {path}, check your internet connection")
53
  response.raise_for_status()
54
  return response
55