-
Notifications
You must be signed in to change notification settings - Fork 3.7k
tg-autopilot D start #27198
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
tg-autopilot D start #27198
Conversation
- DynamicQuantizeMatMul - handle case where B zero point input is provided but not constant. (microsoft#25544) - Refactor plugin EP support (microsoft#25541) - Remove the python installation steps from win-qnn-arm64-ci-pipeline.yml (microsoft#25552) - [EP ABI] Node_GetAttrByName returns ORT_NOT_FOUND with non-existing attr name (microsoft#25565) - Fix C/C++ documentation generation (microsoft#25569) - [build] fix multi-config for VCPKG (microsoft#25585)
…1.23.0 release branch (microsoft#25606) ### Description Cherry-pick the microsoft#25566 for ORT 1.23
This PR cherry-picks some pipeline changes from the main branch to the 1.23.0 release branch. - **[build] disable CodeQL for NPM Packaging Pipeline (microsoft#25614)** - **Refactor Java Test Pipeline (microsoft#25608)** - **[build] upgrade Node.js for NPM packaging pipeline (microsoft#25568)** And a WebGPU change: - **[webgpu] Apply Flash Attention if sliding window exceeds KV cache length (microsoft#25594)**
) ### Description <!-- Describe your changes. --> Move moving weights to memory to the end of Graph::Resolve(). Modify Inject so it copies data into TensorProto according to the C API docs. ### Motivation and Context <!-- - Why is this change required? What problem does it solve? - If it fixes an open issue, please link to the issue here. --> TypeAndShape inference runs as a part of `Resolve()` and it unable to inspect and load the initializers that point to OrtValues at that time. We choose to move TensorProto to OrtValue conversion at the end of `Resolve()`. References: microsoft#25579 Co-authored-by: Dmitri Smirnov <yuslepukhin@users.noreply.github.com>
…#25659) Cherry-pick MiGraphX EP fixes from upstream for rel-1.23.0 This PR cherry-picks three critical fixes for the MiGraphX Execution Provider: 1. Fix compilation after cherry-picking from win-onnxruntime (microsoft#25516) - Adds ORT_UNUSED_PARAMETER(num_devices) to fix unused parameter warning - Corrects struct usage in CreateIExecutionProvider method 2. Fix CreateExecutionProviderFactory with correct struct and change vendor_id (microsoft#25625) - Updates vendor_id from 0x1002 to 0x9999 to allow DML EP to be default - Ensures proper device ordering in provider_policy_context.cc 3. Update OrtEpFactory in MiGraphX EP (microsoft#25567) - Adds complete OrtEpFactory infrastructure for auto EP selection - Implements all required factory methods with noexcept specifiers - Sets ort_version_supported to ORT_API_VERSION - Enables MiGraphX/AMDGPU EP integration with hardware device detection These fixes ensure MiGraphX EP builds correctly and integrates properly with the ORT execution provider selection framework in the 1.23.0 release. Cherry-picked commits: - 87f1499 - 14ca6df - 131cf40 --------- Co-authored-by: Artur Wojcik <artur.wojcik@amd.com> Co-authored-by: Owen Zhang <owen_zzz@hotmail.com> Co-authored-by: ozhang <ozhang@amd.com>
…5, 25652 (microsoft#25701) ### Description Cherry-pick the following PRs into the `rel-1.23.0` branch: - microsoft#25391 - microsoft#25611 - microsoft#25656 - microsoft#25346 - microsoft#25374 - microsoft#25664 - microsoft#25675 - microsoft#25652 ### Motivation and Context <!-- - Why is this change required? What problem does it solve? - If it fixes an open issue, please link to the issue here. --> --------- Co-authored-by: Yulong Wang <7679871+fs-eire@users.noreply.github.com> Co-authored-by: Ishwar Raut <iraut@nvidia.com> Co-authored-by: Maximilian Müller <44298237+gedoensmax@users.noreply.github.com> Co-authored-by: Gaurav Garg <gaugarg@nvidia.com> Co-authored-by: Scott McKay <skottmckay@gmail.com> Co-authored-by: Chi Lo <54722500+chilo-ms@users.noreply.github.com> Co-authored-by: Abhishek Jindal <abjindal@microsoft.com> Co-authored-by: Dmitri Smirnov <yuslepukhin@users.noreply.github.com>
### Description Cherry-pick the following PRs into `rel-1.23.0`: - microsoft#25629 - microsoft#25583 ### Motivation and Context <!-- - Why is this change required? What problem does it solve? - If it fixes an open issue, please link to the issue here. --> --------- Co-authored-by: Chunye Wang@AMD <Chunye.wang@amd.com> Co-authored-by: mingyue <mingyue@amd.com> Co-authored-by: Artur Wojcik <artur.wojcik@amd.com> Co-authored-by: urpetkov-amd <127323899+urpetkov-amd@users.noreply.github.com> Co-authored-by: Ted Themistokleous <107195283+TedThemistokleous@users.noreply.github.com> Co-authored-by: Ted Themistokleous <tedthemistokleous@amd.com> Co-authored-by: Scott McKay <Scott.McKay@microsoft.com>
### Description Cherry-picks microsoft#25725 into the `rel-1.23.0` branch. ### Motivation and Context <!-- - Why is this change required? What problem does it solve? - If it fixes an open issue, please link to the issue here. --> Co-authored-by: Ankit Maheshkar <ankit.maheshkar@intel.com> Co-authored-by: jatinwadhwa921 <110383850+jatinwadhwa921@users.noreply.github.com>
### Description Cherry-pick the following PRs into the `rel-1.23.0` branch: - microsoft#25592 - microsoft#25622 - microsoft#25688 - microsoft#25729 - microsoft#25743 - microsoft#25769 - microsoft#25745 - microsoft#25761 - microsoft#25751 - microsoft#25716 - microsoft#25228 - microsoft#25768 - microsoft#25788 - microsoft#25747 - microsoft#25800 - microsoft#25818 - microsoft#25762 - microsoft#25749 - microsoft#25831 ### Motivation and Context <!-- - Why is this change required? What problem does it solve? - If it fixes an open issue, please link to the issue here. --> --------- Co-authored-by: quic-tirupath <quic_tirupath@quicinc.com> Co-authored-by: quic-calvnguy <quic_calvnguy@quicinc.com> Co-authored-by: qti-kromero <kromero@qti.qualcomm.com> Co-authored-by: Jeff Kilpatrick <jkilpatrick@qti.qualcomm.com> Co-authored-by: Scott McKay <skottmckay@gmail.com> Co-authored-by: David Fan <30608893+jiafatom@users.noreply.github.com> Co-authored-by: kuanyul-qti <kuanyul@qti.qualcomm.com> Co-authored-by: Dmitri Smirnov <yuslepukhin@users.noreply.github.com> Co-authored-by: Chi Lo <54722500+chilo-ms@users.noreply.github.com> Co-authored-by: Edward Chen <18449977+edgchen1@users.noreply.github.com> Co-authored-by: Chunye Wang@AMD <chunywan@amd.com> Co-authored-by: minfhong-qti <minfhong@qti.qualcomm.com> Co-authored-by: Vishal Agarwal <vishala@nvidia.com> Co-authored-by: Maximilian Müller <maximilianm@nvidia.com> Co-authored-by: Maximilian Müller <44298237+gedoensmax@users.noreply.github.com> Co-authored-by: Changming Sun <chasun@microsoft.com> Co-authored-by: adrastogi <aditya.rastogi@microsoft.com> Co-authored-by: Aditya Rastogi <adityar@ntdev.microsoft.com> Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
- **Relax WeightBiasQuantization constraint for larger QDQ node group (microsoft#25673)** - **Add cuda graph implementation for NV TRT RTX EP (microsoft#25787)** - **python GPU IO Bindings for NVIDIA (microsoft#25776)** - **Fixes for DynamicQuantizeMatMul and Attention3D tests (microsoft#25814)** - **Fix a long standing bug on file memory mapping on windows. (microsoft#25833)** - **Add API for precompiled model compatibility check using just the compat info (microsoft#25841)** - **Enable ABSL_FLAGS flag registration for onnxruntime_perf_test for mobile build (microsoft#25849)** - **Add default constructor to Ort::Status. (microsoft#25860)** - microsoft#25871 - microsoft#25878 - microsoft#25884 - microsoft#25886 - microsoft#25866
### Description Cherry-pick the following PRs: microsoft#25943 microsoft#25937 microsoft#25917 microsoft#25909 microsoft#25898 microsoft#25897 microsoft#25888 microsoft#25881 microsoft#25830 microsoft#25619 microsoft#25575 microsoft#25572 microsoft#25558 microsoft#25530 microsoft#25474 microsoft#25455 microsoft#25110 Also two dependent PRs for qMoE cpu: microsoft#25877 microsoft#25822 --------- Co-authored-by: xiaomsft <136376084+xiaomsft@users.noreply.github.com> Co-authored-by: Xiaoyan Hu <xiaoh@microsoft.com> Co-authored-by: Akshay Sonawane <111780983+apsonawane@users.noreply.github.com> Co-authored-by: Kunal Vaishnavi <kvaishnavi@microsoft.com> Co-authored-by: Pradeep Sakhamoori <psakhamoori@microsoft.com> Co-authored-by: mingyue <131847423+mingyueliuh@users.noreply.github.com> Co-authored-by: Maximilian Müller <44298237+gedoensmax@users.noreply.github.com> Co-authored-by: Adrian Lizarraga <adlizarraga@microsoft.com> Co-authored-by: Dmitri Smirnov <yuslepukhin@users.noreply.github.com> Co-authored-by: Emmanuel <91394589+kobby-kobbs@users.noreply.github.com> Co-authored-by: Emmanuel Assumang <eassumang@microsoft.com> Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: praneshgo <pranesh.iitp@gmail.com> Co-authored-by: Hariharan Seshadri <shariharan91@gmail.com> Co-authored-by: Jing Fang <fajin@microsoft.com> Co-authored-by: Ishwar Raut <iraut@nvidia.com>
This PR cherry-picks the following PRs to the rel-1.23.0 branch: * microsoft#25938 * microsoft#25957 * microsoft#25960 * microsoft#25968 * microsoft#25971 --------- Co-authored-by: Dmitri Smirnov <yuslepukhin@users.noreply.github.com> Co-authored-by: Adrian Lizarraga <adlizarraga@microsoft.com> Co-authored-by: Hariharan Seshadri <shariharan91@gmail.com>
This PR cherry-picks the following PRs to the release branch: - microsoft#25988 - microsoft#25991 --------- Co-authored-by: Dmitri Smirnov <yuslepukhin@users.noreply.github.com> Co-authored-by: umangb-09 <umangb@nvidia.com>
This PR cherry-picks several commits from the main branch to the rel-1.23.0 release branch as part of the release process. ### Changes included: * **Major Refactoring of Azure DevOps Pipelines (microsoft#26008)** * Commit: `2e6d7ccfdff55aaf7b0799d7e28b041e607dce2b` * **Disables failing test to unblock Python DML Pipeline (microsoft#26043)** * Commit: `64c8f40d01bf14b3cf7ac4cf8606ad9e0e56feb0` * **Pin cmake version in macOS github Actions (microsoft#25998)** * Commit: `148f13cc6b44cae156226cd4e0dcfc154691c5b4` * **Bump actions/setup-python from 5 to 6 (microsoft#25979)** * Commit: `97a8d332595c974ad24be133df216565493ffb95` * **Remove CACHE_URL settings from Github Actions (microsoft#25989)** * Commit: `e2a0999ba4b224ab90ef7a8768dd4941fcc19b17` * **Bump actions/checkout from 4 to 5 (microsoft#25771)** * Commit: `f19215db21f8e1a8fc93090748e455f41076f456` * **Bump ruff from 0.12.8 to 0.12.9 (microsoft#25772)** * Commit: `78df404871fa2f3fbbb7f1902f9623787ba8dc86` * **Bump ruff from 0.12.4 to 0.12.8 (microsoft#25713)** * Commit: `7204746e709005d2c7294e7a24d63a2df4a1aee8` * **Update macOS target version from 13.3 to 13.4 (microsoft#25616)** * Commit: `65bd82564cd31e0acf9139cdd826d08193212c6e` --------- Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Prathik Rao <prathik.rao@gmail.com>
- **Major Refactoring of Azure DevOps Pipelines (microsoft#26008)** - **Convert QNN x64 pipeline to GH (microsoft#26047)** - **Upgrade com.diffplug.spotless to 7.2.1 in Java build (microsoft#26051)** - **Fix Mac Catalyst build options. (microsoft#25970)** - **Update Podfile.template: update macOS target version from 13.3 to 13.4 (microsoft#25699) **
… (microsoft#26087) Reduce Python and Nuget GPU package size (microsoft#26002) [CUDA] Add build flag onnxruntime_USE_FPA_INTB_GEMM (microsoft#25802)
### Description Cherry-pick the following PRs into the ORT 1.23.1 branch: - Fix Attention GQA implementation on CPU - **MANUAL MERGE**: see microsoft#26057 - main merge date: Sept 15, 11:33am - pr: microsoft#25966 - commit: d530b29 - Address edge GetMemInfo edge cases - main merge date: Sept 16, 10:32am - pr: microsoft#26021 - commit: d251f3a - Implement new Python APIs - main merge date: Sept 17, 11:44am - pr: microsoft#25999 - commit: abc63e8 - MemcpyFromHost and MemcpyToHost support for plugin EPs - **MERGE CONFLICT** on file onnxruntime/test/optimizer/transpose_optimizer_test.cc. Conflicts with microsoft#25689 - main merge date: Sept 23, 10:42am - pr: microsoft#26088 - commit: 4545732 - [TRT RTX EP] Fix bug for generating the correct subgraph in GetCapability microsoft#26132 - main merge date: Sept 23, 8:54pm - pr: microsoft#26132 - commit: 72e56e7 ### Motivation and Context <!-- - Why is this change required? What problem does it solve? - If it fixes an open issue, please link to the issue here. --> --------- Co-authored-by: Dmitri Smirnov <yuslepukhin@users.noreply.github.com> Co-authored-by: Edward Chen <18449977+edgchen1@users.noreply.github.com> Co-authored-by: Chi Lo <54722500+chilo-ms@users.noreply.github.com>
### Description Adds the following commits to the `rel-1.23.1` branch for ORT 1.23.1: - add session_id_ to LogEvaluationStart/Stop, LogSessionCreationStart - main merge date: July 31, 1:05am - pr: microsoft#25590 - commit: e753643 - [build] fix WebAssembly build on macOS/arm64 - main merge date: Aug 5, 8:07am - pr: microsoft#25653 - commit: 53f152b - [CPU] MoE Kernel (microsoft#25958) - main merge date: Sept 10, 4:54pm - pr: microsoft#25958 - commit: 930e640 - [CPU] Block-wise QMoE kernel for CPU - main merge date: Sept 15, 8:32am - pr: microsoft#26009 - commit: 5d17734 - [C#] Implement missing APIs - main merge date: Sept 24, 10:50am - pr: microsoft#26101 - commit: 35dcab5 - Regenerate test model with ONNX IR < 12 - main merge date: Sept 24, 2:50pm - pr: microsoft#26149 - commit: 88f2652 - [CPU] Fix compilation errors because of unused variables - main merge date: Sept 25, 1:21pm - pr: microsoft#26147 - commit: 42fcd71 - [EP ABI] Check if nodes specified in GetCapability() have already been assigned - main merge date: Sept 26, 1:24am - pr: microsoft#26156 - commit: 67d3ba0 - [QNN EP] Add dynamic option to set HTP performance mode - main merge date: Sept 26, 11:55am - pr: microsoft#26135 - commit: 6cc40fd --------- Co-authored-by: xieofxie <xieofxie@126.com> Co-authored-by: hualxie <hualxie@microsoft.com> Co-authored-by: Yulong Wang <7679871+fs-eire@users.noreply.github.com> Co-authored-by: Akshay Sonawane <111780983+apsonawane@users.noreply.github.com> Co-authored-by: Dmitri Smirnov <yuslepukhin@users.noreply.github.com> Co-authored-by: Edward Chen <18449977+edgchen1@users.noreply.github.com> Co-authored-by: quic-tirupath <quic_tirupath@quicinc.com> Co-authored-by: quic-ashwshan <quic_ashwshan@quicinc.com>
Adds the following commits to the release-1.23.2 branch for ORT 1.23.2: - [TensorRT] Fix DDS output bug during engine update - PR: microsoft#26272 - commit id: 00e85dd - Fix shape inference failure with in-memory external data - PR: microsoft#26263 - commit id: d955476 - [CUDA] replace 90a-virtual by 90-virtual for forward compatible - PR: microsoft#26230 - commit id: b58911f - [QNN-EP] Fix logic flow bug - PR: microsoft#26148 - commit id: b282379 - Internal Dupe of microsoft#25255 - [MLAS] Optimize MlasConv using thread partition opt - PR: microsoft#26103 - commit id: 7362518 - Update qMoE spec to support block quantization - PR: microsoft#25641 - commit id: 7a8ffa8 - [VitisAI] add new api to VitisAI to save graph as a string - PR: microsoft#25602 - commit id: 3361d72 - [[Build] Lock torch, onnxscript and onnx-ir versions to latest] - PR: microsoft#26315 - commit id: ea69c4d --------- Co-authored-by: Hariharan Seshadri <shariharan91@gmail.com> Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: Edward Chen <18449977+edgchen1@users.noreply.github.com> Co-authored-by: Yateng Hong <toothache9010@gmail.com> Co-authored-by: Changming Sun <chasun@microsoft.com> Co-authored-by: Dmitri Smirnov <dmitrism@microsoft.com> Co-authored-by: Tianlei Wu <tlwu@microsoft.com> Co-authored-by: quic-calvnguy <quic_calvnguy@quicinc.com> Co-authored-by: quic_calvnguy <quic_calvnguy@quic_inc.com> Co-authored-by: yifei410 <31260809+yifei410@users.noreply.github.com> Co-authored-by: yifei <y.zhou@xilinx.com>
|
@ArsenKhanamiryan please read the following Contributor License Agreement(CLA). If you agree with the CLA, please reply with the following information.
Contributor License AgreementContribution License AgreementThis Contribution License Agreement (“Agreement”) is agreed to by the party signing below (“You”),
|
set -euo pipefail
set +H
TS="$(date +%Y%m%d_%H%M%S)"
LOG="/tmp/tg_mac_autopilot_fix_${TS}.log"
TMP="/tmp/tg_mac_autopilot_fix_${TS}"
mkdir -p "$TMP"
exec > >(tee -a "$LOG") 2>&1
trap 'rc=$?; rm -rf "$TMP" >/dev/null 2>&1 || true; echo DONE_RC=$rc; echo LOG=$LOG; tail -n 220 "$LOG" 2>/dev/null || true; exit $rc' EXIT
command -v python3 >/dev/null 2>&1 || { echo FATAL missing_python3; exit 1; }
HOME_DIR="$HOME"
ROOT="$HOME_DIR/codex_autopilot_workspace"
BIN="$HOME_DIR/bin"
VENV="$ROOT/venv"
LOGDIR="$ROOT/logs"
RUNDIR="$ROOT/run"
mkdir -p "$ROOT" "$BIN" "$LOGDIR" "$RUNDIR"
touch "$HOME_DIR/.zshrc" || true
grep -q 'export PATH="$HOME/bin:$PATH"' "$HOME_DIR/.zshrc" 2>/dev/null || echo 'export PATH="$HOME/bin:$PATH"' >> "$HOME_DIR/.zshrc"
NEED_INSTALL="1"
if [ -x "$BIN/tg-autopilot" ]; then
if "$BIN/tg-autopilot" --version 2>/dev/null | grep -q 'tg-autopilot-mac-v2'; then
NEED_INSTALL="0"
fi
fi
if [ "$NEED_INSTALL" = "1" ]; then
[ -d "$VENV" ] || python3 -m venv "$VENV"
"$VENV/bin/python" -m pip install --upgrade pip >/dev/null 2>&1 || true
"$VENV/bin/python" -m pip install fastapi uvicorn psutil >/dev/null 2>&1
cat > "$ROOT/panel_app.py" <<'PY'
import os, subprocess
from fastapi import FastAPI, Request
from fastapi.responses import HTMLResponse, PlainTextResponse
HOME=os.path.expanduser("~")
ROOT=os.path.join(HOME,"codex_autopilot_workspace")
def sh(cmd):
p=subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, text=True)
out=[]
for line in p.stdout:
out.append(line)
rc=p.wait()
return rc,"".join(out)
def exists(cmd):
return subprocess.call(["/bin/bash","-lc",f"command -v {cmd} >/dev/null 2>&1"])==0
def doctor_text():
lines=[]
lines.append(f"OK_PYTHON3={1 if exists('python3') else 0}")
lines.append(f"OK_NODE={1 if exists('node') else 0}")
lines.append(f"OK_NPM={1 if exists('npm') else 0}")
lines.append(f"OK_CODE={1 if exists('code') else 0}")
lines.append(f"OK_CODEX={1 if exists('codex') else 0}")
rc,out=sh(["/bin/bash","-lc","code --list-extensions 2>/dev/null | grep -i '^openai.chatgpt$' || true"])
lines.append(f"OK_VSCODE_EXT_openai.chatgpt={1 if out.strip() else 0}")
return "\n".join(lines)+"\n"
app=FastAPI()
@app.get("/health")
def health():
return {"status":"OK"}
@app.get("/", response_class=HTMLResponse)
def index():
return """<!doctype html><title>TG Autopilot</title>
TG Autopilot Panel (Mac)
@app.post("/api/run")
async def api_run(req: Request):
data=await req.json()
cmd=data.get("cmd","")
if cmd=="doctor":
return PlainTextResponse(doctor_text())
if cmd=="open_workspace":
rc,out=sh(["/bin/bash","-lc",f"code '{ROOT}' >/dev/null 2>&1 || true; echo OK_OPENED={ROOT}"])
return PlainTextResponse(out)
return PlainTextResponse("ERR unknown_cmd\n", status_code=400)
PY
cat > "$BIN/tg-autopilot" <<'PY'
#!/usr/bin/env python3
import os, sys, json, subprocess, socket, time, signal, urllib.request, argparse
VERSION="tg-autopilot-mac-v2"
HOME=os.path.expanduser("~")
ROOT=os.path.join(HOME,"codex_autopilot_workspace")
VENV=os.path.join(ROOT,"venv")
RUN=os.path.join(ROOT,"run")
LOG=os.path.join(ROOT,"logs")
os.makedirs(RUN, exist_ok=True)
os.makedirs(LOG, exist_ok=True)
STATE=os.path.join(RUN,"panel_state.json")
def sh(cmd):
p=subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, text=True)
out=[]
for line in p.stdout:
out.append(line)
rc=p.wait()
return rc,"".join(out)
def exists(cmd):
return subprocess.call(["/bin/bash","-lc",f"command -v {cmd} >/dev/null 2>&1"])==0
def free_port():
for p in range(8890, 8910):
s=socket.socket()
try:
s.bind(("127.0.0.1", p))
s.close()
return p
except OSError:
try: s.close()
except: pass
raise SystemExit("FATAL no_free_port_8890_8909")
def load_state():
if not os.path.exists(STATE):
return {}
try:
with open(STATE,"r") as f:
return json.load(f)
except Exception:
return {}
def save_state(d):
with open(STATE,"w") as f:
json.dump(d,f)
def doctor():
lines=[]
lines.append(f"OK_PYTHON3={1 if exists('python3') else 0}")
lines.append(f"OK_NODE={1 if exists('node') else 0}")
lines.append(f"OK_NPM={1 if exists('npm') else 0}")
lines.append(f"OK_CODE={1 if exists('code') else 0}")
lines.append(f"OK_CODEX={1 if exists('codex') else 0}")
rc,out=sh(["/bin/bash","-lc","code --list-extensions 2>/dev/null | grep -i '^openai.chatgpt$' || true"])
lines.append(f"OK_VSCODE_EXT_openai.chatgpt={1 if out.strip() else 0}")
print("\n".join(lines))
def panel_start():
st=load_state()
pid=st.get("pid")
port=st.get("port")
if pid and port:
try:
os.kill(pid, 0)
print(f"OK_ALREADY_RUNNING url=http://127.0.0.1:{port} pid={pid}")
return
except Exception:
pass
port=free_port()
app=os.path.join(ROOT,"panel_app.py")
if not os.path.exists(app):
raise SystemExit("FATAL missing_panel_app.py")
log=os.path.join(LOG, f"panel_{time.strftime('%Y%m%d_%H%M%S')}.log")
cmd=[os.path.join(VENV,"bin","python"),"-m","uvicorn","panel_app:app","--app-dir",ROOT,"--host","127.0.0.1","--port",str(port)]
p=subprocess.Popen(cmd, stdout=open(log,"a"), stderr=subprocess.STDOUT)
save_state({"pid":p.pid,"port":port,"log":log,"started_at":time.time()})
time.sleep(0.9)
print(f"OK_STARTED url=http://127.0.0.1:{port} pid={p.pid} log={log}")
def panel_stop():
st=load_state()
pid=st.get("pid")
if not pid:
print("OK_NOT_RUNNING")
return
try:
os.kill(pid, signal.SIGTERM)
except Exception:
pass
time.sleep(0.4)
try:
os.kill(pid, 0)
try: os.kill(pid, signal.SIGKILL)
except Exception: pass
except Exception:
pass
print("OK_STOPPED")
def panel_status():
st=load_state()
pid=st.get("pid")
port=st.get("port")
if not pid or not port:
print("STATUS=DOWN")
return
alive=0
try:
os.kill(pid, 0)
alive=1
except Exception:
alive=0
print(f"STATUS={'UP' if alive else 'DOWN'} pid={pid} port={port}")
if st.get("log"):
print(f"LOG={st['log']}")
if alive:
print(f"URL=http://127.0.0.1:{port}")
def panel_health():
st=load_state()
port=st.get("port")
if not port:
print("HEALTH=DOWN")
return
url=f"http://127.0.0.1:{port}/health"
try:
with urllib.request.urlopen(url, timeout=3) as r:
code=r.getcode()
print(f"HEALTH_HTTP={code} URL={url}")
except Exception as e:
print(f"HEALTH_HTTP=000 URL={url} ERR={type(e).name}")
def d_map(subcmd):
if subcmd=="start":
panel_start()
return
if subcmd=="stop":
panel_stop()
return
if subcmd=="status":
panel_status()
return
if subcmd=="health":
panel_health()
return
if subcmd=="heal":
panel_stop()
time.sleep(0.4)
panel_start()
panel_health()
return
raise SystemExit("ERR unknown_D_subcmd")
def main():
ap=argparse.ArgumentParser(add_help=True)
ap.add_argument("--version", action="store_true")
ap.add_argument("cmd", nargs="?")
ap.add_argument("subcmd", nargs="?")
args=ap.parse_args()
if args.version:
print(VERSION)
return
if not args.cmd:
print("usage: tg-autopilot doctor|panel-start|panel-stop|panel-status|D <start|stop|status|health|heal>")
sys.exit(2)
if args.cmd=="doctor":
doctor()
return
if args.cmd=="panel-start":
panel_start()
return
if args.cmd=="panel-stop":
panel_stop()
return
if args.cmd=="panel-status":
panel_status()
return
if args.cmd=="D":
if not args.subcmd:
print("usage: tg-autopilot D <start|stop|status|health|heal>")
sys.exit(2)
d_map(args.subcmd)
return
raise SystemExit("ERR unknown_cmd")
if name=="main":
main()
PY
chmod +x "$BIN/tg-autopilot"
fi
WS="$(pwd)"
mkdir -p "$WS/.vscode"
python3 - <<PY
import json, os
ws=os.getcwd()
p=os.path.join(ws,".vscode","settings.json")
data={}
if os.path.exists(p):
try:
with open(p,"r",encoding="utf-8") as f:
data=json.load(f)
except Exception:
data={}
data["python.defaultInterpreterPath"]=os.path.expanduser("~/codex_autopilot_workspace/venv/bin/python")
with open(p,"w",encoding="utf-8") as f:
json.dump(data,f,indent=2,ensure_ascii=False)
print("OK_VSCODE_SETTINGS", p)
print("OK_PYTHON_DEFAULT", data["python.defaultInterpreterPath"])
PY
"$BIN/tg-autopilot" --version
"$BIN/tg-autopilot" doctor
"$BIN/tg-autopilot" D status
"$BIN/tg-autopilot" D start
"$BIN/tg-autopilot" D health