def file_processor()

in project/paperbench/paperbench/nano/utils.py [0:0]


def file_processor(logger, method_name, original_event_dict):
    event_dict = original_event_dict.copy()  # Avoid mutating the original

    destinations = event_dict.pop("destinations", [])
    run_group_id = event_dict.pop("run_group_id", None)
    run_id = event_dict.pop("run_id", None)
    runs_dir = event_dict.pop("runs_dir", get_default_runs_dir())

    if "run" in destinations and run_group_id and run_id:
        dst = bf.join(runs_dir, run_group_id, run_id, "run.log")
        with bf.BlobFile(dst, "a") as f:
            f.write(str(event_dict) + "\n")

    if "group" in destinations and run_group_id:
        dst = bf.join(runs_dir, run_group_id, "group.log")
        with bf.BlobFile(dst, "a") as f:
            f.write(str(event_dict) + "\n")

    return original_event_dict