Skip to main content

Async service toolchain

Project description

PyFlowApi

PyFlowApi is a framework for creating REST API services, powered by PyFreeFlow and FastAPI. It allows you to configure and expose endpoints through a simple YAML configuration file, without writing additional code.

Definition

The YAML configuration requires two main keys:

  • pyfreeflow: defines which non-preloaded pyfreeflow extensions should be loaded.
  • api: defines the list of API endpoints to be exposed.

API configuration

Each API entry under the api key supports the following parameters:

  • min_size: minimum request size.
  • max_size: maximum request size.
  • methods: list of allowed HTTP methods (GET, POST).
  • route: endpoint route.
  • version (optional): API version, defaults to 0.0.
  • pipeline: the pyfreeflow pipeline definition to be executed when the endpoint is called. (See pyfreeflow documentation.)

Endpoint composition

Each endpoint is automatically exposed following the rule:

v<X>/<Y>/<route>

Where:

  • X = major version number
  • Y = minor version number
  • route = the configured route string

Example:

v1/0/sleep

Example configuration

pyfreeflow:
  ext:
  - pyfreeflow.ext.sleep_operator
api:
- max_size: 128
  methods:
  - GET
  - POST
  min_size: 4
  pipeline:
    digraph:
    - I -> A0
    - A0 -> A1
    - A1 -> A2
    - A2 -> O
    name: sleep
    node:
    - config:
        transformer: |2
          data.I = true
          state.I = true
      name: I
      type: DataTransformer
      version: '1.0'
    - config:
        transformer: |2
          data.A = true
          state.A = 0
      name: A0
      type: DataTransformer
      version: '1.0'
    - config:
        sleep_min: 0
        sleep_max: 2
      name: A1
      type: RandomSleepOperator
      version: '1.0'
    - config:
        transformer: |2
          data.A = true
          state.A = state.A + 1
      name: A2
      type: DataTransformer
      version: '1.0'
    - config:
        transformer: |2
          local result
          for k, v in pairs(state) do
            result[k] = v
          end
          data = {body = result}
      name: O
      type: DataTransformer
      version: '1.0'
  version: '1.0'
  route: /sleep

This configuration exposes a single endpoint:

  • Route: v1/0/sleep
  • Method: GET/POST
  • Pipeline: sleep, defined using pyfreeflow operators

Quickstart

Run the API server by providing a configuration file:

pyflowapi-server.py -c config.yaml

Reference

PyFreeFlow -> core library for pipeline definition and execution. FastAPI -> web framework powering the API layer.

License

This software is available under dual licensing:

Non-Commercial Use - AGPL v3

For non-commercial use, this software is released under the GNU Affero General Public License v3.0. Any modifications must be shared under the same license.

Commercial Use

For commercial use, please contact me.

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

pyflowapi-0.1.0.tar.gz (18.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pyflowapi-0.1.0-py3-none-any.whl (17.7 kB view details)

Uploaded Python 3

File details

Details for the file pyflowapi-0.1.0.tar.gz.

File metadata

  • Download URL: pyflowapi-0.1.0.tar.gz
  • Upload date:
  • Size: 18.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for pyflowapi-0.1.0.tar.gz
Algorithm Hash digest
SHA256 6ee59b778a3f63accdd94627a16ce39e54370320c675c2dd8053ef6e8306def2
MD5 cbfc3357de5ff49b4a32651720eba59b
BLAKE2b-256 57096d7e77ac100136e1d1628ce222403e02e4a9ff0e62eb50ba51cb9769da84

See more details on using hashes here.

File details

Details for the file pyflowapi-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: pyflowapi-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 17.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for pyflowapi-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 a6d99403f716311c49c2de1dd6f3412c1237a7a0189bf9f09f68762d0b576add
MD5 d50e157cac086237cbffbb79b29c1997
BLAKE2b-256 c55fc4841773108d96a19c98458e3544839e32e2cfe905f2e6229c3084ebba8d

See more details on using hashes here.

Supported by

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