Commit 20be6135 authored by Andrey Filippov's avatar Andrey Filippov

MCP-related scripts and switching LMA implementation to "elphel"-type

implementation
parent 557ea847
......@@ -320,3 +320,30 @@ Dependencies:
- eyesis_host_daemon.py
Tags: daemon, client, automation, mcp, lifecycle
## eyesis_run_report.py
Extract latest completed Eyesis run summary from eyesis_mcp.log and compare report JSONs.
Path: `scripts/eyesis_run_report.py`
Example:
```bash
/home/elphel/git/imagej-elphel/scripts/eyesis_run_report.py extract --snapshot-dir /tmp/eyesis-reports --auto-compare
```
Inputs:
- extract: --log path (default attic/session-logs/eyesis_mcp.log)
- extract: optional --json output, --snapshot-dir DIR, --auto-compare, --show-outputs N
- compare: --base report.json --new report.json
Outputs:
- Console summary for latest completed run
- Optional JSON report and/or timestamped snapshots for baseline tracking
- CSV-like metric delta table for report comparisons
Dependencies:
- python3
Tags: log, report, lma, comparison, automation
......@@ -245,6 +245,28 @@
],
"owner": "codex",
"created": "2026-02-23"
},
{
"name": "eyesis_run_report.py",
"path": "scripts/eyesis_run_report.py",
"purpose": "Extract latest completed Eyesis run summary from eyesis_mcp.log and compare report JSONs.",
"inputs": [
"extract: --log path (default attic/session-logs/eyesis_mcp.log)",
"extract: optional --json output, --snapshot-dir DIR, --auto-compare, --show-outputs N",
"compare: --base report.json --new report.json"
],
"outputs": [
"Console summary for latest completed run",
"Optional JSON report and/or timestamped snapshots for baseline tracking",
"CSV-like metric delta table for report comparisons"
],
"example": "/home/elphel/git/imagej-elphel/scripts/eyesis_run_report.py extract --snapshot-dir /tmp/eyesis-reports --auto-compare",
"tags": ["log", "report", "lma", "comparison", "automation"],
"dependencies": [
"python3"
],
"owner": "codex",
"created": "2026-02-23"
}
]
}
......@@ -40,6 +40,13 @@ tail -n 200 -F /home/elphel/git/imagej-elphel/attic/session-logs/eyesis_mcp.log
tail -n 100 -F /home/elphel/git/imagej-elphel/attic/session-logs/eyesis_host_daemon.log
```
Quick post-run summary and baseline compare:
```bash
/home/elphel/git/imagej-elphel/scripts/eyesis_run_report.py extract --snapshot-dir /tmp/eyesis-reports --auto-compare
# optional explicit compare using generated pointers:
/home/elphel/git/imagej-elphel/scripts/eyesis_run_report.py compare --base /tmp/eyesis-reports/run_previous.json --new /tmp/eyesis-reports/run_latest.json
```
## Request examples
Daemon-backed lifecycle request:
```bash
......
This diff is collapsed.
#!/usr/bin/env bash
set -euo pipefail
TARGET_DEFAULT="elphel@192.168.0.224"
TARGET="${TARGET:-$TARGET_DEFAULT}"
MODE="remote"
KWIN_ONLY=0
FORCE_DISPLAY="${DISPLAY_OVERRIDE:-}"
FORCE_XAUTH="${XAUTHORITY_OVERRIDE:-}"
SSH_CONNECT_TIMEOUT="${SSH_CONNECT_TIMEOUT:-7}"
usage() {
cat <<'EOF'
Recover KDE desktop responsiveness without reboot.
Default mode:
Connect to elphel@192.168.0.224 over SSH and run recovery there.
Usage:
recover_kde_gui.sh [options]
Options:
--target USER@HOST SSH destination (default: elphel@192.168.0.224)
--local Run recovery on current machine (no SSH)
--kwin-only Restart only kwin service (skip plasmashell restart)
--display VALUE Force DISPLAY (example: :0)
--xauthority PATH Force XAUTHORITY path
-h, --help Show this help
Examples:
recover_kde_gui.sh
recover_kde_gui.sh --target elphel@192.168.0.224
recover_kde_gui.sh --local --display :0
recover_kde_gui.sh --local --kwin-only
EOF
}
log() {
printf '[%s] %s\n' "$(date '+%F %T')" "$*"
}
detect_proc_env() {
local pid="$1"
local key="$2"
if [[ -r "/proc/$pid/environ" ]]; then
tr '\0' '\n' <"/proc/$pid/environ" | sed -n "s/^${key}=//p" | head -n1
fi
}
recover_local() {
local uid display xauth kwin_pid
uid="$(id -u)"
export XDG_RUNTIME_DIR="/run/user/$uid"
if [[ ! -d "$XDG_RUNTIME_DIR" ]]; then
log "ERROR: $XDG_RUNTIME_DIR is missing (no user runtime dir)."
return 2
fi
log "Restarting plasma-kwin_x11.service"
if ! systemctl --user restart plasma-kwin_x11.service; then
log "ERROR: failed to restart plasma-kwin_x11.service"
return 3
fi
if [[ "$KWIN_ONLY" -eq 1 ]]; then
log "Done (kwin-only mode)."
return 0
fi
kwin_pid="$(pgrep -u "$uid" -n -x kwin_x11 || true)"
display="$FORCE_DISPLAY"
if [[ -z "$display" && -n "$kwin_pid" ]]; then
display="$(detect_proc_env "$kwin_pid" DISPLAY || true)"
fi
if [[ -z "$display" ]]; then
display=":0"
fi
xauth="$FORCE_XAUTH"
if [[ -z "$xauth" && -n "$kwin_pid" ]]; then
xauth="$(detect_proc_env "$kwin_pid" XAUTHORITY || true)"
fi
if [[ -z "$xauth" ]]; then
xauth="$HOME/.Xauthority"
fi
export DISPLAY="$display"
export XAUTHORITY="$xauth"
log "Using DISPLAY=$DISPLAY XAUTHORITY=$XAUTHORITY"
log "Restarting plasmashell"
kquitapp5 plasmashell >/dev/null 2>&1 || true
sleep 1
kstart5 plasmashell >/dev/null 2>&1 || true
if command -v qdbus >/dev/null 2>&1; then
qdbus org.kde.KWin /Compositor suspend >/dev/null 2>&1 || true
sleep 1
qdbus org.kde.KWin /Compositor resume >/dev/null 2>&1 || true
fi
log "KDE recovery commands completed."
}
while [[ $# -gt 0 ]]; do
case "$1" in
--target)
TARGET="$2"
shift 2
;;
--local)
MODE="local"
shift
;;
--kwin-only)
KWIN_ONLY=1
shift
;;
--display)
FORCE_DISPLAY="$2"
shift 2
;;
--xauthority)
FORCE_XAUTH="$2"
shift 2
;;
-h|--help)
usage
exit 0
;;
*)
echo "Unknown argument: $1" >&2
usage
exit 1
;;
esac
done
if [[ "$MODE" == "remote" ]]; then
log "Connecting to $TARGET"
remote_cmd="$(printf "KWIN_ONLY=%q FORCE_DISPLAY=%q FORCE_XAUTH=%q bash -s -- --local" "$KWIN_ONLY" "$FORCE_DISPLAY" "$FORCE_XAUTH")"
exec ssh -o BatchMode=yes -o ConnectTimeout="$SSH_CONNECT_TIMEOUT" "$TARGET" "$remote_cmd" <"$0"
fi
recover_local
......@@ -4838,8 +4838,8 @@ public class Interscene {
opts.debugShowObservationHyperstack = clt_parameters.iglp.glob_debug_show_observation_hyperstack;
opts.saveInitialFinalOnly = clt_parameters.iglp.glob_save_initial_final_only;
opts.centerPairWeightMode = clt_parameters.iglp.glob_center_pair_weight_mode;
final int solverMode = clt_parameters.iglp.glob_solver_mode;
final String solverName = (solverMode == 1) ? "classic-lma" : "sparse-banded";
final int solverMode = IntersceneGlobalLmaParameters.clampSolverMode(clt_parameters.iglp.glob_solver_mode);
final String solverName = IntersceneGlobalLmaParameters.solverModeName(solverMode);
if (debugLevel > -4) {
System.out.println("reAdjustPairsLMAIntersceneGlobalReference(): center=" + center_index +
", range=[" + earliest_scene + "," + last_scene + "], outer=" + opts.outerIterations +
......@@ -4883,7 +4883,7 @@ public class Interscene {
param_lpf[ErsCorrection.DP_DSTL] + "," +
param_lpf[ErsCorrection.DP_DSRL] + "]");
}
if (solverMode == 1) {
if (solverMode == IntersceneGlobalLmaParameters.GLOB_SOLVER_CLASSIC_LMA) {
return IntersceneGlobalLmaRefine.refineAllToReference(
clt_parameters,
quadCLTs,
......
......@@ -7,6 +7,23 @@ import com.elphel.imagej.common.GenericJTabbedDialog;
public class IntersceneGlobalLmaParameters {
public static final double DEFAULT_GLOB_PCG_TOLERANCE = 1.0e-7;
public static final int GLOB_SOLVER_SPARSE_BANDED = 0;
public static final int GLOB_SOLVER_CLASSIC_LMA = 1;
public static int clampSolverMode(final int mode) {
if (mode <= GLOB_SOLVER_SPARSE_BANDED) {
return GLOB_SOLVER_SPARSE_BANDED;
}
if (mode >= GLOB_SOLVER_CLASSIC_LMA) {
return GLOB_SOLVER_CLASSIC_LMA;
}
return mode;
}
public static String solverModeName(final int mode) {
return (clampSolverMode(mode) == GLOB_SOLVER_CLASSIC_LMA) ? "classic-lma" : "sparse-banded";
}
public boolean glob_en;
public boolean glob_exit_after_test; // exit OpticalFlow.buildSeries() immediately after running, do not increment num_orient
public int glob_solver_mode; // 0 - current sparse global refine, 1 - classic LMA-structure implementation
......@@ -38,7 +55,7 @@ public class IntersceneGlobalLmaParameters {
public IntersceneGlobalLmaParameters() {
glob_en = true;
glob_exit_after_test = true; // TODO: change default to false when debugging is over
glob_solver_mode = 0;
glob_solver_mode = GLOB_SOLVER_SPARSE_BANDED;
param_sel = new boolean [ErsCorrection.DP_XYZATR.length];
param_regweights = new double [ErsCorrection.DP_XYZATR.length];
param_lpf = new double [ErsCorrection.DP_XYZATR.length];
......@@ -131,13 +148,7 @@ public class IntersceneGlobalLmaParameters {
public void dialogAnswers(GenericJTabbedDialog gd) {
this.glob_en = gd.getNextBoolean();
this.glob_exit_after_test = gd.getNextBoolean();
this.glob_solver_mode = (int) gd.getNextNumber();
if (this.glob_solver_mode < 0) {
this.glob_solver_mode = 0;
}
if (this.glob_solver_mode > 1) {
this.glob_solver_mode = 1;
}
this.glob_solver_mode = clampSolverMode((int) gd.getNextNumber());
this.param_sel = IntersceneMatchParameters.StringToBooleans(gd.getNextString(), this.param_sel);
this.param_regweights = IntersceneMatchParameters.StringToDoubles(gd.getNextString(), this.param_regweights);
this.param_lpf = IntersceneMatchParameters.StringToDoubles(gd.getNextString(), this.param_lpf);
......@@ -208,8 +219,7 @@ public class IntersceneGlobalLmaParameters {
if (properties.getProperty(prefix+"glob_en")!=null) this.glob_en=Boolean.parseBoolean(properties.getProperty(prefix+"glob_en"));
if (properties.getProperty(prefix+"glob_exit_after_test")!=null) this.glob_exit_after_test=Boolean.parseBoolean(properties.getProperty(prefix+"glob_exit_after_test"));
if (properties.getProperty(prefix+"glob_solver_mode")!=null) this.glob_solver_mode=Integer.parseInt(properties.getProperty(prefix+"glob_solver_mode"));
if (this.glob_solver_mode < 0) this.glob_solver_mode = 0;
if (this.glob_solver_mode > 1) this.glob_solver_mode = 1;
this.glob_solver_mode = clampSolverMode(this.glob_solver_mode);
if (properties.getProperty(prefix+"param_sel")!=null) this.param_sel= IntersceneMatchParameters.StringToBooleans(properties.getProperty(prefix+"param_sel"),this.param_sel);
if (properties.getProperty(prefix+"param_regweights")!=null) this.param_regweights= IntersceneMatchParameters.StringToDoubles(properties.getProperty(prefix+"param_regweights"),this.param_regweights);
if (properties.getProperty(prefix+"param_lpf")!=null) this.param_lpf= IntersceneMatchParameters.StringToDoubles(properties.getProperty(prefix+"param_lpf"),this.param_lpf);
......
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 to comment