OpenDILab commited on
Commit
56a30d8
1 Parent(s): eff0dab

dev(hus): use HfApi to upload log

Browse files
Files changed (1) hide show
  1. app.py +9 -11
app.py CHANGED
@@ -133,21 +133,19 @@ def _get_api_key_cfgs(api_key):
133
  if __name__ == '__main__':
134
 
135
  ###########################
 
 
 
 
136
  write_token = os.environ.get('CONTAINER')
137
  huggingface_hub.login(token = write_token, write_permission = True)
138
- JSON_DATASET_DIR = Path("json_dataset")
139
- JSON_DATASET_DIR.mkdir(parents=True, exist_ok=True)
140
- JSON_DATASET_PATH = JSON_DATASET_DIR / f"train-{uuid4()}.json"
141
- scheduler = huggingface_hub.CommitScheduler(
142
- repo_id="container",
143
- repo_type="dataset",
144
- folder_path=JSON_DATASET_DIR,
145
  path_in_repo="container.log",
 
 
146
  )
147
- with scheduler.lock:
148
- with JSON_DATASET_PATH.open("a") as f:
149
- json.dump('test data', f)
150
- f.write("\n")
151
  ###########################
152
 
153
  with gr.Blocks(title=title, theme='ParityError/Interstellar') as demo:
 
133
  if __name__ == '__main__':
134
 
135
  ###########################
136
+ os.makedirs('/data')
137
+ with open ('/data/test.json','w') as f:
138
+ f.write('hello')
139
+ api = huggingface_hub.HfApi()
140
  write_token = os.environ.get('CONTAINER')
141
  huggingface_hub.login(token = write_token, write_permission = True)
142
+
143
+ api.upload_file(
144
+ path_or_fileobj="/data/test.json",
 
 
 
 
145
  path_in_repo="container.log",
146
+ repo_id="OpenDILabCommunity/container",
147
+ repo_type="dataset",
148
  )
 
 
 
 
149
  ###########################
150
 
151
  with gr.Blocks(title=title, theme='ParityError/Interstellar') as demo: