Spaces:
Runtime error
Runtime error
dev(hus): use HfApi to upload log
Browse files
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 |
-
|
139 |
-
|
140 |
-
|
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:
|