AlexNijjar commited on
Commit
ad2a76e
·
1 Parent(s): b190717

Fix not fetching data for latest runs

Browse files
Files changed (1) hide show
  1. src/wandb_data.py +14 -9
src/wandb_data.py CHANGED
@@ -231,6 +231,14 @@ def _add_runs(wandb_runs: list[wapi.Run]):
231
  RUNS[id].append(run)
232
 
233
 
 
 
 
 
 
 
 
 
234
  def _fetch_history(wandb_api: wandb.Api):
235
  wandb_runs = wandb_api.runs(
236
  WANDB_RUN_PATH,
@@ -240,11 +248,11 @@ def _fetch_history(wandb_api: wandb.Api):
240
  _add_runs(wandb_runs)
241
 
242
 
243
- def _fetch_current_runs(wandb_api: wandb.Api, now: datetime):
244
- contest_start = now.replace(hour=0, minute=0, second=0, microsecond=0)
245
  wandb_runs = wandb_api.runs(
246
  WANDB_RUN_PATH,
247
- filters={"config.type": "validator", "created_at": {'$gt': str(contest_start)}},
248
  order="+created_at",
249
  )
250
  _add_runs(wandb_runs)
@@ -265,7 +273,7 @@ def sync():
265
  if not RUNS:
266
  _fetch_history(wandb_api)
267
  else:
268
- _fetch_current_runs(wandb_api, now)
269
 
270
 
271
  def get_current_runs() -> list[Run]:
@@ -273,10 +281,7 @@ def get_current_runs() -> list[Run]:
273
  from chain_data import sync_metagraph
274
  sync_metagraph()
275
 
276
- now = datetime.now(TIMEZONE)
277
- today = now.replace(hour=0, minute=0, second=0, microsecond=0)
278
- if now.hour < 12:
279
- today -= timedelta(days=1)
280
 
281
  current_runs: list[Run] = []
282
 
@@ -285,4 +290,4 @@ def get_current_runs() -> list[Run]:
285
  if run.start_date >= today:
286
  current_runs.append(run)
287
 
288
- return current_runs
 
231
  RUNS[id].append(run)
232
 
233
 
234
+ def _get_contest_start() -> datetime:
235
+ now = datetime.now(TIMEZONE)
236
+ today = now.replace(hour=0, minute=0, second=0, microsecond=0)
237
+ if now.hour < 12:
238
+ today -= timedelta(days=1)
239
+ return today
240
+
241
+
242
  def _fetch_history(wandb_api: wandb.Api):
243
  wandb_runs = wandb_api.runs(
244
  WANDB_RUN_PATH,
 
248
  _add_runs(wandb_runs)
249
 
250
 
251
+ def _fetch_current_runs(wandb_api: wandb.Api):
252
+ today = _get_contest_start()
253
  wandb_runs = wandb_api.runs(
254
  WANDB_RUN_PATH,
255
+ filters={"config.type": "validator", "created_at": {'$gt': str(today)}},
256
  order="+created_at",
257
  )
258
  _add_runs(wandb_runs)
 
273
  if not RUNS:
274
  _fetch_history(wandb_api)
275
  else:
276
+ _fetch_current_runs(wandb_api)
277
 
278
 
279
  def get_current_runs() -> list[Run]:
 
281
  from chain_data import sync_metagraph
282
  sync_metagraph()
283
 
284
+ today = _get_contest_start()
 
 
 
285
 
286
  current_runs: list[Run] = []
287
 
 
290
  if run.start_date >= today:
291
  current_runs.append(run)
292
 
293
+ return current_runs