Skip to main content

Expose your functions as HTTP endpoints.

Project description

dploy-kickstart

maintained PyPI version PyPI - Python Version workflow codecov

Expose your Python functions via an HTTP API. dploy-kickstart is designed with a focus of making deployment of machine learning models as easy as possible with as clean of a contract as possible. This means that you will find configurations options that are less relevant outside of this domain.

Installation

pip install dploy_kickstart

When installed it provides a kickstart executable. Have a look at the help functionality: kickstart --help.

Usage

dploy_kickstart is a helper utility that can expose your Python functions as HTTP endpoints. Based on comment annotations it wraps your chosen functions to be served as API endpoints. It is meant to be used via the kickstart CLI, hence, it would generally not be used programmatically.

Let's say you have a script.py with @dploy comment annotations:

# @dploy endpoint echo
def echo_func(payload):
    return payload

Serve this function with:

kickstart serve -e script.py

Let's try to call the endpoint via curl.

$ curl -d '{"foo":"bar"}' -H "Content-Type: application/json" -X POST http://localhost:8080/echo/

{"foo":"bar"}

Annotations

Following annotation options are currently available.

  • # @dploy endpoint {endpoint_path}
    Will expose the annotated function on path {endpoint_path} with trailing slash (and redirect without trailing slash).
  • # @dploy response_mime_type {mimetype}
    Specify response mime type, will wrap function response accordingly. default: application/json
    available: application/json
  • # @dploy request_content_type {content_type}
    Specify allowed request content type.
    default: application/json available: application/json
  • # @dploy request_method {method}
    Specify allowed request method.
    default: post
    available: any method supported by Flask
  • # @dploy json_to_kwargs
    Will map json payload's keys to function kwargs if supplied.

Endpoint utilities

Following paths are generated automatically:

  • GET /healthz: that always returns a 200
  • GET /openapi.yaml: autogenerated OpenAPI Spec (WIP)

Current dependency tree

Aim is to keep this as small as possible to not clutter the user space.

$ poetry show --no-dev --tree

apispec 3.3.0 A pluggable API specification generator. Currently supports the OpenAPI Specification (f.k.a. the Swagger specification).
click 7.1.2 Composable command line interface toolkit
flask 1.1.2 A simple framework for building complex web applications.
├── click >=5.1
├── itsdangerous >=0.24
├── jinja2 >=2.10.1
│   └── markupsafe >=0.23 
└── werkzeug >=0.15
paste 3.4.0 Tools for using a Web Server Gateway Interface stack
└── six >=1.4.0
waitress 1.4.3 Waitress WSGI server

Package naming

Isn't using underscores in package names discouraged? The reasoning behind the dploy_kickstart naming is that this utility is not meant to be used programmatically. Its meant to be used as a sidecar to user code that should be unaware of its existence, therefore, a longer name has a lower chance of clashing with user code. Yes, this is quite subjective.

Contributing

Questions, ideas, suggestions? Feel free to create issue or PR.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

dploy-kickstart-0.1.5.tar.gz (11.0 kB view details)

Uploaded Source

Built Distribution

dploy_kickstart-0.1.5-py3-none-any.whl (11.8 kB view details)

Uploaded Python 3

File details

Details for the file dploy-kickstart-0.1.5.tar.gz.

File metadata

  • Download URL: dploy-kickstart-0.1.5.tar.gz
  • Upload date:
  • Size: 11.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.0.9 CPython/3.7.7 Linux/5.3.0-1022-azure

File hashes

Hashes for dploy-kickstart-0.1.5.tar.gz
Algorithm Hash digest
SHA256 4e2abf7a5520f269b1f237ec2db09a73ee76b36b46a31e44aa87a389f697d5e9
MD5 281fd23af9c73b8a70209e6034adb63a
BLAKE2b-256 75e1c5a05d8a42ea1c2f6fb603aeaa2ab4d821f0e05b03537f1fc025d9fdb36a

See more details on using hashes here.

File details

Details for the file dploy_kickstart-0.1.5-py3-none-any.whl.

File metadata

  • Download URL: dploy_kickstart-0.1.5-py3-none-any.whl
  • Upload date:
  • Size: 11.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.0.9 CPython/3.7.7 Linux/5.3.0-1022-azure

File hashes

Hashes for dploy_kickstart-0.1.5-py3-none-any.whl
Algorithm Hash digest
SHA256 368fc0a4b3a358b8e72a36b87f910044e847eb8734bb25c0605321984b6c0fb1
MD5 e0f385cdf2371082ca9b86ddc17ab813
BLAKE2b-256 246481182aaf4d8012c99f529156b27a3c4094a284335b0410fdcd5aa78d0b65

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page