Skip to content

Commit

Permalink
pre-commit changes
Browse files Browse the repository at this point in the history
  • Loading branch information
gabrielrfg committed Sep 8, 2024
1 parent 6aea574 commit fef4c02
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 7 deletions.
8 changes: 5 additions & 3 deletions llmstudio/engine/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import json
import os
from pathlib import Path
from threading import Event
from typing import Any, Dict, List, Optional, Union

import uvicorn
Expand All @@ -9,7 +10,6 @@
from fastapi.middleware.cors import CORSMiddleware
from fastapi.responses import StreamingResponse
from pydantic import BaseModel, ValidationError
from threading import Event

from llmstudio.config import ENGINE_HOST, ENGINE_PORT
from llmstudio.engine.providers import *
Expand Down Expand Up @@ -79,7 +79,9 @@ def _merge_configs(config1, config2):
raise RuntimeError(f"Error in configuration data: {e}")


def create_engine_app(started_event: Event, config: EngineConfig = _load_engine_config()) -> FastAPI:
def create_engine_app(
started_event: Event, config: EngineConfig = _load_engine_config()
) -> FastAPI:
app = FastAPI(
title=ENGINE_TITLE,
description=ENGINE_DESCRIPTION,
Expand Down Expand Up @@ -169,7 +171,7 @@ async def startup_event():
return app


def run_engine_app(started_event : Event):
def run_engine_app(started_event: Event):
try:
engine = create_engine_app(started_event)
uvicorn.run(
Expand Down
1 change: 1 addition & 0 deletions llmstudio/llm/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
from llmstudio.llm.semaphore import DynamicSemaphore
from llmstudio.server import start_server


class LLM:
def __init__(self, model_id: str, **kwargs):
start_server()
Expand Down
4 changes: 2 additions & 2 deletions llmstudio/server.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import threading
from threading import Event

import requests

Expand All @@ -13,7 +14,6 @@
from llmstudio.engine import run_engine_app
from llmstudio.tracking import run_tracking_app
from llmstudio.ui import run_ui_app
from threading import Event

_servers_started = False

Expand All @@ -33,7 +33,7 @@ def start_server_component(host, port, run_func, server_name):
started_event = Event()
thread = threading.Thread(target=run_func, daemon=True, args=(started_event,))
thread.start()
started_event.wait() # wait for startup, this assumes the event is set somewhere
started_event.wait() # wait for startup, this assumes the event is set somewhere
return thread
else:
print(f"{server_name} server already running on {host}:{port}")
Expand Down
5 changes: 3 additions & 2 deletions llmstudio/tracking/__init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
from threading import Event

import uvicorn
from fastapi import APIRouter, FastAPI
from fastapi.middleware.cors import CORSMiddleware
from threading import Event

from llmstudio.config import TRACKING_HOST, TRACKING_PORT
from llmstudio.engine.providers import *
Expand All @@ -16,7 +17,7 @@


## Tracking
def create_tracking_app(started_event : Event) -> FastAPI:
def create_tracking_app(started_event: Event) -> FastAPI:
app = FastAPI(
title=TRACKING_TITLE,
description=TRACKING_DESCRIPTION,
Expand Down

0 comments on commit fef4c02

Please sign in to comment.