Seetha commited on
Commit
d15528d
1 Parent(s): 99b81b2

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +19 -5
app.py CHANGED
@@ -65,10 +65,21 @@ import urllib.request
65
  import gradio as gr
66
  from gradio import inputs, outputs
67
  from datasets import load_dataset
 
 
 
 
 
 
 
 
 
68
 
69
- dataset = load_dataset('Seetha/Visualization', streaming=True)
70
- df = pd.DataFrame.from_dict(dataset['train'])
71
 
 
 
72
 
73
  def main():
74
 
@@ -472,8 +483,11 @@ def main():
472
  'target': col,
473
  'value': int(df_tab.loc[row, col])
474
  })
475
- dat = json.dumps(json_data)
476
- level2_df = pd.read_json(dat)
 
 
 
477
  # level2_df = pd.DataFrame.from_dict(dat, orient='index')
478
  # level2_df.reset_index(level=0,inplace=True)
479
  #st.write(level2_df)
@@ -484,7 +498,7 @@ def main():
484
  # fi.write(dat)
485
  # fi.truncate()
486
 
487
- updated_dataset = dataset.map(lambda example: {'new_value': level2_df['value'], 'new_source':level2_df['source'], 'new_target': level2_df['target']},remove_columns=['value','source','target'])
488
 
489
  # st.write(updated_dataset)
490
  #updated_dataset.push_to_hub('Seetha/visual', token=os.environ.get('HF_TOKEN'))
 
65
  import gradio as gr
66
  from gradio import inputs, outputs
67
  from datasets import load_dataset
68
+ from huggingface_hub import HfApi, list_models
69
+ import os
70
+ from huggingface_hub import HfFileSystem
71
+
72
+ # dataset = load_dataset('Seetha/Visualization', streaming=True)
73
+ # df = pd.DataFrame.from_dict(dataset['train'])
74
+ DATASET_REPO_URL = "https://huggingface.co/datasets/Seetha/Visualization"
75
+ DATA_FILENAME = "level2.json"
76
+ #DATA_FILE = os.path.join("data", DATA_FILENAME)
77
 
78
+ HF_TOKEN = os.environ.get("HF_TOKEN")
79
+ st.write("is none?", HF_TOKEN is None)
80
 
81
+ HfApi().delete_file(path_in_repo = DATA_FILENAME ,repo_id = 'Seetha/Visualization',token= HF_TOKEN,repo_type='dataset')
82
+ st.write('file-deleted')
83
 
84
  def main():
85
 
 
483
  'target': col,
484
  'value': int(df_tab.loc[row, col])
485
  })
486
+ fs = HfFileSystem(token=HF_TOKEN)
487
+ with fs.open('datasets/Seetha/Visualization.json', 'w') as f:
488
+ json.dump(json_data, f)
489
+ # dat = json.dumps(json_data)
490
+ # level2_df = pd.read_json(dat)
491
  # level2_df = pd.DataFrame.from_dict(dat, orient='index')
492
  # level2_df.reset_index(level=0,inplace=True)
493
  #st.write(level2_df)
 
498
  # fi.write(dat)
499
  # fi.truncate()
500
 
501
+ #updated_dataset = dataset.map(lambda example: {'new_value': level2_df['value'], 'new_source':level2_df['source'], 'new_target': level2_df['target']},remove_columns=['value','source','target'])
502
 
503
  # st.write(updated_dataset)
504
  #updated_dataset.push_to_hub('Seetha/visual', token=os.environ.get('HF_TOKEN'))