From 7a5038fc97f4d1c7393d5db80cdee03f249e5156 Mon Sep 17 00:00:00 2001 From: Siddharth Narayanan Date: Wed, 27 Nov 2024 16:47:35 -0800 Subject: [PATCH] Making uvicorn import lazy (#131) --- src/aviary/dataset_server.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/aviary/dataset_server.py b/src/aviary/dataset_server.py index 146c5e95..85e3a500 100644 --- a/src/aviary/dataset_server.py +++ b/src/aviary/dataset_server.py @@ -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__) @@ -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