Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
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
8 changes: 6 additions & 2 deletions runpod/apps/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,12 @@
"tqdm-loggable",
)

# api workers additionally serve over fastapi/uvicorn
API_RUNTIME_REQUIREMENTS = ("fastapi[standard]", "uvicorn>=0.30")
# api workers additionally serve over fastapi/uvicorn. no [standard] extra:
# the runtime imports only fastapi and uvicorn, and the extra's closure
# (fastapi-cloud-cli, sentry, opentelemetry, rich, ...) is ~4,000 files and
# ~18 MB compressed that every cold worker downloads and unpacks. uvicorn
# still picks up uvloop/httptools from the api images, which ship them.
API_RUNTIME_REQUIREMENTS = ("fastapi", "uvicorn>=0.30")

# runpod's serverless limit for build artifacts
MAX_ARTIFACT_MB = 1500
Expand Down
16 changes: 16 additions & 0 deletions tests/test_apps/test_build.py
Original file line number Diff line number Diff line change
Expand Up @@ -476,6 +476,22 @@ def test_gpu_builtin_image_prunes_transitive_torch(self, tmp_path):
assert result.excluded == ["torch"]
assert _installed(result.env_dir) == ["peft"]

def test_api_runtime_vendors_fastapi_without_the_standard_extra(self, tmp_path):
app = App("a")

@app.api(name="web", cpu="cpu3c-2-4")
def web():
pass

seen = []
with patch(
"runpod.apps.build.vendor",
side_effect=lambda env_dir, requirements, *a, **k: seen.extend(requirements),
):
build_environment(app, tmp_path, scratch_dir=tmp_path / "s")
assert "fastapi" in seen and "uvicorn>=0.30" in seen
assert not any(r.startswith("fastapi[") for r in seen)

def test_runpod_in_dependencies_fails_before_vendoring(self, tmp_path):
app = App("a")

Expand Down
Loading