julien-c HF staff commited on
Commit
f227033
1 Parent(s): 88775d1

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +15 -12
app.py CHANGED
@@ -31,18 +31,21 @@ def run(token: str, model_id: str) -> str:
31
  commit_info = convert(api=api, model_id=model_id)
32
 
33
  # save in a private dataset:
34
- repo.git_pull(rebase=True)
35
- with open(DATA_FILE, "a") as csvfile:
36
- writer = csv.DictWriter(csvfile, fieldnames=["model_id", "pr_url", "time"])
37
- writer.writerow(
38
- {
39
- "model_id": model_id,
40
- "pr_url": commit_info.pr_url,
41
- "time": str(datetime.now()),
42
- }
43
- )
44
- commit_url = repo.push_to_hub()
45
- print("[dataset]", commit_url)
 
 
 
46
 
47
  return f"""
48
  ### Success 🔥
 
31
  commit_info = convert(api=api, model_id=model_id)
32
 
33
  # save in a private dataset:
34
+ if repo is not None:
35
+ repo.git_pull(rebase=True)
36
+ with open(DATA_FILE, "a") as csvfile:
37
+ writer = csv.DictWriter(
38
+ csvfile, fieldnames=["model_id", "pr_url", "time"]
39
+ )
40
+ writer.writerow(
41
+ {
42
+ "model_id": model_id,
43
+ "pr_url": commit_info.pr_url,
44
+ "time": str(datetime.now()),
45
+ }
46
+ )
47
+ commit_url = repo.push_to_hub()
48
+ print("[dataset]", commit_url)
49
 
50
  return f"""
51
  ### Success 🔥