Skip to content

Commit b436610

Browse files
committed
Fix cloud-sync cursor; update deploy and status
Handle named-server cursor behavior in cloud-sync: fetch the first batch before reading cursor.description so column names and signal columns are populated correctly, and iterate fetchmany() in a proper loop to avoid missing batches. Update .env.macbook to point DBC_HOST_PATH to the secret DBC location. Clarify docker-compose.macbook-base usage and environment file path in comments, and add status and Cloud Sync access URLs. Enhance status UI to show the DBC file name (shortened), color-code it (red for example.dbc), and retain the existing warning banner behavior for the example DBC.
1 parent de1b449 commit b436610

4 files changed

Lines changed: 27 additions & 11 deletions

File tree

universal-telemetry-software/cloud-sync/sync.py

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,8 @@ def sync(self, progress_cb: Optional[Callable[[int, int], None]] = None) -> dict
237237
if total_rows == 0:
238238
return {"rows_synced": 0, "batches": 0, "elapsed_s": 0.0}
239239

240-
# Use a named (server-side) cursor to avoid loading all rows into RAM
240+
# Use a named (server-side) cursor to avoid loading all rows into RAM.
241+
# description is not populated until after the first fetchmany() on named cursors.
241242
with local_conn.cursor("_cloud_sync") as read_cur:
242243
if cursor is None:
243244
read_cur.execute(
@@ -249,13 +250,15 @@ def sync(self, progress_cb: Optional[Callable[[int, int], None]] = None) -> dict
249250
(cursor,),
250251
)
251252

252-
col_names = [d.name for d in read_cur.description]
253-
signal_cols = [c for c in col_names if c not in _FIXED_COLS]
253+
col_names = None
254+
signal_cols = None
254255

255-
while True:
256-
rows = read_cur.fetchmany(self.batch_size)
257-
if not rows:
258-
break
256+
rows = read_cur.fetchmany(self.batch_size)
257+
while rows:
258+
# description is available after the first fetch on named cursors
259+
if col_names is None:
260+
col_names = [d.name for d in read_cur.description]
261+
signal_cols = [c for c in col_names if c not in _FIXED_COLS]
259262

260263
# Collect signal names present in this batch (non-null columns vary)
261264
batch_signal_names: Set[str] = set()
@@ -302,6 +305,7 @@ def sync(self, progress_cb: Optional[Callable[[int, int], None]] = None) -> dict
302305
progress_cb(rows_synced, total_rows)
303306

304307
logger.info(f"Batch {batches}: {rows_synced}/{total_rows} rows synced")
308+
rows = read_cur.fetchmany(self.batch_size)
305309

306310
finally:
307311
try:

universal-telemetry-software/deploy/.env.macbook

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
REMOTE_IP=10.71.1.10
55
TIMESCALE_TABLE=WFR26test
6-
DBC_HOST_PATH=./example.dbc
6+
DBC_HOST_PATH=../../secret-dbc/WFR25.dbc
77
GRAFANA_ADMIN_PASSWORD=admin
88

99
# Cloud Sync dashboard — http://localhost:8092

universal-telemetry-software/deploy/docker-compose.macbook-base.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
11
# MacBook base station — full local stack with TimescaleDB persistence
22
# Use this for development and testing with full telemetry recording.
3-
# Run from universal-telemetry-software/:
4-
# docker compose -f deploy/docker-compose.macbook-base.yml up -d --build
3+
# Run from repo root (data-acquisition/):
4+
# docker compose -f universal-telemetry-software/deploy/docker-compose.macbook-base.yml --env-file universal-telemetry-software/deploy/.env.macbook up -d --build
55
#
66
# Access points:
77
# Pecan dashboard: http://localhost:3000
8+
# Status page: http://localhost:8080
89
# Grafana: http://localhost:8087
910
# TimescaleDB: postgresql://wfr:wfr_password@localhost:5432/wfr
11+
# Cloud Sync: http://localhost:8092
1012

1113
networks:
1214
datalink:

universal-telemetry-software/status/index.html

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -539,6 +539,10 @@ <h1>[DAQ_BASE_STATION]</h1>
539539
<span class="metric-label">Write Errors</span>
540540
<span class="metric-value" id="timescaleErrors">--</span>
541541
</div>
542+
<div class="metric" style="margin-top:8px; padding-top:8px; border-top:1px solid #222;">
543+
<span class="metric-label">DBC File</span>
544+
<span class="metric-value" id="dbcFileName" style="font-size:0.75rem; word-break:break-all;">--</span>
545+
</div>
542546
</div>
543547
</div>
544548

@@ -729,7 +733,13 @@ <h1>[DAQ_BASE_STATION]</h1>
729733

730734
if (stats.dbc_file) {
731735
const dbcWarning = document.getElementById('dbcWarningBanner');
732-
if (stats.dbc_file.includes('example.dbc')) {
736+
const dbcFileName = document.getElementById('dbcFileName');
737+
const isExample = stats.dbc_file.includes('example.dbc');
738+
// Show just the filename, not the full container path
739+
const shortName = stats.dbc_file.split('/').pop();
740+
dbcFileName.textContent = shortName;
741+
dbcFileName.style.color = isExample ? '#f85149' : '#3fb950';
742+
if (isExample) {
733743
dbcWarning.style.display = 'block';
734744
} else {
735745
dbcWarning.style.display = 'none';

0 commit comments

Comments
 (0)