TheXeos commited on
Commit
f980695
1 Parent(s): 7a90911

Try push_to_hub

Browse files
Files changed (1) hide show
  1. background_task.py +7 -2
background_task.py CHANGED
@@ -2,7 +2,7 @@ import os
2
  import random
3
  import pandas as pd
4
  from datetime import datetime
5
- from huggingface_hub import HfApi
6
 
7
 
8
  DATASET_REPO_URL = "https://huggingface.co/datasets/CarlCochet/BotFightData"
@@ -11,6 +11,10 @@ ELO_DIR = "soccer_elo"
11
  ELO_FILE = os.path.join(ELO_DIR, ELO_FILENAME)
12
  HF_TOKEN = os.environ.get("HF_TOKEN")
13
 
 
 
 
 
14
 
15
  class Model:
16
  """
@@ -110,7 +114,8 @@ class Matchmaking:
110
  data_dict["games_played"].append(model.games_played)
111
  df = pd.DataFrame(data_dict)
112
  print(df.head())
113
- df.to_csv(os.path.join(DATASET_REPO_URL, "resolve", "main", ELO_FILE))
 
114
  # df_matches = pd.DataFrame(self.matches)
115
  # date = datetime.now()
116
  # df_matches.to_csv(f"match_history/{date.strftime('%Y-%m-%d_%H-%M-%S_%f')}.csv", index=False)
 
2
  import random
3
  import pandas as pd
4
  from datetime import datetime
5
+ from huggingface_hub import HfApi, Repository
6
 
7
 
8
  DATASET_REPO_URL = "https://huggingface.co/datasets/CarlCochet/BotFightData"
 
11
  ELO_FILE = os.path.join(ELO_DIR, ELO_FILENAME)
12
  HF_TOKEN = os.environ.get("HF_TOKEN")
13
 
14
+ repo = Repository(
15
+ local_dir=ELO_DIR, clone_from=DATASET_REPO_URL, use_auth_token=HF_TOKEN
16
+ )
17
+
18
 
19
  class Model:
20
  """
 
114
  data_dict["games_played"].append(model.games_played)
115
  df = pd.DataFrame(data_dict)
116
  print(df.head())
117
+ df.to_csv(ELO_FILE)
118
+ repo.push_to_hub(commit_message="Update ELO")
119
  # df_matches = pd.DataFrame(self.matches)
120
  # date = datetime.now()
121
  # df_matches.to_csv(f"match_history/{date.strftime('%Y-%m-%d_%H-%M-%S_%f')}.csv", index=False)