Generate a unique experiment identifier based on the input `name` and the current timestamp in the format "YYYY-MM-DD_HH_MM_SS". Create a directory path using this identifier within the 'loggers/results' directory relative to the script's location, and if it doesn't exist, create it.
(name, target_stock)
| 8 | |
| 9 | |
| 10 | def generate_id(name, target_stock): |
| 11 | """ |
| 12 | Generate a unique experiment identifier based on the input `name` and the current timestamp in the format "YYYY-MM-DD_HH_MM_SS". |
| 13 | Create a directory path using this identifier within the 'loggers/results' directory relative to the script's location, and if |
| 14 | it doesn't exist, create it. |
| 15 | |
| 16 | :param name: name of the DL model to be used in the experiment, (str). |
| 17 | :return: experiment_id: unique experiment identifier, (str). |
| 18 | """ |
| 19 | random_string_part = ''.join(random.choice(string.ascii_letters + string.digits) for _ in range(7)) |
| 20 | init_time = datetime.now().strftime("%Y-%m-%d_%H_%M_%S") |
| 21 | experiment_id = f"{target_stock}_{name}_{init_time}_{random_string_part}" |
| 22 | |
| 23 | root_path = sys.path[0] |
| 24 | dir_path = f"{root_path}/loggers/results/{experiment_id}" |
| 25 | if not os.path.exists(dir_path): |
| 26 | os.makedirs(dir_path) |
| 27 | |
| 28 | return experiment_id |
| 29 | |
| 30 | |
| 31 | def find_save_path(model_id): |
nothing calls this directly
no outgoing calls
no test coverage detected