Skip to main content

Python SDK for the DirectivSys Analytics Platform

Project description

directivsys-sdk-python

directivsys-sdk-python is a Python translation of the DirectivSys .NET SDK. It provides a typed async client for DirectivSys analytics ingestion, batch synchronization, payload result polling, directive status updates, and webhook-driven directive execution.

Highlights

Capability Description
Strict typing Pydantic models and explicit type hints throughout the public API
Async-first client Built around httpx.AsyncClient and asyncio
Batch ingestion Supports polymorphic analytic item batches with $type discrimination
Directive execution Includes a base executor, registry, and webhook processing service
Resilience Retry and circuit-breaker behavior for directive execution
FastAPI support Optional webhook router for FastAPI applications

Installation

pip install directivsys-sdk-python

For FastAPI webhook support:

pip install "directivsys-sdk-python[fastapi]"

For development and tests:

pip install "directivsys-sdk-python[dev]"

Quick start

import asyncio

from directivsys_sdk import DirectivSysClient, DirectivSysOptions
from directivsys_sdk.models import InventoryHealthPayload


async def main() -> None:
    options = DirectivSysOptions(api_key="your-api-key")

    async with DirectivSysClient(options) as client:
        response = await client.submit_inventory_health(
            InventoryHealthPayload(
                sku="SKU-123",
                stock_level=18,
                reorder_point=25,
                safety_stock=10,
                forecasted_demand_next30_days=42,
                average_lead_time_days=7,
            )
        )
        print(response.payload_id, response.status)


asyncio.run(main())

Webhook and executor usage

The SDK includes a framework-agnostic record processor and a FastAPI router helper. You register concrete directive executors in your application and allow the service to auto-run directives whose status is auto-execute.

import logging

from directivsys_sdk import BaseDirectiveExecutor, DirectivSysClient, DirectivSysOptions
from directivsys_sdk.executors import DirectiveRegistry
from directivsys_sdk.models import DirectiveExecutionResult, ImpactData
from directivsys_sdk.service import DirectivSysService
from directivsys_sdk.webhooks import create_directivsys_router
from fastapi import FastAPI


class ReorderSupplierExecutor(BaseDirectiveExecutor):
    async def execute_internal(self, parameters: dict[str, object]) -> DirectiveExecutionResult:
        sku = str(parameters.get("sku", ""))
        quantity = int(parameters.get("quantity", 0))
        return DirectiveExecutionResult(
            success=True,
            message=f"Created reorder workflow for {sku}",
            impact_data=ImpactData(
                entity_id=sku,
                property_changed="PurchaseOrderStatus",
                original_value=None,
                new_value="Pending",
                insight_delta=quantity,
            ),
        )


app = FastAPI()
options = DirectivSysOptions(api_key="your-api-key")
client = DirectivSysClient(options)
registry = DirectiveRegistry()
registry.register("reorderSupplier", ReorderSupplierExecutor(client, logging.getLogger("reorder")))
service = DirectivSysService(registry)
app.include_router(create_directivsys_router(service, options))

Package layout

Module Purpose
directivsys_sdk.client Async API client
directivsys_sdk.models Typed payloads, records, items, and responses
directivsys_sdk.executors Base directive executor and registry
directivsys_sdk.service Webhook record processing service
directivsys_sdk.resilience Retry and circuit-breaker behavior
directivsys_sdk.webhooks.fastapi FastAPI router helper

Notes on concurrency

The SDK is intentionally async-first. It is designed to preserve the concurrency-oriented spirit of the .NET SDK without pretending that Python’s event loop is identical to .NET’s task scheduler. Async boundaries are explicit, HTTP calls are non-blocking, and directive execution resilience is centralized rather than hidden across ad hoc helper code.

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

directivsys_sdk_python-0.1.1.tar.gz (14.7 kB view details)

Uploaded Source

Built Distribution

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

directivsys_sdk_python-0.1.1-py3-none-any.whl (14.4 kB view details)

Uploaded Python 3

File details

Details for the file directivsys_sdk_python-0.1.1.tar.gz.

File metadata

  • Download URL: directivsys_sdk_python-0.1.1.tar.gz
  • Upload date:
  • Size: 14.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.15

File hashes

Hashes for directivsys_sdk_python-0.1.1.tar.gz
Algorithm Hash digest
SHA256 12e00442f9d62bb6b9628a5e12131544f3c2c4fc5b29da593fa3b1793b5ad0f2
MD5 69eba9bd4fd7a635abf91d52f2c14b2c
BLAKE2b-256 2ee3b5f44abb5ceb1dc80b332327f758dcb711bb7c7c7898c36f686a8023a1ff

See more details on using hashes here.

File details

Details for the file directivsys_sdk_python-0.1.1-py3-none-any.whl.

File metadata

File hashes

Hashes for directivsys_sdk_python-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 cb953567c04b9957b99ef21de053ad40bbdcaf7b18595ad03b34d16ff72b52b3
MD5 646cbc0f77c736eb5ccb03ec0d4303cc
BLAKE2b-256 daa4029544d638ac88aedbebff4f8580a1932476a6d1f256c5793b2efa91805c

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