Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 1 addition & 22 deletions leads_vec_rc/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
from json import loads, JSONDecodeError
from os import makedirs
from os.path import abspath, exists
from threading import Thread
from time import sleep
from typing import Any, override

Expand All @@ -15,20 +14,6 @@
from leads.data_persistence import DataPersistence, Vector, CSV, DEFAULT_HEADER_FULL
from leads_gui import Config

try:
from leads_vec_rc.jarvis import process


def processor() -> None:
while True:
callback.processed_data = process(callback.current_data)


processor_thread: Thread = Thread(name="Jarvis Processor", target=processor, daemon=True)
except ImportError:
process: None = None
processor_thread: None = None

config: Config = require_config()
if not exists(config.data_dir):
L.debug(f"Data directory not found. Creating \"{abspath(config.data_dir)}\"...")
Expand All @@ -53,7 +38,6 @@ def __init__(self) -> None:
super().__init__()
self.client: Client = start_client(config.comm_addr, create_client(config.comm_port, self), True)
self.current_data: dict[str, Any] = DataContainer().to_dict()
self.processed_data: dict[str, Any] | None = None

@override
def on_connect(self, service: Service, connection: Connection) -> None:
Expand Down Expand Up @@ -92,12 +76,7 @@ def on_disconnect(self, service: Service, connection: ConnectionBase) -> None:


callback: CommCallback = CommCallback()

if processor_thread:
processor_thread.start()

app: FastAPI = FastAPI(title="LEADS VeC Remote Analyst")

app.add_middleware(
CORSMiddleware,
allow_origins=["*"],
Expand All @@ -114,7 +93,7 @@ async def index() -> str:

@app.get("/current")
async def current() -> dict[str, Any]:
return callback.processed_data if callback.processed_data else callback.current_data
return callback.current_data


@app.get("/time_stamp")
Expand Down