Skip to content

Data Scanner and Downloader#7

Merged
haoruizhou merged 10 commits intomainfrom
dev-data-downloader
Nov 13, 2025
Merged

Data Scanner and Downloader#7
haoruizhou merged 10 commits intomainfrom
dev-data-downloader

Conversation

@haoruizhou
Copy link
Collaborator

Automatic Full Database & Sensor Scanning

Summary

API Layer

  • Added a FastAPI surface exposing:
    • run, sensor, and scanner resources
    • Note persistence
    • Ad-hoc scan scheduling
    • Raw-signal SQL queries
  • Unified under a single service layer managing JSON-backed state.
    Files:
    backend/app.py, backend/services.py

Backend Infrastructure

  • Implemented:
    • Adaptive Influx scanner
    • Unique-sensor collector
    • JSON repositories with atomic writes
    • Periodic worker that reuses the API image for scheduled refreshes
  • Ensures consistent refresh cycles and fault-tolerant state management.
    Files:
    backend/server_scanner.py, backend/sql.py, backend/storage.py, backend/periodic_worker.py

Containerization

  • Containerized the stack for reproducible deployment.
  • Documented environment configuration and sample credentials.
  • API, worker, and frontend share a common ./data volume via Docker Compose.
    Files:
    docker-compose.yml, .env.example, backend/Dockerfile, frontend/Dockerfile

Frontend UI

  • Built a React interface for:
    • Browsing runs
    • Editing annotations
    • Triggering scans
    • Selecting sensors
    • Querying raw readings (with Plotly previews)
    • Exporting CSVs
  • All features powered by a shared API client.
    Files:
    frontend/src/App.tsx,
    frontend/src/components/RunTable.tsx,
    frontend/src/components/data-download.tsx,
    frontend/src/api.ts,
    frontend/src/styles.css

Demo & Data Seeding

  • Added onboarding documentation and seeded JSON data for offline demos.
  • Mirrors the backend schema for consistent local testing.
    Files:
    README.md,
    data/runs.json,
    data/sensors.json,
    data/scanner_status.json

Usage

Run locally with: docker compose up

Screenshots

Run list view Sensor scan UI

@haoruizhou haoruizhou requested a review from numcap November 12, 2025 05:24
@haoruizhou haoruizhou self-assigned this Nov 12, 2025
@haoruizhou
Copy link
Collaborator Author

@codex

Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@chatgpt-codex-connector
Copy link

Summary

Testing

  • ⚠️ npm install --package-lock=false (fails: 403 Forbidden fetching @types/react)

View task →

  - data-downloader/backend/storage.py:51-83 now records the snapshot’s updated_at value and re-reads the store just before writing so _preserve_concurrent_note_updates
    can merge in any notes edited while the scan was running instead of overwriting them with the stale snapshot.
  - data-downloader/backend/storage.py:99-127 adds helpers that re-read runs.json, compare note_updated_at timestamps (parsed via datetime), and copy across whichever
    note is newer, keeping user edits that landed during the scan window.

Addressed comment: "The scheduled scanner rebuilds runs.json from a snapshot taken at the start of merge_scanned_runs, then writes it back after the scan finishes. If a user edits a note while a scan is running, the scan process still writes the stale snapshot (lines 51‑80) and overwrites the user’s newer note because no cross‑process locking or reread happens before self.store.write. With the worker defaulting to hourly scans, this can silently discard user annotations whenever an edit overlaps with a scan. Consider rereading and merging just before the write, or using a file lock/last‑updated timestamp to detect and preserve newer notes.
"
@haoruizhou haoruizhou merged commit a9f19fb into main Nov 13, 2025
6 of 10 checks passed
@haoruizhou haoruizhou deleted the dev-data-downloader branch November 13, 2025 20:43
haoruizhou added a commit that referenced this pull request Nov 13, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant