sheonhan commited on
Commit
ed05c10
1 Parent(s): f579e0b

git pull rebase and push to the hub after write block

Browse files
Files changed (1) hide show
  1. app.py +6 -3
app.py CHANGED
@@ -19,6 +19,7 @@ client = Client(
19
  headers={"Authorization": f"Bearer {API_TOKEN}"},
20
  )
21
 
 
22
  if HF_TOKEN:
23
  try:
24
  shutil.rmtree("./data/")
@@ -32,9 +33,11 @@ if HF_TOKEN:
32
 
33
 
34
  def save_inputs_and_outputs(inputs, outputs, generate_kwargs):
35
- with open(os.path.join("data", "prompts.jsonl"), "a") as f:
36
- json.dump({"inputs": inputs, "outputs": outputs, "generate_kwargs": generate_kwargs}, f, ensure_ascii=False)
37
- f.write("\n")
 
 
38
  repo.push_to_hub()
39
 
40
 
 
19
  headers={"Authorization": f"Bearer {API_TOKEN}"},
20
  )
21
 
22
+ repo = None
23
  if HF_TOKEN:
24
  try:
25
  shutil.rmtree("./data/")
 
33
 
34
 
35
  def save_inputs_and_outputs(inputs, outputs, generate_kwargs):
36
+ if repo is not None:
37
+ repo.git_pull(rebase=True)
38
+ with open(os.path.join("data", "prompts.jsonl"), "a") as f:
39
+ json.dump({"inputs": inputs, "outputs": outputs, "generate_kwargs": generate_kwargs}, f, ensure_ascii=False)
40
+ f.write("\n")
41
  repo.push_to_hub()
42
 
43