model2api
Turns your Python functions into microservices REST API in an instant.
Instantly turn your Python functions into production-ready microservices. Deploy and access your services via REST API. model2api builds on open standards - OpenAPI, JSON Schema, and Python type hints - and is powered by FastAPI, and Pydantic. It cuts out all the pain for productizing and sharing your Python code - or anything you can wrap into a single Python function.
This package is based on opyrator and was fork as the package was relying on older version of FastAPI and Starlette.
Highlights
- Turn functions into production-ready services within seconds.
- Auto-generated HTTP API based on FastAPI.
- Save and share as self-contained executable file or Docker image.
- Instantly deploy and scale for production usage.
- Track and monitor API's call with correlation_id
Getting Started
Installation
Requirements: Python 3.7+.
pip install model2api
Usage
-
A simple compatible function could look like this:
from pydantic import BaseModel class Input(BaseModel): message: str class Output(BaseModel): message: str def hello_world(input: Input) -> Output: """Returns the `message` of the input data.""" return Output(message=input.message)
A compatible function is required to have an
inputparameter and return value based on Pydantic models or an UploadFile. The input and output models are specified via type hints. -
Copy this code to a file, e.g.
model.py -
Run the HTTP API server from command-line:
model2api model:hello_worldIn the output, there's a line that shows where your web service is being served, on your local machine.
Metadata
Release files for model2api 0.0.3
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 |
|---|---|---|---|---|
| model2api-0.0.3.tar.gz | 12.3 kB | Without provenance | Details for model2api-0.0.3.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| model2api-0.0.3-py3-none-any.whl | Python 3 | none | any | Details for model2api-0.0.3-py3-none-any.whl |
Total release size: 23.4 kB
Release files / model2api-0.0.3.tar.gz
| Download URL | model2api-0.0.3.tar.gz |
|---|---|
| Size | 12.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
97e53269b7c135476158b06ab75e6bc988efc827fe15d1a4cdf375059b09e03e
|
|
BLAKE2b-256 checksum How to use checksums |
8a6828223e9d5813d419a4474277914abfb3a4fe8e8b60ac8edeb47d24dd8458
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.8.0 pkginfo/1.8.2 readme-renderer/34.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.8 tqdm/4.62.3 importlib-metadata/4.8.2 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.9.7
|
Release files / model2api-0.0.3-py3-none-any.whl
| Download URL | model2api-0.0.3-py3-none-any.whl |
|---|---|
| Size | 11.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
73f475c1f2ae60add3998b7fd7073fa9b44c71722ab73e8c686d6d46651e9db3
|
|
BLAKE2b-256 checksum How to use checksums |
4ee64fa894e5c0b9739ff21cc2158297d54bff1cc0e3c551be031e897f323f31
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.8.0 pkginfo/1.8.2 readme-renderer/34.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.8 tqdm/4.62.3 importlib-metadata/4.8.2 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.9.7
|
Security for model2api 0.0.3
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.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A 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.