A lightweight library for node and internal flow-level status tracking using PostgreSQL.
This project has been archived.
The maintainers of this project have marked this project as archived. No new releases are expected.
Project description
node-status-lib
node-status-lib is a lightweight Python library designed to simplify tracking the status of nodes and their internal flows in distributed systems. It is particularly useful for monitoring pipelines, workflows, and microservices by persisting status updates to a PostgreSQL database.
Features
- Track the status of an entire node
- Monitor the status of individual flows or tasks within a node
- Persist all status updates in a PostgreSQL database
- Optional support for AWS Secrets Manager integration
- Easy to integrate into any Python-based pipeline or microservice
Installation
Install from PyPI:
pip install node-status-lib
or
poetry add node-status-lib
Usage
1. Import the Library
from node_status_lib.manager import NodeStatusManager
from node_status_lib.enums import Status
2. Initialize the Node Status Manager
manager = NodeStatusManager(
node_id="102",
node_name="multispectral_node",
flows=["heatmap_gen", "insight_gen", "response"],
db_details={
"DB_NAME": "<your_db_name>",
"DB_USER": "<your_db_user>",
"DB_PASSWORD": "<your_db_password>",
"DB_HOST": "<your_db_host>",
"DB_PORT": "<your_db_port>"
}
)
3. Update Node and Flow Status
# Update the overall node status
manager.update_node_status(
Status.RUNNING,
description="Node is active and initialized all services."
)
# Update status of individual flows
manager.update_flow_status("heatmap_gen", Status.SUCCESS, description="Heatmap generation completed.")
manager.update_flow_status("insight_gen", Status.NOT_RUNNING)
manager.update_flow_status("response", Status.NOT_RUNNING, description="Awaiting input trigger.")
Note: description is optional for both node and flow updates.
Status Enum Options
Status.PENDING
Status.RUNNING
Status.SUCCESS
Status.FAILED
Database Table Schema
Ensure your PostgreSQL database includes the following table schema:
CREATE TABLE node_status (
node_id TEXT PRIMARY KEY,
node_name TEXT NOT NULL,
node_status TEXT NOT NULL CHECK (
node_status IN ('running', 'not_running', 'success', 'failed')
),
node_description TEXT DEFAULT NULL,
flow_status JSONB NOT NULL,
last_updated TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);
flow_statusformat:{ "flow_name": { "status": "...", "description": "..." }, ... }
Requirements
- Python 3.7+
- PostgreSQL
psycopg2-binaryboto3(optional, required only for AWS Secrets Manager integration)
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 node_status_lib-0.1.17.tar.gz.
File metadata
- Download URL: node_status_lib-0.1.17.tar.gz
- Upload date:
- Size: 3.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/2.1.3 CPython/3.10.12 Linux/6.8.0-60-generic
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d4ae22918dba6552797897b1adc1595de0c34b3bfce29aa6a3c5da9c25f0e13f
|
|
| MD5 |
25d5e34f41b4ad9aa46225252171337f
|
|
| BLAKE2b-256 |
c8177dbe7ac0257a45436a8691e0329da1c7f6ca5b55bad8b90eecd68b8dc79a
|
File details
Details for the file node_status_lib-0.1.17-py3-none-any.whl.
File metadata
- Download URL: node_status_lib-0.1.17-py3-none-any.whl
- Upload date:
- Size: 4.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/2.1.3 CPython/3.10.12 Linux/6.8.0-60-generic
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
238489388d920c90df4f5d47aefc3f91de5954314030f0d3d8bc771469665ee2
|
|
| MD5 |
e01368c2dd52fd3a7aafaea29b516348
|
|
| BLAKE2b-256 |
78a1c6b2b517826b6134a2fc7267860617b708b8a6ca0fe1d7037d33d036db68
|