Skip to content

Commit

Permalink
Making uvicorn import lazy (#131)
Browse files Browse the repository at this point in the history
  • Loading branch information
sidnarayanan authored Nov 28, 2024
1 parent 22dc897 commit 7a5038f
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/aviary/dataset_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,17 @@
from itertools import starmap
from typing import Generic, TypeVar

import uvicorn
from pydantic import BaseModel, Field

from aviary.env import Environment, TaskDataset
from aviary.tools import MessagesAdapter, ToolRequestMessage, ToolsAdapter

try:
import uvicorn
from fastapi import FastAPI, HTTPException
except ImportError:
# We will raise if a TaskDatasetServer is instantiated but fastapi is not available
FastAPI = HTTPException = None # type: ignore[misc,assignment]
# We will raise if a TaskDatasetServer is instantiated but FastAPI/uvicorn are not available
uvicorn = FastAPI = HTTPException = None # type: ignore[misc,assignment]

logger = logging.getLogger(__name__)

Expand Down Expand Up @@ -61,8 +61,8 @@ def __init__(
):
if FastAPI is None:
raise ImportError(
"FastAPI is required to run a TaskDatasetServer. "
"Please `pip install aviary[server]`."
"FastAPI and Uvicorn are required to run a TaskDatasetServer. "
"Please `pip install fhaviary[server]`."
)

self.dataset = dataset
Expand Down

0 comments on commit 7a5038f

Please sign in to comment.