Commit f1d251ca authored by FarzanehNakhaee's avatar FarzanehNakhaee
Browse files

Update output path for the example logger

parent 5a766ac5
...@@ -10,6 +10,7 @@ from lm_eval.logger import eval_logger ...@@ -10,6 +10,7 @@ from lm_eval.logger import eval_logger
os.environ["TOKENIZERS_PARALLELISM"] = "false" os.environ["TOKENIZERS_PARALLELISM"] = "false"
ALL_TASKS = sorted(list(TASK_REGISTRY.keys()) + list(GROUP_REGISTRY.keys())) ALL_TASKS = sorted(list(TASK_REGISTRY.keys()) + list(GROUP_REGISTRY.keys()))
print("ALL tasks: ", ALL_TASKS)
class MultiChoice: class MultiChoice:
def __init__(self, choices): def __init__(self, choices):
...@@ -59,19 +60,19 @@ def pattern_match(patterns, source_list): ...@@ -59,19 +60,19 @@ def pattern_match(patterns, source_list):
task_names.add(matching) task_names.add(matching)
return sorted(list(task_names)) return sorted(list(task_names))
def setup_example_logger(output_path, separator): def setup_example_logger(output_path):
"""Sets up a logger that will save each example and prediction.""" """Sets up a logger that will save each example and prediction."""
example_logger = logging.getLogger("examples") example_logger = logging.getLogger("examples")
filename = f"./outputs/examples{separator}{output_path}.jsonl" if output_path:
formatter = logging.Formatter("%(message)s") filename = f"./{os.path.dirname(output_path)}/examples.jsonl"
handler = logging.FileHandler(filename) formatter = logging.Formatter("%(message)s")
handler.setFormatter(formatter) handler = logging.FileHandler(filename)
example_logger.addHandler(handler) handler.setFormatter(formatter)
example_logger.addHandler(handler)
example_logger.setLevel(logging.INFO) example_logger.setLevel(logging.INFO)
def main(): def main():
os.makedirs("./outputs", exist_ok=True)
args = parse_args() args = parse_args()
if args.limit: if args.limit:
...@@ -80,9 +81,10 @@ def main(): ...@@ -80,9 +81,10 @@ def main():
"REAL METRICS SHOULD NOT BE COMPUTED USING LIMIT." "REAL METRICS SHOULD NOT BE COMPUTED USING LIMIT."
) )
path_separator = "." if args.output_path:
output_path = args.output_path if args.output_path is not None else "" os.makedirs(os.path.dirname(args.output_path), exist_ok=True)
setup_example_logger(output_path, path_separator)
setup_example_logger(args.output_path)
if args.tasks is not None: if args.tasks is not None:
if os.path.isdir(args.tasks): if os.path.isdir(args.tasks):
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment