Commit 84525019 by ccran

feat: add optimize prompt;

parent 96c9a464
...@@ -35,7 +35,7 @@ DEFAULT_RULES_FILE = REPO_ROOT / "data" / "rules.xlsx" ...@@ -35,7 +35,7 @@ DEFAULT_RULES_FILE = REPO_ROOT / "data" / "rules.xlsx"
DEFAULT_REPORT_FILE = REPO_ROOT / "data" / "prompt_optimization_rounds.xlsx" DEFAULT_REPORT_FILE = REPO_ROOT / "data" / "prompt_optimization_rounds.xlsx"
DEFAULT_MAX_WORKERS = 10 DEFAULT_MAX_WORKERS = 10
DEFAULT_APP_SESSION = "jp-contract-debug" DEFAULT_APP_SESSION = "jp-contract-debug"
DEFAULT_APP_COMMAND = "python main.py" DEFAULT_APP_COMMAND = "source ~/.jp-contract/bin/activate && python main.py"
@dataclass @dataclass
...@@ -342,24 +342,18 @@ def run_batch() -> Path: ...@@ -342,24 +342,18 @@ def run_batch() -> Path:
def restart_app(session: str, command: str) -> None: def restart_app(session: str, command: str) -> None:
result = subprocess.run( subprocess.run(
["tmux", "has-session", "-t", session], ["tmux", "kill-session", "-t", session],
cwd=REPO_ROOT, cwd=REPO_ROOT,
text=True,
capture_output=True,
check=False, check=False,
) )
if result.returncode != 0: tmux_command = f"cd {shell_quote(str(REPO_ROOT))} && {command}"
raise RuntimeError(f"tmux session not found: {session}")
subprocess.run(["tmux", "send-keys", "-t", session, "C-c"], cwd=REPO_ROOT, check=True)
time.sleep(2)
subprocess.run( subprocess.run(
["tmux", "send-keys", "-t", session, f"cd {shell_quote(str(REPO_ROOT))} && {command}", "C-m"], ["tmux", "new-session", "-d", "-s", session, tmux_command],
cwd=REPO_ROOT, cwd=REPO_ROOT,
check=True, check=True,
) )
time.sleep(5) time.sleep(8)
def shell_quote(value: str) -> str: def shell_quote(value: str) -> str:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment