lhoestq HF staff commited on
Commit
fab39d3
β€’
1 Parent(s): f1a73de

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +3 -3
app.py CHANGED
@@ -37,7 +37,7 @@ with gr.Blocks(css=css) as demo:
37
 
38
  @dataset_search.change(inputs=[dataset_search], outputs=[revision_dropdown, parquet_file_dropdown, output_dataframe])
39
  def dataset_update(dataset, oauth_token: Optional[gr.OAuthToken] = None):
40
- fs = HfFileSystem(token=oauth_token.token if oauth_token else None)
41
  if "/" not in dataset:
42
  return {revision_dropdown: gr.Dropdown(choices=[], value="", info="")}
43
  try:
@@ -49,7 +49,7 @@ with gr.Blocks(css=css) as demo:
49
 
50
  @revision_dropdown.change(inputs=[revision_dropdown], outputs=[parquet_file_dropdown, output_dataframe])
51
  def revision_update(dataset_and_revision, oauth_token: Optional[gr.OAuthToken] = None):
52
- fs = HfFileSystem(token=oauth_token.token if oauth_token else None)
53
  try:
54
  parquet_files = ["hf://" + path for path in fs.glob(f"datasets/{dataset_and_revision}/**/*.parquet")]
55
  parquet_file = parquet_files[0] if parquet_files else None
@@ -59,7 +59,7 @@ with gr.Blocks(css=css) as demo:
59
 
60
  @parquet_file_dropdown.change(inputs=[parquet_file_dropdown], outputs=[output_dataframe])
61
  def parquet_file_update(parquet_file, oauth_token: Optional[gr.OAuthToken] = None):
62
- fs = HfFileSystem(token=oauth_token.token if oauth_token else None)
63
  try:
64
  return {output_dataframe: pd.DataFrame([{k: str(v)[:1000] for k, v in x.items()} for x in pq.ParquetFile(parquet_file, filesystem=fs).read_row_group(0).to_pylist()] if parquet_file else [])}
65
  except Exception:
 
37
 
38
  @dataset_search.change(inputs=[dataset_search], outputs=[revision_dropdown, parquet_file_dropdown, output_dataframe])
39
  def dataset_update(dataset, oauth_token: Optional[gr.OAuthToken] = None):
40
+ fs = HfFileSystem(token=oauth_token.token if oauth_token else None, skip_instance_cache=True)
41
  if "/" not in dataset:
42
  return {revision_dropdown: gr.Dropdown(choices=[], value="", info="")}
43
  try:
 
49
 
50
  @revision_dropdown.change(inputs=[revision_dropdown], outputs=[parquet_file_dropdown, output_dataframe])
51
  def revision_update(dataset_and_revision, oauth_token: Optional[gr.OAuthToken] = None):
52
+ fs = HfFileSystem(token=oauth_token.token if oauth_token else None, skip_instance_cache=True)
53
  try:
54
  parquet_files = ["hf://" + path for path in fs.glob(f"datasets/{dataset_and_revision}/**/*.parquet")]
55
  parquet_file = parquet_files[0] if parquet_files else None
 
59
 
60
  @parquet_file_dropdown.change(inputs=[parquet_file_dropdown], outputs=[output_dataframe])
61
  def parquet_file_update(parquet_file, oauth_token: Optional[gr.OAuthToken] = None):
62
+ fs = HfFileSystem(token=oauth_token.token if oauth_token else None, skip_instance_cache=True)
63
  try:
64
  return {output_dataframe: pd.DataFrame([{k: str(v)[:1000] for k, v in x.items()} for x in pq.ParquetFile(parquet_file, filesystem=fs).read_row_group(0).to_pylist()] if parquet_file else [])}
65
  except Exception: