A framework for building MLOps pipelines
Project description
Anacostia
Welcome to Anacostia. Anacostia is a framework for creating machine learning operations (MLOps) pipelines. I believe the process of creating MLOps pipelines today are too difficult; thus, this is my attempt at simplifying the entire process.
Notes for contributors and developers
If you are interested in contributing to Anacostia, please see CONTRIBUTORS.md. If you are interested in building your own plugins for Anacostia and contributing to the Anacostia ecosystem, please see DEVELOPERS.md.
Basic Anacostia Concepts & Terminology:
Anacostia works by allowing you to define a pipeline as a directed acyclic graph (DAG). Each node in the DAG is nothing more than a continuously running thread that does the following:
- Waits for enough data to become available in a resource or waits for signals received from other nodes.
- Executes a job.
- Sends a signal to another node upon completion of its job.
The edges of the DAG dictates which child nodes are listening for signals from which parent nodes.
There are fundamentally three types of nodes in Anacostia:
- Metadata store nodes: stores tracking information about each time the pipeline executes (i.e., a run).
- The metadata store is responsible for storing information like the start/end time of the run, metadata information about all the nodes in the pipeline, etc.
- Resource nodes: think of a "resource" as the inputs and outputs of your pipeline.
- A resource can be a folder on a local filesystem, an S3 bucket, an API endpoint, a database, etc.
- An "input resource" is a resource that is monitored for changes. When there is enough data in the input resource, it triggers the pipeline to start executing.
- An "output resource" is a resource that is not monitored for changes. This is a resource that stores artifacts produced by the pipeline.
- The data in each resource resides only in that resource, it is never moved to another resource.
- Other nodes can interact with the data in that resource via calls to its API.
- Action nodes: executes a job in your pipeline. Examples of jobs include tasks like: data preprocessing, retraining a model on new data, evaluating a model on new data, etc.
Every node in Anacostia is inherited from these three basic nodes.
A couple things that distinguish Anacostia from other MLOps solutions:
- Anacostia is meant to be ran locally. Of course you can run an Anacostia Pipeline in the cloud, but it is designed to be ran locally.
- Pipelines in Anacostia can be built incrementally. Start with building the simplest pipeline possible; just one metadata store node, one input resource node, and one action node; e.g., an alerting system that monitors a resource and then sends an email notification whenever there is a certain amount of data available. From there, add in an output resource node to build something like a data preprocessing pipeline and then add in more nodes for retraining and evaluation to create a model retraining pipeline.
- Because every node in the Anacostia ecosystem derives from one of the three base nodes, Anacostia provides a format for a common API; thus, allowing for users to swap one node out for another node. This is great for experimentation and evaluating different solutions for your pipeline (e.g., swap out a sqlite metadata store for a redis metadata store).
Installation
Requirements: Python 3.11 or greater, if you need to update Python, see CONTRIBUTORS.md
pip install anacostia-pipeline
Example Usage
from anacostia_pipeline.nodes.node import BaseNode
from anacostia_pipeline.nodes.metadata.node import BaseMetadataStoreNode
from anacostia_pipeline.nodes.actions.node import BaseActionNode
from anacostia_pipeline.nodes.resources.filesystem.node import FilesystemStoreNode
from anacostia_pipeline.nodes.metadata.sqlite.node import SqliteMetadataStoreNode
from anacostia_pipeline.pipelines.root.pipeline import RootPipeline
class MonitoringDataStoreNode(FilesystemStoreNode):
def __init__(
self, name: str, resource_path: str, metadata_store: BaseMetadataStoreNode,
init_state: str = "new", max_old_samples: int = None
) -> None:
super().__init__(name, resource_path, metadata_store, init_state, max_old_samples)
def custom_trigger(self):
if self.get_num_artifacts("new") >= 1:
self.trigger()
class EmailNode(BaseActionNode):
def __init__(
self, name: str, predecessors: List[BaseNode],
metadata_store: BaseMetadataStoreNode,
sender_email: str, recipient_email: str,
loggers: Logger | List[Logger] = None
) -> None:
self.metadata_store = metadata_store
self.sender_email = sender_email
self.recipient_email = recipient_email
super().__init__(name, predecessors, loggers)
def execute(self, *args, **kwargs) -> bool:
# send email to boss
return True
if __name__ == "__main__":
haiku_data_store = MonitoringDataStoreNode("haiku_data_store", haiku_data_store_path, metadata_store)
email_boss_node = EmailNode("email_boss_node", predecessors=[retraining], metadata_store=metadata_store)
metadata_store = SqliteMetadataStore(
name="metadata_store",
uri=f"sqlite:///{metadata_store_path}/metadata.db"
)
pipeline = RootPipeline(
nodes=[metadata_store, haiku_data_store, email_boss_node],
loggers=logger
)
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file anacostia_pipeline-0.3.0.tar.gz.
File metadata
- Download URL: anacostia_pipeline-0.3.0.tar.gz
- Upload date:
- Size: 434.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6c84947f0bcbb7c8c71bbc33ef6508d8ff7078e96ce54e35d78ad82dd72fc2d6
|
|
| MD5 |
15be7c55f2c5e25488965667c6e2f852
|
|
| BLAKE2b-256 |
11656fca65a822cf7b4a28e923507bd2f716362dac2aa4e093bccd8ace558760
|
File details
Details for the file anacostia_pipeline-0.3.0-py3-none-any.whl.
File metadata
- Download URL: anacostia_pipeline-0.3.0-py3-none-any.whl
- Upload date:
- Size: 447.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
11cd4c651afcd7b346c2244a4629bf32342cd8b3b45c3ab95328ed53a36c39f9
|
|
| MD5 |
f3829a0e522322e40506da3ca729cd75
|
|
| BLAKE2b-256 |
575e95fac7d5f122ec52ec46d7feb83f7f5ca5a240b073fbbeaabebe745da2b9
|