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
+14 -10
View File
@@ -230,16 +230,20 @@ class ParallelRunner:
log_path = self.project_root / run_state.log_file
log_f = open(log_path, "a", encoding="utf-8")
# Start subprocess
run_state.process = subprocess.Popen(
cmd,
env=env,
cwd=str(self.project_root),
stdout=log_f,
stderr=subprocess.STDOUT,
)
run_state.status = "running"
run_state.start_time = datetime.now()
try:
# Start subprocess
run_state.process = subprocess.Popen(
cmd,
env=env,
cwd=str(self.project_root),
stdout=log_f,
stderr=subprocess.STDOUT,
)
run_state.status = "running"
run_state.start_time = datetime.now()
except Exception:
log_f.close()
raise
console.print(
f"[dim] ▶️ Run {run_state.run_id} started (PID: {run_state.process.pid}, "
+5 -4
View File
@@ -16,7 +16,8 @@ def load_factors(names, vdir):
if df is not None and len(df.columns) > 0:
dfs[n] = df.iloc[:, 0]
break
except: pass
except Exception:
pass
return dfs
def fix_code(code, available):
@@ -79,7 +80,7 @@ except Exception as e:
if r.returncode != 0:
return None
sig = pd.read_pickle(str(tdp / "s.pkl"))
except:
except Exception:
return None
fwd = df.mean(axis=1).shift(-96).dropna()
@@ -124,7 +125,7 @@ def main(count=None):
d = json.load(open(f))
if isinstance(d, dict) and 'strategy_name' in d:
files.append(f)
except: pass
except Exception: pass
if count: files = files[:count]
print(f"Re-evaluating {len(files)} strategies...\n")
@@ -147,7 +148,7 @@ def main(count=None):
with open(f, 'w') as out: json.dump(data, out, indent=2, ensure_ascii=False)
updated += 1
results.append({'name':data['strategy_name'], **bt})
except:
except Exception:
pass
p.update(task, advance=1)