Log experimental results in a YAML file associated with the given `model_id`. If the file already exists, it appends new data to it; otherwise, it creates a new file. :param experiment_id: model identifier, (str). :param header: header for the data being logged, (str). :param c
(experiment_id, header, contents)
| 42 | |
| 43 | |
| 44 | def logger(experiment_id, header, contents): |
| 45 | """ |
| 46 | Log experimental results in a YAML file associated with the given `model_id`. If the file already exists, it appends new data to it; |
| 47 | otherwise, it creates a new file. |
| 48 | |
| 49 | :param experiment_id: model identifier, (str). |
| 50 | :param header: header for the data being logged, (str). |
| 51 | :param contents: data to be logged, provided as a dictionary, (dict). |
| 52 | """ |
| 53 | root_path = sys.path[0] |
| 54 | file_path = f"{root_path}/loggers/results/{experiment_id}/data.yaml" |
| 55 | |
| 56 | contents = {header: contents} |
| 57 | |
| 58 | if os.path.exists(file_path): |
| 59 | with open(file_path, "r") as yamlfile: |
| 60 | current_yaml = yaml.safe_load(yamlfile) |
| 61 | current_yaml.update(contents) |
| 62 | else: |
| 63 | current_yaml = contents |
| 64 | with open(file_path, "w") as yamlfile: |
| 65 | yaml.dump(current_yaml, yamlfile) |
| 66 | |
| 67 | |
| 68 | def read_log(model_id, header): |
nothing calls this directly
no outgoing calls
no test coverage detected