Spaces:
Running on Zero
Running on Zero
Download app.py from Samuelson77/q-snasb-flight-deck: direct link, hf CLI and curl.
- Browser
- Download file 2.45 kB
-
https://huggingface.co/spaces/Samuelson77/q-snasb-flight-deck/resolve/c2fdfa2c33d2bf39b34d2d2a98d48eac591e7d73/app.py
- Command line
-
hf download hf://spaces/Samuelson77/q-snasb-flight-deck@c2fdfa2c33d2bf39b34d2d2a98d48eac591e7d73/app.py
-
curl -L -o app.py https://huggingface.co/spaces/Samuelson77/q-snasb-flight-deck/resolve/c2fdfa2c33d2bf39b34d2d2a98d48eac591e7d73/app.py
2.45 kB
| import subprocess | |
| from pathlib import Path | |
| from fastapi import FastAPI | |
| from fastapi.responses import FileResponse, JSONResponse | |
| from fastapi.staticfiles import StaticFiles | |
| from quantum_co_processor.q_navigation_engine import ( | |
| ObstaclePolygon, | |
| QUAVTrajectoryPlanner, | |
| PQCQuantumRLAttitudeController, | |
| RelativisticSpacetimeQFIEstimator, | |
| ) | |
| import numpy as np | |
| app = FastAPI(title="Q-SNASB & Q-MCT v4.2 Flight Deck", version="4.2.0") | |
| BASE_DIR = Path(__file__).resolve().parent | |
| UI_DIR = BASE_DIR / "ui" | |
| BUILD_DIR = BASE_DIR / "build" | |
| async def serve_flight_deck(): | |
| return FileResponse(UI_DIR / "q_mct_flight_deck.html") | |
| async def get_live_layer_telemetry(): | |
| # Execute Layer 1 C++20 Quantum Core Firmware binary | |
| l1_proc = subprocess.run( | |
| [str(BUILD_DIR / "quantum_core_driver")], | |
| capture_output=True, | |
| text=True, | |
| timeout=5, | |
| ) | |
| # Execute Layer 2 C++20 Swarm WCI & DTN Middleware binary | |
| l2_proc = subprocess.run( | |
| [str(BUILD_DIR / "swarm_wci_dtn_node")], | |
| capture_output=True, | |
| text=True, | |
| timeout=5, | |
| ) | |
| # Execute Layer 3 Python Quantum Co-Processor diagnostics | |
| obstacles = [ObstaclePolygon(center_xy=(500.0, 200.0), radius_m=120.0)] | |
| planner = QUAVTrajectoryPlanner(start_xy=(0.0, 0.0), end_xy=(1000.0, 400.0), obstacles=obstacles) | |
| candidates = [ | |
| [(0.0, 0.0), (500.0, 210.0), (1000.0, 400.0)], | |
| [(0.0, 0.0), (480.0, 460.0), (1000.0, 400.0)], | |
| ] | |
| quav_res = planner.evaluate_candidate_paths(candidates) | |
| qrl = PQCQuantumRLAttitudeController(n_qubits=4, n_layers=3) | |
| qrl_actions = qrl.forward_expectation_z(np.array([0.12, -0.08, 0.04, -0.15])).tolist() | |
| qfim_res = RelativisticSpacetimeQFIEstimator.compute_qfim_and_qcrb( | |
| r_meters=7.0e6, photon_freq_hz=3.84e14 | |
| ) | |
| return JSONResponse( | |
| { | |
| "status": "NOMINAL", | |
| "layer1_firmware_stdout": l1_proc.stdout.strip().splitlines(), | |
| "layer2_middleware_stdout": l2_proc.stdout.strip().splitlines(), | |
| "layer3_quantum_coprocessor": { | |
| "quav_qaoa": quav_res, | |
| "pqc_qrl_expectations": qrl_actions, | |
| "relativistic_qfim": qfim_res, | |
| }, | |
| } | |
| ) | |
| # Mount static HTML/CSS/JS assets at root so cross-page links resolve cleanly | |
| app.mount("/", StaticFiles(directory=str(UI_DIR), html=True), name="ui") |