sheonhan commited on
Commit
bdd6050
1 Parent(s): 59b2505

rebase repo before pushing

Browse files
Files changed (1) hide show
  1. app.py +8 -5
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/")
@@ -28,14 +29,16 @@ if HF_TOKEN:
28
  repo = Repository(
29
  local_dir="./data/", clone_from="HuggingFaceH4/starchat-prompts", use_auth_token=HF_TOKEN, repo_type="dataset"
30
  )
31
- repo.git_pull()
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
 
41
  def get_total_inputs(inputs, chatbot, preprompt, user_name, assistant_name, sep):
 
19
  headers={"Authorization": f"Bearer {API_TOKEN}"},
20
  )
21
 
22
+ repo = None
23
  if HF_TOKEN:
24
  try:
25
  shutil.rmtree("./data/")
 
29
  repo = Repository(
30
  local_dir="./data/", clone_from="HuggingFaceH4/starchat-prompts", use_auth_token=HF_TOKEN, repo_type="dataset"
31
  )
32
+ repo.git_pull(rebase=True)
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
 
44
  def get_total_inputs(inputs, chatbot, preprompt, user_name, assistant_name, sep):