Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make fastapi a regular dependency #243

Merged
merged 2 commits into from
Feb 10, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
26 changes: 5 additions & 21 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -1,25 +1,9 @@
{
"version": "0.2.0",
"configurations": [
{
"name": "Debug examples/fastapi",
"type": "python",
"request": "launch",
"module": "uvicorn",
"args": [
"main:app",
"--app-dir",
"${workspaceFolder}/examples/fastapi/arcade_example_fastapi",
"--port",
"8002"
],
"jinja": true,
"justMyCode": true,
"cwd": "${workspaceFolder}/examples/fastapi/arcade_example_fastapi"
},
Comment on lines -4 to -19
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cleanup. The fastapi example was removed a while ago.

{
"name": "Debug `arcade workerup --no-auth`",
"type": "python",
"type": "debugpy",
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

type: python is being deprecated in favor of type: debugpy

See https://devblogs.microsoft.com/python/python-in-visual-studio-code-february-2024-release/

"request": "launch",
"program": "${workspaceFolder}/arcade/run_cli.py",
"args": ["workerup", "--no-auth"],
Expand All @@ -29,8 +13,8 @@
"cwd": "${workspaceFolder}"
},
{
"name": "Debug `arcade chat -s -d -h localhost`",
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cleanup: not actually streaming

"type": "python",
"name": "Debug `arcade chat -d -h localhost`",
"type": "debugpy",
"request": "launch",
"program": "${workspaceFolder}/arcade/run_cli.py",
"args": ["chat", "-d", "-h", "localhost"],
Expand All @@ -41,7 +25,7 @@
},
{
"name": "Debug `arcade dev`",
"type": "python",
"type": "debugpy",
"request": "launch",
"program": "${workspaceFolder}/arcade/run_cli.py",
"args": ["dev"],
Expand All @@ -52,7 +36,7 @@
},
{
"name": "Debug `arcade evals -d` on current file",
"type": "python",
"type": "debugpy",
"request": "launch",
"program": "${workspaceFolder}/arcade/run_cli.py",
"args": ["evals", "-d", "${fileDirname}", "-h", "localhost"],
Expand Down
8 changes: 4 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,8 @@ build-and-publish: build publish ## Build and publish.
docker: ## Build and run the Docker container
@echo "🚀 Building arcade and toolkit wheels..."
@make full-dist
@echo "Writing extras requirements.txt"
@cd arcade && poetry export --extras "fastapi" --output ../dist/requirements.txt
@echo "Writing requirements.txt"
@cd arcade && poetry export --output ../dist/requirements.txt
@echo "🚀 Building Docker image"
@cd docker && make docker-build
@cd docker && make docker-run
Expand All @@ -101,8 +101,8 @@ docker: ## Build and run the Docker container
docker-base: ## Build and run the Docker container
@echo "🚀 Building arcade and toolkit wheels..."
@make full-dist
@echo "Writing extras requirements.txt"
@cd arcade && poetry export --extras "fastapi" --output ../dist/requirements.txt
@echo "Writing requirements.txt"
@cd arcade && poetry export --output ../dist/requirements.txt
@echo "🚀 Building Docker image"
@cd docker && INSTALL_TOOLKITS=false make docker-build
@cd docker && INSTALL_TOOLKITS=false make docker-run
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ _Pst. hey, you, give us a star if you like it!_
Install the package:

```bash
pip install 'arcade-ai[fastapi]'
pip install arcade-ai
```

Log in to your account via the CLI:
Expand Down
17 changes: 2 additions & 15 deletions arcade/arcade/cli/serve.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,24 +5,11 @@
from contextlib import asynccontextmanager
from typing import Any

import fastapi
import uvicorn
from loguru import logger

from arcade.core.telemetry import OTELHandler

try:
import fastapi
except ImportError:
raise ImportError(
"FastAPI is not installed. Please install it using `pip install arcade-ai[fastapi]`."
)

try:
import uvicorn
except ImportError:
raise ImportError(
"Uvicorn is not installed. Please install it using `pip install arcade-ai[fastapi]`."
)

from arcade.sdk import Toolkit
from arcade.worker.fastapi.worker import FastAPIWorker

Expand Down
2 changes: 1 addition & 1 deletion arcade/arcade/sdk/eval/critic.py
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ def evaluate(self, expected: str, actual: str) -> dict[str, float | bool]:
from sklearn.metrics.pairwise import cosine_similarity
except ImportError:
raise ImportError(
"Use `pip install arcade[evals]` to install the required dependencies for similarity metrics."
"Use `pip install 'arcade-ai[evals]'` to install the required dependencies for similarity metrics."
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks 🙏

)
vectorizer = TfidfVectorizer()
tfidf_matrix = vectorizer.fit_transform([expected, actual])
Expand Down
2 changes: 1 addition & 1 deletion arcade/arcade/sdk/eval/eval.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
from scipy.optimize import linear_sum_assignment
except ImportError:
raise ImportError(
"Use `pip install arcade-ai[evals]` to install the required dependencies for evaluation."
"Use `pip install 'arcade-ai[evals]'` to install the required dependencies for evaluation."
)

from openai import AsyncOpenAI
Expand Down
2 changes: 1 addition & 1 deletion arcade/arcade/templates/{{ toolkit_name }}/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
1. [Install the Arcade Engine Locally](https://docs.arcade.dev/home/install/local)
2. Install extra dependencies needed for evals:
```bash
pip install 'arcade-ai[fastapi,evals]'
pip install 'arcade-ai[evals]'
```
3. Log into Arcade:
```bash
Expand Down
7 changes: 0 additions & 7 deletions arcade/arcade/worker/fastapi/__init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +0,0 @@
import importlib.util

# FastAPI is an optional dependency, so make sure it's installed
if importlib.util.find_spec("fastapi") is None:
raise ImportError(
"FastAPI is not installed. Please install it using `pip install arcade-ai[fastapi]`."
)
13 changes: 6 additions & 7 deletions arcade/pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "arcade-ai"
version = "1.0.1"
version = "1.1.0"
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since most people installed as pip install 'arcade-ai[fastapi]' I think it might be okay to only make this a minor release.

description = "Arcade Python SDK and CLI"
readme = "README.md"
packages = [
Expand All @@ -27,11 +27,11 @@ loguru = "^0.7.0"
tqdm = "^4.1.0"
types-python-dateutil = "2.9.0.20241003"
types-pytz = "2024.2.0.20241003"
opentelemetry-instrumentation-fastapi = {version = "0.48b0", optional = true}
opentelemetry-exporter-otlp-proto-http = {version = "1.27.0", optional = true}
opentelemetry-exporter-otlp-proto-common = {version = "1.27.0", optional = true}
fastapi = {version = "^0.115.3", optional = true}
uvicorn = {version = "^0.30.0", optional = true}
opentelemetry-instrumentation-fastapi = "0.48b0"
opentelemetry-exporter-otlp-proto-http = "1.27.0"
opentelemetry-exporter-otlp-proto-common = "1.27.0"
fastapi = "^0.115.3"
uvicorn = "^0.30.0"
scipy = {version = "^1.14.0", optional = true}
numpy = {version = "^2.0.0", optional = true}
scikit-learn = {version = "^1.5.0", optional = true}
Expand All @@ -40,7 +40,6 @@ python-dateutil = {version = "^2.8.2", optional = true}

pyreadline3 = {version = "^3.5.4", platform = "win32"}
[tool.poetry.extras]
fastapi = ["fastapi", "uvicorn", "opentelemetry-instrumentation-fastapi", "opentelemetry-exporter-otlp-proto-http", "opentelemetry-exporter-otlp-proto-common"]
evals = ["scipy", "numpy", "scikit-learn", "pytz", "python-dateutil"]

[tool.poetry.group.dev.dependencies]
Expand Down
3 changes: 1 addition & 2 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -37,15 +37,14 @@ RUN ls -la /app/arcade/
# Conditional installation based on version
RUN if [ ! "$(echo ${VERSION} | grep -E '\.dev0$')" ]; then \
echo "Installing wheel file" && \
python -m pip install ./arcade_ai-${VERSION}-py3-none-any.whl fastapi && \
python -m pip install ./arcade_ai-${VERSION}-py3-none-any.whl && \
python -m pip install -r ./requirements.txt; \
else \
echo "Installing from source" && \
cd /app/arcade && \
pip install poetry && \
poetry lock && \
poetry version 0.1.0 && \
pip install fastapi && \
pip install -r requirements.txt && \
pip install .; \
fi
Expand Down
2 changes: 1 addition & 1 deletion examples/serving-tools/modal/run-arcade-worker.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

image = (
Image.debian_slim()
.pip_install("arcade-ai[fastapi]")
.pip_install("arcade-ai")
.pip_install(toolkits)
.pip_install("fastapi>=0.115.3")
.pip_install("uvicorn>=0.24.0")
Expand Down