Skip to main content

AI/ML inference SDK for streaming data

Project description

Packflow logo

PyPI - Version PyPI - Python Version License

Introduction

packflow is a software development kit (SDK) that simplifies the development process and standardizes packaging of AI/ML running on streaming data sources.

Many existing packaging frameworks are catered towards inference APIs and often require custom preprocessing steps. This can be particularly challenging when dealing with data sources that typically generate data one row at a time in key-value pairs (e.g., firewall logs or message streams).

Packflow, however, is optimized to run models on either individual events or batches of events, streamlining development and reducing the need for additional preprocessing. By leveraging Packflow, teams can focus on building and deploying models with custom out-of-the-box workflows and utilities, significantly reducing the time and effort required to onboard new capabilities.

Getting Started

The following instructions quickly walk through how to install Packflow and serve user documentation.

Installing Packflow

Prerequisite Requirements

  • Python (version 3.10+)

Installation from PyPI

  1. Packflow can be installed directly from PyPI:
pip install packflow

from the root of the Packflow repo.

[!NOTE] If contributing to Packflow, it is recommended to install packflow from source in editable mode: pip install -e .

Packflow Documentation

Packflow documentation is available pre-built in the repository and can be viewed immediately, or built from source for development work. Follow the instructions below to get started with serving the documentation.

Viewing Pre-built Documentation

The simplest way to view the Packflow documentation is to serve the pre-built HTML files included in the repository:

  1. Navigate to the pre-built docs folder: cd docs/built/html
  2. Start a local web server: python -m http.server 8000
  3. Access the documentation in a web browser by navigating to http://127.0.0.1:8000/

[!WARNING] If a "Not Found" error page is received when first accessing the documentation, wait a moment for the server to fully start and refresh the page.

Building Documentation from Source

Prerequisite Requirements

The following are required to build documentation from source:

  • Python (version 3.10+)
  • Pip
  • Packflow (the version corresponding to the docs being served)
  • Pandoc[^1] (see Pandoc.org's official installation instructions)
  • make Command[^2]

Steps

  1. Navigate to the docs folder: cd docs
  2. Install Python dependencies for building and hosting the documentation: pip install -r requirements.txt
  3. Run make dev to serve the documentation from a working tree with live updates, or make prod-serve to serve static multi-version documentation (requires .git directory with branch/tag history)
  4. Access the built documentation in a web browser by navigating to http://127.0.0.1:8000/

[!WARNING] If a "Not Found" error page is received when first accessing the documentation, wait a moment for the server to fully start and refresh the page.

Usage

Packflow provides a flexible base class called an InferenceBackend that allows users to build highly scalable platform- and tool-agnostic inference code, enabling simplified sharing across environments.

Additionally, Packflow's CLI can assist with creating projects, gathering environmental information, and creating distributable code packages for sharing reproducible inference code between disconnected environments.

For detailed information and usage patterns on Packflow, please see the About Packflow and User Guide sections of the official documentation site.

Dummy Inference Backend

To create a dummy Inference Backend, update the inference.py file to the following:

from packflow import InferenceBackend


class Backend(InferenceBackend):
    def execute(self, inputs):
        """
        Simply print 'Hello, world!' then return the input data
        """
        print('Hello, world!')
        return inputs

Load and Run the Inference Backend

In a different Python file or from the command line in the same directory, execute the following:

from packflow.loaders import LocalLoader

backend = LocalLoader('inference:Backend').load()

backend({"sample": "data"})
# >> {"sample": "data"}

Contributing

Contributions to Packflow are welcomed and highly encouraged! Please refer to the CONTRIBUTE.md guide for more information and guidelines for contributing to Packflow.

Authors

Packflow is developed and maintained by Booz Allen Hamilton on behalf of the Federal Government of the United States of America and the Department of War's Chief Digital and Artificial Intelligence Office (CDAO).

License

packflow is distributed under the terms of the MIT license. Please refer to the LICENSE.txt for more information of acceptable usage and distribution of Packflow.

[^1]: Pandoc must be installed separately from the pandoc python package in docs/requirements.txt. [^2]: Installation of make varies by operating system. On MacOS, install xcode-select. On Windows, it is recommend to use Windows Subsystem for Linux (WSL). On Debian/Ubuntu, make can be installed via apt package manager:

sudo apt update
sudo apt install make build-essential

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

packflow-0.3.0.tar.gz (21.8 kB view details)

Uploaded Source

Built Distribution

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

packflow-0.3.0-py3-none-any.whl (29.5 kB view details)

Uploaded Python 3

File details

Details for the file packflow-0.3.0.tar.gz.

File metadata

  • Download URL: packflow-0.3.0.tar.gz
  • Upload date:
  • Size: 21.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.3.2 CPython/3.11.14 Darwin/24.6.0

File hashes

Hashes for packflow-0.3.0.tar.gz
Algorithm Hash digest
SHA256 40c5d7822613e74516664a77db72a9d5250e89afc4f6331a2d7080d0791bf081
MD5 0d8b2b82e14661344eb02c977f16932e
BLAKE2b-256 7e276143c57ac5f4ce23f9ca766349f87ddcec9e99f27f16fef18911aaf41c38

See more details on using hashes here.

File details

Details for the file packflow-0.3.0-py3-none-any.whl.

File metadata

  • Download URL: packflow-0.3.0-py3-none-any.whl
  • Upload date:
  • Size: 29.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.3.2 CPython/3.11.14 Darwin/24.6.0

File hashes

Hashes for packflow-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 ad1ae2c80616c0e85d4e2e9d4404f7362842d12c8aa057bf66be1347f774e063
MD5 f136954247f885ece215721963d98534
BLAKE2b-256 c010759c1ef701566ac9634d723eda8a8cd7b71a43c66a1342b6d66f471766ed

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