Simon Strandgaard commited on
Commit
19654e9
·
1 Parent(s): bb28e75

generate_run_id() now prefixes the string with PlanExe_

Browse files
src/plan/app_text2plan.py CHANGED
@@ -14,7 +14,7 @@ import threading
14
  from dataclasses import dataclass
15
  from math import ceil
16
  from src.llm_factory import get_available_llms
17
- from src.plan.generate_run_id import generate_run_id
18
  from src.plan.create_zip_archive import create_zip_archive
19
  from src.plan.filenames import FilenameEnum
20
  from src.plan.plan_file import PlanFile
 
14
  from dataclasses import dataclass
15
  from math import ceil
16
  from src.llm_factory import get_available_llms
17
+ from src.plan.generate_run_id import generate_run_id, RUN_ID_PREFIX
18
  from src.plan.create_zip_archive import create_zip_archive
19
  from src.plan.filenames import FilenameEnum
20
  from src.plan.plan_file import PlanFile
src/plan/generate_run_id.py CHANGED
@@ -1,17 +1,29 @@
1
  from datetime import datetime
2
  import uuid
3
 
4
- def generate_run_id(use_uuid: bool):
5
- """
6
- Generates a unique ID, either a UUID or a timestamp.
 
 
 
 
 
 
7
 
8
- In a multi user environment, use UUID to avoid conflicts.
9
- In a single user environment, use timestamp for human readability.
 
 
 
 
 
10
  """
11
  if use_uuid:
12
- return str(uuid.uuid4())
13
  else:
14
- return datetime.now().strftime("%Y%m%d_%H%M%S")
 
15
 
16
  if __name__ == "__main__":
17
  print(generate_run_id(use_uuid=True))
 
1
  from datetime import datetime
2
  import uuid
3
 
4
+ RUN_ID_PREFIX = "PlanExe_"
5
+
6
+ def generate_run_id(use_uuid: bool) -> str:
7
+ """Generates a unique run ID.
8
+
9
+ This function creates a unique identifier for a run, prefixed with `RUN_ID_PREFIX` for easy identification by purging scripts.
10
+
11
+ Args:
12
+ use_uuid: If True, generates a UUID-based ID. If False, generates a timestamp-based ID.
13
 
14
+ Returns:
15
+ A string representing the unique run ID.
16
+
17
+ The choice between UUID and timestamp depends on the environment:
18
+
19
+ * **Multi-user environments:** Use UUIDs to guarantee uniqueness and avoid conflicts.
20
+ * **Single-user environments:** Use timestamps for improved human readability.
21
  """
22
  if use_uuid:
23
+ return RUN_ID_PREFIX + str(uuid.uuid4())
24
  else:
25
+ return RUN_ID_PREFIX + datetime.now().strftime("%Y%m%d_%H%M%S")
26
+
27
 
28
  if __name__ == "__main__":
29
  print(generate_run_id(use_uuid=True))