fix: 15 bug fixes across orchestrator, runner, backtest, and infrastructure

Critical:
- strategy_orchestrator: fix IndentationError that prevented import (line 764)
- factor_runner: fix literal 'sys.executable' string → variable (line 966)

High (path bugs causing wrong directories):
- backtest_engine: fix results_path depth (3→4 .parent hops)
- results_db: fix factors_dir/failed_dir depth (3→4 .parent hops)
- factor_runner: eliminate run_id variable shadowing (parallel_run_id/db_run_id)
- model_runner: fix DB connection leak on add_backtest exception
- optuna_optimizer: fix imported logger shadowed by module-level reassignment

Medium:
- env: handle non-UTF-8 Docker build output with errors='replace'
- env: guard conda env list parsing against empty lines
- factor_runner: add check=False + stderr logging for full-data subprocess
- strategy_orchestrator: log exec() exceptions at ERROR level with traceback
- strategy_orchestrator: warn on unreplaced {{template}} variables in prompts

Low:
- factor_runner: guard IC_max.index access against scalar (AttributeError)
- predix_parallel: close log file handle on Popen failure
- predix_rebacktest_strategies: replace 4 bare except: with except Exception:
This commit is contained in:
TPTBusiness
2026-05-03 09:37:00 +02:00
parent 28766c932e
commit aba88dd090
8 changed files with 331 additions and 32 deletions
+6 -2
View File
@@ -923,7 +923,11 @@ def _prepare_conda_env(env_name: str, requirements_file: Path, python_version: s
"""
# 1. Create conda environment if not exists
env_list = subprocess.run(["conda", "env", "list"], capture_output=True, text=True, check=False)
env_exists = any(line.split()[0] == env_name for line in env_list.stdout.splitlines() if line and not line.startswith("#"))
env_exists = any(
line.split()[0] == env_name
for line in env_list.stdout.splitlines()
if line and not line.startswith("#") and len(line.split()) > 0
)
if not env_exists:
print(f"[yellow]Creating conda env '{env_name}' (Python {python_version})...[/yellow]")
subprocess.check_call(["conda", "create", "-y", "-n", env_name, f"python={python_version}"])
@@ -1189,7 +1193,7 @@ class DockerEnv(Env[DockerConf]):
with Progress(SpinnerColumn(), TextColumn("{task.description}")) as p:
task = p.add_task("[cyan]Building image...")
for part in resp_stream:
lines = part.decode("utf-8").split("\r\n")
lines = part.decode("utf-8", errors="replace").split("\r\n")
for line in lines:
if line.strip():
status_dict = json.loads(line)