tutorial003_py39.py — fastapi Source File
Architecture documentation for tutorial003_py39.py, a python file in the fastapi codebase. 2 imports, 1 dependents.
Entity Profile
Dependency Diagram
graph LR 71f2968e_1af1_02b0_6082_4ff2aceb8912["tutorial003_py39.py"] a88eb002_9197_73f3_410d_ee5315767f34["contextlib"] 71f2968e_1af1_02b0_6082_4ff2aceb8912 --> a88eb002_9197_73f3_410d_ee5315767f34 534f6e44_61b8_3c38_8b89_6934a6df9802["__init__.py"] 71f2968e_1af1_02b0_6082_4ff2aceb8912 --> 534f6e44_61b8_3c38_8b89_6934a6df9802 32fe68d3_95d9_2e66_78d9_f6e43815ee26["test_tutorial003.py"] 32fe68d3_95d9_2e66_78d9_f6e43815ee26 --> 71f2968e_1af1_02b0_6082_4ff2aceb8912 style 71f2968e_1af1_02b0_6082_4ff2aceb8912 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
from contextlib import asynccontextmanager
from fastapi import FastAPI
def fake_answer_to_everything_ml_model(x: float):
return x * 42
ml_models = {}
@asynccontextmanager
async def lifespan(app: FastAPI):
# Load the ML model
ml_models["answer_to_everything"] = fake_answer_to_everything_ml_model
yield
# Clean up the ML models and release the resources
ml_models.clear()
app = FastAPI(lifespan=lifespan)
@app.get("/predict")
async def predict(x: float):
result = ml_models["answer_to_everything"](x)
return {"result": result}
Domain
Subdomains
Dependencies
- __init__.py
- contextlib
Source
Frequently Asked Questions
What does tutorial003_py39.py do?
tutorial003_py39.py is a source file in the fastapi codebase, written in python. It belongs to the FastAPI domain, Routing subdomain.
What functions are defined in tutorial003_py39.py?
tutorial003_py39.py defines 3 function(s): fake_answer_to_everything_ml_model, lifespan, predict.
What does tutorial003_py39.py depend on?
tutorial003_py39.py imports 2 module(s): __init__.py, contextlib.
What files import tutorial003_py39.py?
tutorial003_py39.py is imported by 1 file(s): test_tutorial003.py.
Where is tutorial003_py39.py in the architecture?
tutorial003_py39.py is located at docs_src/events/tutorial003_py39.py (domain: FastAPI, subdomain: Routing, directory: docs_src/events).
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free