A pluggable server
Project description
FPS
FPS
(Fast Pluggable Server), is a framework designed to compose and run a web-server based on plugins.
It is based on top of FastAPI
, uvicorn
, typer
, and pluggy
.
Motivation
To better understand the motivations behind this project, please refer to the Jupyter server team compass.
How it works
The main purpose of FPS
is to provide hooks to register endpoints, static mounts, CLI setups/teardowns, etc.
An application can then be composed by multiple plugins providing specific/specialized endpoints. Those can be registered using fps.hooks.register_router
with a fastapi.APIRouter
.
What is coming soon
The most important parts will be to have a nice configuration system and also a logger working through multiprocesses, with homogeneous formatters to give devs/ops/users a smooth experience.
Concepts
Few concepts are extensively used in FPS
:
- a
hook
, orhook
implementation, is a method tagged as implementing ahook
specification- a hook specification is the declaration of the hook
@pluggy.HookspecMarker(HookType.ROUTER.value) def router() -> APIRouter: pass
- hooks are automatically collected by
FPS
using Python'sentry_point
s, and ran at the right time[options.entry_points] fps_router = fps_helloworld_router = fps_helloworld.routes fps_config = fps_helloworld_config = fps_helloworld.config
- multiple
entry_point
s groups are defined (e.g.fps_router
,fps_config
, etc.)- a hook MUST be declared in its corresponding group to be collected
- in the previous example,
HookType.ROUTER.value
equalsfps_router
, so therouter
hook is declared in that group
fps.hooks.register_<hook-name>
helpers are returning such hooksdef register_router(r: APIRouter): def router_callback() -> APIRouter: return r return pluggy.HookimplMarker(HookType.ROUTER.value)( function=router_callback, specname="router" )
- a hook specification is the declaration of the hook
- a
plugin
is a Python module declared in aFPS
'sentry_point
- a plugin may contain zero or more hooks
- in the following
helloworld
example, the hookconfig
is declared but not theplugin_name
one. Both are hooks of thefps_config
group.from fps.config import PluginModel from fps.hooks import register_config class HelloConfig(PluginModel): random: bool = True c = register_config(HelloConfig)
- a
plugins package
is a Python package declaring one or more plugins
Configuration
FPS
now support configuration using toml
format.
Precedence order
For now, the loading sequence of the configuration is: fps.toml
< <plugin-name>.toml
< <cli-passed-file>
< <cli-arg>
.
fps.toml
and <cli-passed-file>
files can contain configuration of any plugin, while <plugin-name>.toml
file
will only be used for that specific plugin.
fps.toml
and <plugin-name>.toml
currently have to be in the current working directory. Support for loading from user home
directory or system-wide application directory will be soon implemented.
Note: the environment variable FPS_CONFIG_FILE
is used to store cli-passed filename and make it available to subprocesses.
Merging strategy
At this time the merging strategy between multiple config sources is pretty simple:
- dict values for higher precedence source win
- no appending/prepending on sequences
Testing
FPS
has a testing module leveraging pytest
fixtures and fastAPI
dependencies override.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file fps-0.0.21.tar.gz
.
File metadata
- Download URL: fps-0.0.21.tar.gz
- Upload date:
- Size: 14.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.10.8
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 93d908c8b518b14879f1128f467834311ad1ae546ca6e49b47d72d0aa00f22f6 |
|
MD5 | 83662b41d02445483b81b4c040d8835d |
|
BLAKE2b-256 | 15cb0cc97a8bdf2f9404dfd2cd3e0a33dfda12479d62f673de91cfa6327694b7 |
File details
Details for the file fps-0.0.21-py3-none-any.whl
.
File metadata
- Download URL: fps-0.0.21-py3-none-any.whl
- Upload date:
- Size: 15.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.10.8
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | cf0e1b0d0d9373849d9d1ca95c0b081de3251fd9938dca66df31353c8a4f9238 |
|
MD5 | 25558205f578974cfbf0ba86b56a0bbe |
|
BLAKE2b-256 | 44e22d291d7641282074ecbbdb4038e81c1a0a03549c8b65985e2e467e422885 |