clefourrier HF staff albertvillanova HF staff commited on
Commit
e5d71ab
·
verified ·
1 Parent(s): cb1c891

Fix different results filenames locally and in the Hub (#19)

Browse files

- Align results filenames by calling datetime.now only once (300db21e23bdc470bd831db72b2dd318b7e55197)
- Rename results_path (fbab655a151d2b61cf784a7d2dae64e82927bbb7)


Co-authored-by: Albert Villanova del Moral <[email protected]>

src/backend/run_eval_suite_harness.py CHANGED
@@ -1,7 +1,7 @@
1
  import json
2
  import logging
3
- import os
4
  from datetime import datetime
 
5
  from typing import Union
6
 
7
  from lm_eval import evaluator, utils
@@ -72,16 +72,15 @@ def run_evaluation(
72
  dumped = json.dumps(results, indent=2)
73
  logger.info(dumped)
74
 
75
- output_path = os.path.join(local_dir, *eval_request.model.split("/"), f"results_{datetime.now()}.json")
76
- os.makedirs(os.path.dirname(output_path), exist_ok=True)
77
- with open(output_path, "w") as f:
78
- f.write(dumped)
79
 
80
  logger.info(evaluator.make_table(results))
81
 
82
  API.upload_file(
83
- path_or_fileobj=output_path,
84
- path_in_repo=f"{eval_request.model}/results_{datetime.now()}.json",
85
  repo_id=results_repo,
86
  repo_type="dataset",
87
  )
 
1
  import json
2
  import logging
 
3
  from datetime import datetime
4
+ from pathlib import Path
5
  from typing import Union
6
 
7
  from lm_eval import evaluator, utils
 
72
  dumped = json.dumps(results, indent=2)
73
  logger.info(dumped)
74
 
75
+ results_path = Path(local_dir, eval_request.model, f"results_{datetime.now()}.json")
76
+ results_path.parent.mkdir(exist_ok=True, parents=True)
77
+ results_path.write_text(dumped)
 
78
 
79
  logger.info(evaluator.make_table(results))
80
 
81
  API.upload_file(
82
+ path_or_fileobj=results_path,
83
+ path_in_repo=results_path.relative_to(local_dir).as_posix(),
84
  repo_id=results_repo,
85
  repo_type="dataset",
86
  )