fastapi cache. In our deployment, there might be. fastapi cache

 
 In our deployment, there might befastapi cache Next, using the installed MongoDB graphical user interface tool, Compass, create a database connection

memcached import memcached_plugin from fastapi_plugins. With deep support for asyncio, FastAPI is indeed very fast. You can also specify if your backend allows: Credentials (Authorization headers, Cookies, etc). If you love a cozy, comedic mystery, you'll love this 'whodunit' adventure. It is based on HTTPX, which in turn is designed based on Requests, so it's very familiar and intuitive. The PyPI package fastapi-cache receives a total of 2,490 downloads a week. FastAPI provides the same starlette. We're using FastAPICache to initialize the cache. But remember that when you import Query, Path, Header, and others from fastapi, those are actually functions that return special classes. redis if use RedisBackend. My goal is to build a small authorization system for my app. Dependency calls are cached. How does it work. mount("/public", StaticFiles(directory="public. py","contentType":"file. We have a FastAPI application that we deploy on AWS using Kubernetes. You can also declare singular values to be received as part of the body. In this case lru_cache is thread-safe (atleast from what I see on the net. E seu propósito é ser o FastAPI das CLIs. Short: yes, caches may cache the response even if no explicit controls are present, you need to explicitly disallow it. mount. Another possible way, is to use Depends class and to cache it, but its usage makes sense only with route methods, not with other regular methods which are called from route methods. All calls that come into the service prefixed with "api/" will get handled by this API. Released: Jun 29, 2021 A simple and robust caching solution for FastAPI endpoints, fueled by the unfathomable power of Redis. env file if get_settings (). This becomes extra critical when you start adding more advanced logic to. One of the fastest Python frameworks available. Get the username and password. backends. 共享业务逻辑. from fastapi import FastAPI, Request, Depends async def some_authz_func (request: Request): try: json_ = await request. Innat. I already checked if it is not related to FastAPI but to Swagger UI. I already searched in Google "How to X in FastAPI" and didn't find any information. The data_adapter directory contains modules responsible for interacting with the data layer, such as the database, cache, Elasticsearch, and more. Although FastAPI is a great framework with fantastic documentation, it's not quite obvious how to build larger projects for beginners. state. It returns an object of type HTTPBasicCredentials: It contains the username and password sent. The cache directory is overridden to keep the files handy in our project directory. FastAPI framework, high performance, easy to learn, fast to code, ready for production. The redirect works perfectly fine locally (though, this is without api-key), and both routes work perfectly fine when deployed on AWS and connected to directly, but something is blocking the redirect from route one ( abc/item ) to. Features Support redis, memcache,. You switched accounts on another tab or window. trying to download the file directly (the apparent slow js file) from /static/js/. Navigating back to the docs and executing the /csv route should provide the following response with a link for you to download your CSV data. FastAPI本身并没有提供结果缓存的功能,但我们可以使用常见的第三方缓存库来实现。. The only other possible value for this field is Miss. The main course is where you find the meat: def cache_response(func): """ Decorator that caches the response of a FastAPI async function. fastapi_cache tests . Join. py from f. Improve this answer. which should return something like: Running CUDA docker on CUDA. aioredis_fastapi is an asynchronous redis based session backend for FastAPI powered applications. My fix for now is downgrading back to version 0. Here is the code to init fastapi-cache @asynccontextmanager async def lifespan(app: FastAPI): redis = aioredis. FastAPIで、脆弱性対策のためにレスポンスヘッダーを追加する必要がありました。 すべてのレスポンスに同じヘッダーを追加したかったのですが、 FastAPIのドキュメントには記述がなく (発見しました) 、当初path operation関数 (例: @app. To run this example need to install these modules. To declare headers, you need to use Header, because otherwise the parameters would be interpreted as. This option will walk through creating a global class instance of your environment variables to be shared in your FastAPI project. The concept is plugin - plug a functional utility into your application without or with minimal effort. Use CORSMiddleware. Create a list of allowed origins (as strings). You can add middleware to FastAPI applications. There are also many other API frameworks than FastAPI which can be utilized as the API wrapper. You can use ut like this. Use the Form keyword to define Form-data in your endpoint, and more specifically, use Form (. The Item is defined and added from another app. The auth header in Swagger is now the token, and it validates, for about a minute. Connect and share knowledge within a single location that is structured and easy to search. 7-2019-10-15. In other words, FastAPI Redis Cache is a handy tool for developers as it helps build FastAPI. I searched the FastAPI documentation, with the integrated search. Typer, o FastAPI das interfaces de linhas de comando¶ Se você estiver construindo uma aplicação CLI para ser utilizada em um terminal ao invés de uma aplicação web, dê uma olhada no Typer. So, what is FastAPI? According to the official documentation, it’s a modern and fast web framework for building APIs with Python 3. However, I noticed that this does not work since a cache is created for each worker individually. How to clear cache? · Issue #17 · long2ice/fastapi-cache · GitHub. Learn more about TeamsTyper, the FastAPI of CLIs. over nginx)FastAPI Cache - A simple lightweight cache system. responses import JSONResponse. add_middleware ( CacheControlMiddleware, cache_control=CacheControl ( "public" )) To start, some imports: import asyncio from functools import wraps from fastapi import FastAPI, Request from fastapi. Fastapi Middleware performance tuning Fastapi JSON response classes comparison Gunicorn workers and threads Nginx in front of FastAPI Connection keepaliveUtilizing the Pydantic Settings Management utility is the recommended option when working with environment variables in a FastAPI project. k. you can try fastapi-cache. It is designed to make programming FastAPI applications easier by making assumptions about what every developer needs to get started. But you will probably still get some nice performance improvements just from the upgrade. And then, that system (in this case FastAPI) will take care of doing whatever is needed to provide your code with those. Introducing the FARM Stack - FastAPI, React, & MongoDB. It’s super fast, easy and quick to learn and implement, production-ready. postgresql caddy asyncio alembic fastapi fastapi-boilerplate fastapi-crud fastapi-pagination fastapi-async-db sqlmodel fastapi-sqlmodel fastapi-cache Updated Sep 9, 2023; Python; LuisLuii / FastAPIQuickCRUD Star 225. Reload to refresh your session. Learn how to install, use and customize. fastapi-cache. FastAPI Redis Example. Here uvicorn is an implementation of ASGI (Asynchronous Service Gateway Interface. time ()) class TestAuth. Response headers are sent only on the second request. To disable this, go to /examples/settings/actions and Disable Ac{ privacy: 'value', expiresIn: 300, cache: {get, set}, } Let us understand these options one-by-one: The privacy option can be set to any field that is valid as per RFC2616. Fork 103. "public-docs" This API isn't really an API, it's the gateway to the documentation and OpenAPI. But uvicorn doesn’t support preload option that is we wanted to load the main app only once and still have multiple workers. Download ZIP. 然后,由系统(本文中为 FastAPI )负责执行任意需要的逻辑,为代码提供这些依赖(「注入」依赖项)。. Basically, FastAPI does not affect safety of your app. I cannot use the startup event because I need to create a global variable. FastAPI documentation recommends using lru_cache decorated functions to retrieve the config file. また非同期プログラミングをサポートし、SQLAlchemyやTortoise-ORM. If you haven't an Auth0 account, you can sign up for a free one. The first constraint can be solved by using the Surrogate-Control header, and the second constraint can be solved by using the Cache-Control header: Surrogate-Control: max-age=86400. environment_name == 'production': cache = cache. fastapi (. Typer is FastAPI's little sibling. When you use FastAPI, there's a lot more going on, processing the request and response, handling dependencies, executing your own code, and particularly, waiting for the network. FastAPI and Redis Cache Arturo Cuicas · Follow 8 min read · May 12 Photo by Tim Evans on Unsplash We’re back with the FastAPI series, after a month of crazy. Second endpoint throws TypeError: cache_test2() got multiple values for argument 'num' from this line. Info. decorator import cache @cache (expire=60) async def get_auth_token () -> str: ## just to exemplify return str (time. The module containing the path function => "api". Now, that seems like a. . The app itself is a simple single-endpoint API. k. The tutorial covers: Artifact Cache. First, we’ll add and import the Redis package. ini requirements-test. config import get_settings def nocache (* args, ** kwargs): def decorator (func): return func return decorator # I have an . 6+ framework for building APIs based on standard Python type hints. In some situations, you might need to use a proxy server like Traefik or Nginx with a configuration that adds an extra path prefix that is not seen by your application. Why Clean Architecture? Clean architecture is a design approach that emphasizes separation of concerns, agnosticism, and testability, among other principles:. routers import ratings models. Installation This package is not registered. from fastapi import FastAPI from fastapi. Minimal example utilizing FastAPI and Celery with RabbitMQ for task queue, Redis for Celery backend and flower for monitoring the Celery tasks. Cache invalidation is easy too. Run the API in Local Machine. FastAPI Chameleon - Adds integration of the Chameleon template language to FastAPI. Opinionated Cache Extension for FastAPI Asynchronous Web Framework; This is an extension aiming at making cache access on the server By configuration at startup of the FastAPI App instance, you can set the backend and other configuration options and have it remain a class constant when using FastAPI's. Gunicorn by itself is not compatible with FastAPI, as FastAPI uses the newest ASGI standard. For example, if I make this endpoint to require some-custom-header:FastAPI brought to the table a new feature that previous web frameworks such as Flask and Django were lacking: asynchronous requests. But if I have a function that calls a function that. Support cache like ETag and Cache-Control. The dependency function can take a Request object and get the ulr, headers and body from it. Based on project statistics from the GitHub repository for the PyPI package. Performance In performance, FastAPI is the leader because it is speed-oriented, then next to Flask, and finally Django, which is not very fast. def token_required (func): @wraps (func) async def wrapper (*args, request: Request, **kwargs): my_header = request. You could also use from starlette. FastAPI/starlette are not in control of this as per the WSGI specification (see "Handling the Content-Length Header"). 8+ based on standard Python type hints. 跳转至 Follow @fastapi on Twitter to stay updated Subscribe to the FastAPI and friends newsletter 🎉 You can now sponsor FastAPI 🍰. we keep an in-memory cache of 400k mappings between a string and some glossary object. Teams. middleware import CacheControlMiddleware app = FastAPI () app. Docker image with Uvicorn managed by Gunicorn for high-performance FastAPI web applications in Python with. restart ↻. Share. All caches contain the same minimum interface which consists on the following. Project description fastapi-redis-cache Features. It takes each request that comes to your application. It should also be noted that you can reuse the same dependency in the path operation or its sub dependencies, as FastAPI implements the cache policy by default: If one of your dependencies is declared multiple times for the same path operation, for example, multiple dependencies have a common sub-dependency, FastAPI will know to. a Hit). # If cache is found then serves the data from cache if data is not None: data = data. Teams. Learn more about TeamsBut he was already adding * in his FastApi. fastapi-cache is a tool to cache fastapi response and function result, with backends support redis and memcache. A suspicious death, an upscale spiritual retreat, and a quartet of suspects with a motive for murder. 5 years in production, we have been making good and bad decisions that impacted our developer experience dramatically. 0a1. This is to allow the framework to consume the request body if desired. 9+ Python 3. They are non-idempotent and thus are NOT cached by browsers by default. First released in late 2018, FastAPI differentiates itself from other Python frameworks by offering a modern, fast, and succinct. py tox. FastAPI doesn't notice that the client request is done until the connection itself is closed. 0. We can use uvicorn for launching multiple workers of fastapi. 1 from functools import lru_cache 2 from timeit import repeat 3 4 @lru_cache(maxsize=16) 5 def steps_to(stair): 6 if stair == 1: In this case, you’re limiting the cache to a maximum of 16 entries. FastAPI 提供了简单易用,但功能强大的依赖注入系统。. What's the reason for using FastApi-Cache in a Django application, since it was made for and depends on (as you've discovered) FastAPI (a different web framework)? Also, redis is an external server and not part of your Python project (i. This reduces the per-request overhead while still ensuring the instance is created lazily, making it possible to have the database_uri reflect modifications to the environment performed after importing the. Asynchronous only for the time being. Create the following four files in that Docker directory. 특히 CORS의 세가지 시나리오에 대해서 알면. Water levels have gone down “a little bit" in Cache Creek, says Mayor John Ranta. For more advanced caching in FastAPI see fastapi-cache extension. With an ORM, you normally create a class that represents a table in a SQL database, each. Thus the error, since the file is necessary, but it is not present (at least, the key with that name is not present). if you need to access it in decorator you can use following. Method 2: Python caching using LRU cache decorator. The HTTP caching specification Section 3 lists when the response is forbidden to be cached. Support redis, memcache, dynamodb, and in-memory backends. df. Features. Example: Using a cache to avoid recomputing data or accessing a slow database can provide you with a great performance boost. Load application code before the worker processes are forked. 1 Answer. It can be an async def or normal def function, FastAPI will know how to handle it correctly. Here's the example code: import asyncio import asyncpg from fastapi import FastAPI, Request class Database (): async def create_pool (self): self. Reload to refresh your session. FastAPI Learn Deployment Run a Server Manually - Uvicorn¶. Features Automatic. Snyk scans all the packages in your projects for vulnerabilities and provides automated fix advice. This header allows you to control the length of time that the browser as well as CDNs will cache your static assets. Possible ways is to do it with Lazy loading and with Singlenton pattern, but I am looking for better approach for FastAPI. If this is your first use of FastAPI, you will have to install FastAPI on your system. Create plugins easily using dependency injection. And also with every response before returning it. Basically, FastAPI does not affect safety of your app. Memcached. Finally, there are services that focus. 16. . Possible ways is to do it with Lazy loading and with Singlenton pattern, but I am looking for better approach for FastAPI. This makes it easier to add new features or modify existing ones without affecting the rest of the system. The API Management service consists of two "APIs" (as it calls them): "simple-fastapi-api": This API is configured with subscriptionRequired: true and path: 'api'. FastAPI-Caching. For the purpose of this module, a cache is a mutable mapping of a fixed maximum size. In order to send the value to the next hop, the '/destination' url, I need to pass the value to the forward_request method. And it will save the returned value in a "cache" and pass it to all the "dependants. You signed in with another tab or window. Because the previous step copying the file could be detected by the Docker cache, this step will also use the Docker cache when available. OS: Centos 8. Cache miss — Cache miss is a state where the data requested for processing by a component or application is not found in the cache memory. metadata. But remember that when you import Query, Path, Header, and others from fastapi, those are actually functions that return special classes. Some of them are worth sharing. Artifact Cache is available in Basic, Standard, and Premium service tiers. They are non-idempotent and thus are NOT cached by browsers by default. It includes files for data manipulation, database. Q&A for work. With any sufficiently complex application, performance becomes a primary concern for optimization. I already checked if it is not related to FastAPI but to Pydantic. Cache-Control: max-age=60. This is useful when your data changes and you want to ensure you show the latest information. This decorator implements cache using the least recently used (LRU) caching strategy. And the spec says that the fields have to be named like that. FastAPI Learn Tutorial - User Guide Testing¶ Thanks to Starlette, testing FastAPI applications is easy and enjoyable. md FastAPI Cache Implements. When I make the requests directly to FastAPI (bypassing nginx) the counter is incremented on the status request. FastAPI Cache - A tool to cache FastAPI response and function results, with support for Redis, Memcached, DynamoDB, and in-memory backends. Furthermore, Redis is used as the caching backend by the library. The functools module is for higher-order functions: functions that act on or return other functions. Photo by Science in HD on Unsplash. I searched the FastAPI documentation, with the integrated search. from fastapi import FastAPI from slowapi. Create a list of allowed origins (as strings). The x-fastapi-cache header field indicates that this response was found in the Redis cache (a. It allows you to write less code while accomplishing more. 3. Core features: Generated project based on MVC architectural patternI used Mat's answer and created an open-source library that adds a fixture based on the code snippet. Learn more about TeamsFastAPI is a modern, fast (high-performance), web framework for building APIs with Python 3. Here we are using the recommended one: pyca/cryptography. 😁 It combines SQLAlchemy and Pydantic and tries to simplify the code you write as much as possible, allowing you to reduce the code duplication to a minimum , but while getting the best. Performance-wise, it’s up there with NodeJS and Go, and that tells you something. Our problem is that each worker creates its own object rather than sharing a single one. restart ↻. By the end of this setup, you’ll have a base project that can be re-used for other FastAPI projects. Before you begin protecting endpoints in your API you’ll need to create an API on the Auth0 Dashboard. See also: Provider Asynchronous injections. . py from pydantic import BaseSettings class Settings(BaseSettings): app_name: str = "Awesome API" admin_email: str items_per_user: int = 50 class Config: env_file = ". get ("/") async def root (): return {"message": "Hello World"} After that you can run the following command: uvicorn main:app. Notifications. ) to make a parameter required, instead of using await request. Python offers built-in possibilities for caching, from a simple dictionary to a more complete data structure such as functools. From the app folder, I run the up command: az containerapp up \ -g fastapi-aca-rg \ -n fastapi-aca-app \ --registry-server pamelascontainerregistry. In this example, we'll use SQLite, because it uses a single file and Python has integrated support. state. FastAPI documentation recommends using lru_cache decorated functions to retrieve the config file. Updating Helm Charts. I am building a browser game where every user has 4 types of ressources and each users produce more ressources based on the level of their farms. FastAPI Learn Advanced User Guide Custom Response - HTML, Stream, File, others¶. To declare headers, you need to use Header, because otherwise the parameters would be interpreted as. Learn more about TeamsA few things happening but let me discuss the important one first: FastAPI events. 6. The first constraint can be solved by using the Surrogate-Control header, and the second constraint can be solved by using the Cache-Control header: Surrogate-Control: max-age=86400. py -> main location/endopoint of APIs: /slow_api (port 5011) to run them on different ports (5010,5011). gitignore . Use the templates you created to render and return a TemplateResponse, passing the request as one of the key-value pairs in the Jinja2 "context". Pull requests 11. The script below shows a (simplified) example of what we are doing, though in our case the usage of Meta () is considerably more complex. Info. FastAPI は、PythonでAPIを開発するためのモダンで高速 (高性能)なWebフレームワークです。. Dependency Injection in FastAPI: Dependency Injection (DI) is a design pattern that allows the separation of the creation of an object from its dependencies. The /generate endpoint takes in text and uses a transformers pipeline to generate a completion, which it then returns as a response. We make use of @lru_cache on _get_fastapi_sessionmaker to ensure the same FastAPISessionMaker instance is reused across requests. I'm using fastAPI together with nginx, as a reverse proxy. The client micro service, which calls /do_something, has a timeout of 60 seconds in the request/post() call. First, some Docker jargon: A Docker image is a multi-layered environment that is exactly the environment your app thrives in, such as a Linux OS with Python 3. Support redis and memcache and in-memory backends. environment_name == 'production':. Let's say, some endpoint is sending me this: {"data_key": "data_value"}. (wrt threading) Your functions do. lru_cache. For this, you need to use LifespanManager. Reload to refresh your session. serializers: Serialize and deserialize the data between your code and the backends. Best option is using a library since FastAPI does not provide this functionality out-of-box. #142 opened on May 14 by mjpieters Version 1. CORS에 대해서 더 자세한 정보는 아래 REF)의 모질라 문서를 읽어보도록 하자. You almost always want to use a Redis instance tuned for caching when you're caching and a separate Redis instance tuned for data durability for storing application state. Follow edited Jan 6, 2022 at 19:15. The script below shows a (simplified) example of what we are doing, though in our case the usage of Meta () is considerably more complex. It runs fine, but after doing multiple inference calls, I noticed the vRAM of the GPU becomes full and the inference fails. Sorted by: 3. This package provides a client that integrates with Fastapi and provides a decorator to cache fastapi controllers responses. ; Select. The only other possible value for this field is Miss. FastAPI intercepts a web request, converts the request data to a Pydantic model, inserts dependencies etc. Simply click “Download file” and you will see the. fastapi-plugins. FastAPI Learn Advanced User Guide Behind a Proxy¶. For sharing data between processes you need to use Cache. long2ice / fastapi-cache Public. Another idea: return token with timestamp, that you can check timestamp to verify whether it is get from function or cache. Using Cache-Control: max-age=31536000 for your build/static assets, and Cache-Control: no-cache for everything else is a safe and. To pass the connection pool to every route you can use a middleware and add the pool to request. This can be achieved with the following fixture: @pytest. See it here. – alex_noname. requests_cache. And then, that system (in this case FastAPI) will take care of doing whatever is needed to provide your code with those. Aiocache provides 3 main entities: backends: Allow you specify which backend you want to use for your cache. The new docs will include Pydantic v2 and will use SQLModel once it is updated to use Pydantic v2 as well. Importe FastAPI. For example: import time from fastapi_cache. k. Populate FastAPI cache during startup for an endpoint. Easily integration with fastapi. responses import HTMLResponse from fastapi. k. The source of each value used to construct this cache key is given below: The optional prefix value provided as an argument to the FastApiRedisCache. Also, pass the template "context", which includes the route Request. REDIS or Cache. fastapi-cache is a tool to cache fastapi response and function result, with backends support redis, memcache, and dynamodb. 7-2019-10-15. types import CacheControl from fastapi_simple_cachecontrol. FastAPI doesn't ship with its own, and the problem you're seeing is due to using an event loop that inherits from asyncio's BaseEventLoop without providing an implementation of _make_subprocess_transport (the concrete classes ProactorEventLoop and SelectorEventLoop both define it, and they're the default on Windows and UNIX. Revalidation is the process of purging the Data Cache and re-fetching the latest data. With it, you can use pytest directly with FastAPI. Uvicorn is ASGI server which we will be using for production. py. You can use gunicorn 's --preload flag. You can also use encode/databases with FastAPI to connect to databases using async and await. What I am trying to do, is whenever a given user isSome basics about cache invalidation - how to make sure the cache doesn't get out-of-date; Overview. In these cases you can use root_path to configure your application. Note: Gunicorn doesn't limit the size of request body, but sizes of the request line and request header. I'm wondering if there is built-in way to cache the results of API requests so that they can be returned automatically when requested again? Some of the routes I plan to make call external APIs and do some data processing on the results, so they take a few seconds to finish. decorator import cache. 2. The below command line will do the job: docker exec -it station-db bash. About; Products. asyncio environment. Finally, in order to create the Docker images, we can use the docker-compose build command. FastAPI StreamingResponse with picamera2 - browser refresh problem. redis import RedisBackend from fastapi_cache. Based on my older post about deploying a containerized Flask app to Azure Container Apps, here's a similar process for deploying a FastAPI app instead. I already checked if it is not related to FastAPI but to Pydantic. This article is part one in a six-part tutorial series. drop_all (bind=engine) And then use it in your tests like so:Use pip to install fastapi and uvicorn as shown in fig 1 below. This does not generate etags that are a hash of the response content, but instead lets you pass in a custom etag generating function per endpoint that is called before executing the route function. Pydantic for the data parts. Start by installing the package: Shell. ) abaixo. As Python grows in popularity, the variety of high-quality frameworks available to developers has blossomed. Features. Reload to refresh your session. With Flask-like simplicity, Django-like batteries, and Go/Node-like performance, FastAPI is a powerful framework that makes it easy and fun to spin up. Currently supporting: SimpleMemoryCache, RedisCache using redis and MemCache using aiomcache. get ("/") def home (request: Request): return. This is because FastAPI session variables are stored client-side as a cookie, which has a limit of 4096 bytes of data. FastAPI also distinguishes itself with features like automatic OpenAPI (OAS) documentation for your API, easy-to-use data validation tools, and more. get ('/get') async def get_dataframe (request: Request): df = request. 1 spec states that the Pragma: no-cache response should be handled as Cache-Control: no-cache, but it’s not a reliable replacement due to the fact that it’s still a request header. 8+ non-Annotated. Flexibility Flexibility is something developers value a lot, and Flask is more flexible than Django. 0a1. Aiocache provides 3 main entities: backends: Allow you specify which backend you want to use for your cache. And still you can have FastAPI do the data. MEMCACHED . Technical Details. config. This makes it easier to add new features or modify existing ones without affecting the rest of the system. backends. Resource provider Asynchronous initializers. Opinionated Cache Extension for FastAPI Asynchronous Web Framework; This is an extension aiming at making cache access on the server By configuration at startup of the FastAPI App instance, you can set the backend and other configuration options and have it remain a class constant when using FastAPI's intuitive Dependency Injection system. Support redis, memcache, dynamodb, and in-memory backends. With deep support for asyncio, FastAPI is indeed very fast. RedirectResponse. 4) particularly with Flask. FastAPI performance tuning. from fastapi import FastAPI, status class Meta: def __init__ (self. I'm trying to create role-based access control on endpoint and since fastAPI has this build-in Depends method with possibility to cache result I'm trying to create something like this. You signed out in another tab or window. The ETag in the header stays unchanged when reloading the file. Requirements. In general, ASGI middlewares are classes that expect to receive an ASGI app as the first argument. redis import RedisBackend from fastapi_cache. For example: According to Uvicorn Documentation, --reload-include does work only if optional dependency Watchfiles (previously called watchgod) is installed.