node-status-lib


Namenode-status-lib JSON
Version 0.1.17 PyPI version JSON
download
home_pageNone
SummaryA lightweight library for node and internal flow-level status tracking using PostgreSQL.
upload_time2025-07-09 06:49:23
maintainerNone
docs_urlNone
authorAngelo Antu
requires_python>=3.10
licenseMIT
keywords node status
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # `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](https://pypi.org):

```bash
pip install node-status-lib

or 

poetry add node-status-lib
```

---

## Usage

### 1. Import the Library

```python
from node_status_lib.manager import NodeStatusManager
from node_status_lib.enums import Status
```

### 2. Initialize the Node Status Manager

```python
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

```python
# 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

```python
Status.PENDING
Status.RUNNING
Status.SUCCESS
Status.FAILED
```

---

## Database Table Schema

Ensure your PostgreSQL database includes the following table schema:

```sql
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_status` format:
  `{ "flow_name": { "status": "...", "description": "..." }, ... }`

---

## Requirements

* Python 3.7+
* PostgreSQL
* `psycopg2-binary`
* `boto3` (optional, required only for AWS Secrets Manager integration)


            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "node-status-lib",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.10",
    "maintainer_email": null,
    "keywords": "node, status",
    "author": "Angelo Antu",
    "author_email": "angelo.antu@kireap.com",
    "download_url": "https://files.pythonhosted.org/packages/c8/17/7dbe7ac0257a45436a8691e0329da1c7f6ca5b55bad8b90eecd68b8dc79a/node_status_lib-0.1.17.tar.gz",
    "platform": null,
    "description": "# `node-status-lib`\n\n`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.\n\n---\n\n## Features\n\n* Track the status of an entire node\n* Monitor the status of individual flows or tasks within a node\n* Persist all status updates in a PostgreSQL database\n* Optional support for AWS Secrets Manager integration\n* Easy to integrate into any Python-based pipeline or microservice\n\n---\n\n## Installation\n\nInstall from [PyPI](https://pypi.org):\n\n```bash\npip install node-status-lib\n\nor \n\npoetry add node-status-lib\n```\n\n---\n\n## Usage\n\n### 1. Import the Library\n\n```python\nfrom node_status_lib.manager import NodeStatusManager\nfrom node_status_lib.enums import Status\n```\n\n### 2. Initialize the Node Status Manager\n\n```python\nmanager = NodeStatusManager(\n    node_id=\"102\",\n    node_name=\"multispectral_node\",\n    flows=[\"heatmap_gen\", \"insight_gen\", \"response\"],\n    db_details={\n        \"DB_NAME\": \"<your_db_name>\",\n        \"DB_USER\": \"<your_db_user>\",\n        \"DB_PASSWORD\": \"<your_db_password>\",\n        \"DB_HOST\": \"<your_db_host>\",\n        \"DB_PORT\": \"<your_db_port>\"\n    }\n)\n```\n\n### 3. Update Node and Flow Status\n\n```python\n# Update the overall node status\nmanager.update_node_status(\n    Status.RUNNING,\n    description=\"Node is active and initialized all services.\"\n)\n\n# Update status of individual flows\nmanager.update_flow_status(\"heatmap_gen\", Status.SUCCESS, description=\"Heatmap generation completed.\")\nmanager.update_flow_status(\"insight_gen\", Status.NOT_RUNNING)\nmanager.update_flow_status(\"response\", Status.NOT_RUNNING, description=\"Awaiting input trigger.\")\n```\n\n*Note: `description` is optional for both node and flow updates.*\n\n---\n\n## Status Enum Options\n\n```python\nStatus.PENDING\nStatus.RUNNING\nStatus.SUCCESS\nStatus.FAILED\n```\n\n---\n\n## Database Table Schema\n\nEnsure your PostgreSQL database includes the following table schema:\n\n```sql\nCREATE TABLE node_status (\n    node_id TEXT PRIMARY KEY,\n    node_name TEXT NOT NULL,\n    node_status TEXT NOT NULL CHECK (\n        node_status IN ('running', 'not_running', 'success', 'failed')\n    ),\n    node_description TEXT DEFAULT NULL,\n    flow_status JSONB NOT NULL,\n    last_updated TIMESTAMP DEFAULT CURRENT_TIMESTAMP\n);\n```\n\n* `flow_status` format:\n  `{ \"flow_name\": { \"status\": \"...\", \"description\": \"...\" }, ... }`\n\n---\n\n## Requirements\n\n* Python 3.7+\n* PostgreSQL\n* `psycopg2-binary`\n* `boto3` (optional, required only for AWS Secrets Manager integration)\n\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "A lightweight library for node and internal flow-level status tracking using PostgreSQL.",
    "version": "0.1.17",
    "project_urls": null,
    "split_keywords": [
        "node",
        " status"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "78a1c6b2b517826b6134a2fc7267860617b708b8a6ca0fe1d7037d33d036db68",
                "md5": "e01368c2dd52fd3a7aafaea29b516348",
                "sha256": "238489388d920c90df4f5d47aefc3f91de5954314030f0d3d8bc771469665ee2"
            },
            "downloads": -1,
            "filename": "node_status_lib-0.1.17-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "e01368c2dd52fd3a7aafaea29b516348",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.10",
            "size": 4209,
            "upload_time": "2025-07-09T06:49:22",
            "upload_time_iso_8601": "2025-07-09T06:49:22.293230Z",
            "url": "https://files.pythonhosted.org/packages/78/a1/c6b2b517826b6134a2fc7267860617b708b8a6ca0fe1d7037d33d036db68/node_status_lib-0.1.17-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "c8177dbe7ac0257a45436a8691e0329da1c7f6ca5b55bad8b90eecd68b8dc79a",
                "md5": "25d5e34f41b4ad9aa46225252171337f",
                "sha256": "d4ae22918dba6552797897b1adc1595de0c34b3bfce29aa6a3c5da9c25f0e13f"
            },
            "downloads": -1,
            "filename": "node_status_lib-0.1.17.tar.gz",
            "has_sig": false,
            "md5_digest": "25d5e34f41b4ad9aa46225252171337f",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.10",
            "size": 3611,
            "upload_time": "2025-07-09T06:49:23",
            "upload_time_iso_8601": "2025-07-09T06:49:23.485570Z",
            "url": "https://files.pythonhosted.org/packages/c8/17/7dbe7ac0257a45436a8691e0329da1c7f6ca5b55bad8b90eecd68b8dc79a/node_status_lib-0.1.17.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2025-07-09 06:49:23",
    "github": false,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "lcname": "node-status-lib"
}
        
Elapsed time: 0.71031s