MCPcopy Create free account
hub / github.com/FinancialComputingUCL/LOBFrame / generate_id

Function generate_id

loggers/logger.py:10–28  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

8
9
10def 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
31def find_save_path(model_id):

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected