Skip to content

Commit

Permalink
missing docstrings
Browse files Browse the repository at this point in the history
  • Loading branch information
deeleeramone committed Dec 8, 2024
1 parent e9c3aa5 commit cb8435e
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import asyncio
import json
import sys
from pathlib import Path
from typing import Optional

import uvicorn
Expand All @@ -22,6 +23,7 @@
SLEEP_TIME = kwargs.pop("sleep_time", None) or 0.25
AUTH_TOKEN = kwargs.pop("auth_token", None)


app = FastAPI()


Expand Down Expand Up @@ -156,7 +158,6 @@ def _decrypt_value(self, value: str) -> str:
async def stream_results(self): # noqa: PLR0915
"""Continuously read the database and send new messages as JSON via WebSocket."""
import sqlite3 # noqa
from pathlib import Path
from openbb_core.app.model.abstract.error import OpenBBError

file_path = Path(self.results_file).absolute()
Expand Down Expand Up @@ -232,6 +233,7 @@ async def broadcast(self, message: str):
connected_clients.remove(client)

def start_app(self, host: str = "127.0.0.1", port: int = 6666, **kwargs):
"""Start the FastAPI app with Uvicorn."""
uvicorn.run(
self._app,
host=host,
Expand All @@ -247,10 +249,12 @@ def create_broadcast_server(
auth_token: Optional[str] = None,
**kwargs,
):
"""Create a new BroadcastServer instance."""
return BroadcastServer(results_file, table_name, sleep_time, auth_token)


def main():
"""Main entry point."""
broadcast_server = create_broadcast_server(
RESULTS_FILE,
TABLE_NAME,
Expand All @@ -276,4 +280,9 @@ def main():


if __name__ == "__main__":
if not RESULTS_FILE:
raise ValueError("Results file path is required for Broadcast server.")

if not Path(RESULTS_FILE).absolute().exists():
raise FileNotFoundError(f"Results file not found: {RESULTS_FILE}")
main()
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,6 @@ def parse_kwargs():
import sys

args = sys.argv[1:].copy()
sys.stdout.write(f"ARGS: {args}\n")
_kwargs: dict = {}
for i, arg in enumerate(args):
if arg.startswith("url"):
Expand Down

0 comments on commit cb8435e

Please sign in to comment.