Skip to content
Snippets Groups Projects
Commit 300ba08e authored by Max Kimmich's avatar Max Kimmich
Browse files

Create unique run names

parent 0aff2b5c
No related branches found
No related tags found
No related merge requests found
import inspect import inspect
import json import json
import logging import logging
import os
import re import re
from functools import wraps from functools import wraps
from pathlib import Path from pathlib import Path
...@@ -32,17 +33,18 @@ Create a random name that sounds german or dutch ...@@ -32,17 +33,18 @@ Create a random name that sounds german or dutch
The parts should be separated by underscores and contain only lowercase. The parts should be separated by underscores and contain only lowercase.
Only return the name without any text before or after.""".strip() Only return the name without any text before or after.""".strip()
RUNS_DIR = current_directory / "runs"
def initialize_run_directory(model: OpenAI | Llama2): def initialize_run_directory(model: OpenAI | Llama2):
response, usage = model(None, run_name_prompt, chat=True) response, usage = model(None, run_name_prompt, chat=True)
model.usage -= usage model.usage -= usage
run_name_match = re.search(r"^\w+$", response, re.MULTILINE) run_name_match = re.search(r"^\w+$", response, re.MULTILINE)
if run_name_match is None: existing_dirs = os.listdir(RUNS_DIR)
if run_name_match is None or run_name_match.group(0) in existing_dirs:
run_name = uuid4().hex run_name = uuid4().hex
else: else:
run_name = run_name_match.group(0) run_name = run_name_match.group(0)
run_directory = current_directory / f"runs/{run_name}" run_directory = RUNS_DIR / run_name
# TODO what if name exists?
run_directory.mkdir(parents=True, exist_ok=False) run_directory.mkdir(parents=True, exist_ok=False)
# create file handler and set level to debug # create file handler and set level to debug
file_handler = logging.FileHandler(run_directory / "output.log") file_handler = logging.FileHandler(run_directory / "output.log")
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment