Ese774 Frame (FastAPI Frame)
ese774_frame is a communication frame for exposing Python device-control classes through FastAPI/HTTP while allowing
clients to use an interface close to the original control class.
Communication between server and client uses JSON/HTTP. Device-specific communication remains in the control class,
while the frame provides common handling for HTTP transport, API exposure, property transport, return-type
reconstruction, clients/proxies, and .pyi generation for IDE completion.
Main features include:
- automatic exposure of public methods and properties of Python control classes
- automatic dispatch with
api_spec=None - exclusion from automatic exposure with
dispatch_exclude - combination of device-specific Routers with automatic dispatch
- transparent access to read-only and read-write properties
- reconstruction of dataclass and other return types from type annotations
- Sync and Async clients
- client creation through
DeviceProxy .pyigeneration for clients, Routers, andDeviceProxy- explicit API definitions using Pydantic +
ApiSpec - FastAPI / OpenAPI integration
Architecture
Python device control class
|
v
FastApiServer
|
+-- DeviceRouter / device-specific Router
| |
| +-- automatic method dispatch
| +-- property transport
| +-- explicit ApiSpec routes
|
v
HTTP / JSON
|
v
SyncDeviceClient / AsyncDeviceClient
|
+-- Python method call
+-- Python property access
+-- return-type reconstruction
|
v
DeviceProxy / device package API
A device-control class does not need to be rewritten as a network-aware wrapper. Methods, properties, and type annotations can be defined on an ordinary Python class, and the frame constructs the exposed API and communication boundary around it.
Automatic dispatch
Passing api_spec=None to FastApiServer enables automatic dispatch.
from ese774_frame.api_server import FastApiServer
server = FastApiServer(
device_cls=SimpleCtrl,
router_cls=None,
config=None,
api_spec=None,
device_kwargs={"name": "simple"},
logger=logger,
logger_name="SimpleServer",
lifespan_msg_prefix="SIMPLE",
)
server.run(host="127.0.0.1", port=8000)
When router_cls=None, the standard DeviceRouter provided by the frame is used. When router_cls is specified,
automatic dispatch can be used together with that Router.
Automatic dispatch exposes public methods and static properties of the control class. Names beginning with _ are not
exposed.
Additional APIs can be excluded with dispatch_exclude.
server = FastApiServer(
device_cls=SimpleCtrl,
router_cls=None,
config=None,
api_spec=None,
dispatch_exclude=["release", "internal_reset"],
)
Properties
@property and property() definitions on the control class are handled by a property transport separate from method
dispatch.
class SimpleCtrl:
def __init__(self, name: str = "simple"):
self._name = name
@property
def name(self) -> str:
return self._name
@name.setter
def name(self, value: str) -> None:
self._name = value
A Sync client can access them like normal Python properties.
print(client.name)
client.name = "device1"
A property without a setter is treated as read-only. Dynamic attributes produced at runtime through __getattr__ are
not included in automatic static-property detection.
Return-type reconstruction
In automatic dispatch, the server sends return-type annotations for exposed methods to the client as metadata.
Dataclass instances are transferred as JSON-compatible values and reconstructed on the client using the type information.
from dataclasses import dataclass
from typing import Optional
@dataclass
class MotorStatus:
enabled: bool
speed: float
class MotorCtrl:
def get_status(self) -> Optional[MotorStatus]:
return MotorStatus(
enabled=True,
speed=10.0,
)
The transport itself remains JSON based.
MotorStatus
-> JSON-compatible dict
-> HTTP / JSON
-> dict
-> MotorStatus
Type descriptors recursively support Any, None, ordinary Python types, dataclasses, Union / Optional, list,
tuple, and dict.
If type information cannot be resolved or dataclass reconstruction fails, the client falls back toward preserving the existing JSON value.
Device-specific Routers
A device-specific Router can implement only the APIs that require special HTTP-layer behavior while automatic dispatch remains enabled.
from ese774_frame.routers.device_router import DeviceRouter
class SimpleRouter(DeviceRouter):
async def emergency_stop(self):
...
When the device-specific Router defines a method/property with the same name, the Router implementation takes precedence. Other APIs fall back to automatic dispatch to the control class.
This allows ordinary APIs to be exposed directly from the control class while keeping only exceptional HTTP-specific behavior in the Router.
Pydantic + ApiSpec
When an HTTP API must be defined explicitly, use Pydantic request models and ApiSpec.
from pydantic import BaseModel
from ese774_frame.models.api_spec import ApiSpec
class AddRequest(BaseModel):
a: int
b: int
simple_api_spec = [
ApiSpec(
name="add",
object_name="simple",
request_model=AddRequest,
response_model=None,
method="post",
summary="add",
description="a + b",
),
]
For a property defined through ApiSpec, specify kind="property". Set writable=True when a setter is allowed.
ApiSpec(
name="name",
object_name="simple",
request_model=None,
response_model=str,
kind="property",
writable=True,
)
When api_spec is provided, FastApiServer requires router_cls.
server = FastApiServer(
device_cls=SimpleCtrl,
router_cls=DeviceRouter,
config=None,
api_spec=simple_api_spec,
)
Clients
The frame provides SyncDeviceClient and AsyncDeviceClient.
For automatic dispatch, specify api_spec=None and object_name.
from ese774_frame.clients import SyncDeviceClient
client = SyncDeviceClient(
server_host="127.0.0.1",
server_port=8000,
api_spec=None,
object_name="simple",
)
print(client.ping())
print(client.add(1, 2))
print(client.name)
Method calls on the Async client are awaited.
from ese774_frame.clients import AsyncDeviceClient
client = AsyncDeviceClient(
server_host="127.0.0.1",
server_port=8000,
api_spec=None,
object_name="simple",
)
result = await client.add(1, 2)
Because Python properties themselves have no await syntax, property transport in AsyncDeviceClient internally uses a
synchronous HTTP client.
DeviceProxy
DeviceProxy creates a Sync or Async client from a registered device-class name.
Register the device in the device package, for example in its __init__.py.
from ese774_frame import DeviceProxy
from ese774_frame.clients import register_device_proxy
register_device_proxy(
"SimpleCtrl",
async_client_cls=AsyncSimpleClient,
sync_client_cls=SyncSimpleClient,
api_spec=None,
object_name="simple",
default_async_mode=True,
aliases=["simple"],
)
Client code can use either the registered class name or an alias.
from server import DeviceProxy
client = DeviceProxy(
"SimpleCtrl",
async_mode=False,
)
print(client.ping())
If device-specific client classes are not registered, the frame falls back to its standard SyncDeviceClient /
AsyncDeviceClient.
.pyi generation
Automatic dispatch and DeviceProxy construct APIs dynamically at runtime, so an IDE cannot infer device-specific APIs
without additional type information.
make_pyi_device_client() generates client stubs.
For automatic dispatch, pass device_class.
from ese774_frame.clients.make_pyi_device_client import make_pyi_device_client
make_pyi_device_client(
filename="sync_simple_client.pyi",
device_class=SimpleCtrl,
class_name="SyncSimpleClient",
async_mode=False,
)
make_pyi_device_client(
filename="async_simple_client.pyi",
device_class=SimpleCtrl,
class_name="AsyncSimpleClient",
async_mode=True,
)
The generator collects public methods and properties from device_class using the same exposure rules as automatic
dispatch.
In ApiSpec mode, pass api_spec.
make_pyi_device_client(
filename="sync_simple_client.pyi",
api_spec=simple_api_spec,
class_name="SyncSimpleClient",
async_mode=False,
)
api_spec and device_class are mutually exclusive.
For explicit ApiSpec mode, Router stubs can be generated with make_pyi_device_router().
from ese774_frame.routers.make_pyi_device_router import make_pyi_device_router
make_pyi_device_router(
filename="simple_router.pyi",
api_spec=simple_api_spec,
class_name="SimpleRouter",
)
.pyi for DeviceProxy
DeviceProxy() selects a client class from the registry at runtime, so its device-specific return type cannot be
determined statically by the frame alone.
Generate overloads in the device package's __init__.pyi to provide the IDE with the device-specific client type.
from ese774_frame.clients.make_pyi_device_proxy import make_pyi_device_proxy
make_pyi_device_proxy(
filename=str(root / "__init__.pyi"),
import_lines=[
"from server.clients import SyncSimpleClient",
"from server.clients import AsyncSimpleClient",
],
device_class="SimpleCtrl",
aliases=["simple"],
sync_client_class_name="SyncSimpleClient",
async_client_class_name="AsyncSimpleClient",
all_names=[
"SyncSimpleClient",
"AsyncSimpleClient",
"DeviceProxy",
],
)
At runtime, re-export ese774_frame.DeviceProxy directly rather than creating a device-specific wrapper.
Device-specific typing is supplied only by the .pyi file.
Tutorial
For a step-by-step example covering the server, clients, DeviceProxy, and .pyi generation,
see TUTORIAL.md.
Author
- Kengo NAKADA
Metadata
Release files for ese774-frame 0.6.4
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| ese774_frame-0.6.4.tar.gz | 42.8 kB | With provenance | Details for ese774_frame-0.6.4.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| ese774_frame-0.6.4-py3-none-any.whl | Python 3 | none | any | Details for ese774_frame-0.6.4-py3-none-any.whl |
Total release size: 89.5 kB
Release files / ese774_frame-0.6.4.tar.gz
| Download URL | ese774_frame-0.6.4.tar.gz |
|---|---|
| Size | 42.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
bbc0f951937c2a7e6867e18057c3d0030b1ec797e48f0b9dfd854e1d750ff2ae
|
|
BLAKE2b-256 checksum How to use checksums |
183161a45f41a44f79022950c865f155b67d4b8fbac6175a07e13e96b1a53d77
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 24, 2026.
Transparency logRelease files / ese774_frame-0.6.4-py3-none-any.whl
| Download URL | ese774_frame-0.6.4-py3-none-any.whl |
|---|---|
| Size | 46.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
e2971891eca1a69ef469560fdfff68ab7bf538639568b051641c735ea2a424d4
|
|
BLAKE2b-256 checksum How to use checksums |
9d8f0326ab1708ebe20ecc331a636da299218593a09839716eb5e93bffe5fa77
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 24, 2026.
Transparency logSecurity for ese774-frame 0.6.4
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for ese774_frame-0.6.4.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 24, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.