Skip to main content

Scenario management model for the Algomancy library

Project description

algomancy-scenario

Scenario modeling utilities for Algomancy: define algorithms and parameters, run scenarios against data, and compute KPIs.

Features

  • Scenario lifecycle with statuses (CREATED, QUEUED, PROCESSING, COMPLETE, FAILED)
  • BaseAlgorithm and parameter classes to define pluggable algorithms
  • KPI framework (BaseKPI) to compute metrics from algorithm results
  • Works with algomancy-data data sources and can be orchestrated from the GUI

Installation

pip install -e packages/algomancy-scenario

Requires Python >= 3.14.

Quick start

Define a simple algorithm and KPI, then run a Scenario:

from algomancy_scenario import (
    Scenario, ScenarioStatus,
    BaseAlgorithm, BaseParameterSet, BaseKPI,
)
from algomancy_data import DataSource, DataClassification


# Minimal parameters type
class ExampleParams(BaseParameterSet):
    def serialize(self) -> dict:
        return {"hello": "world"}


# Minimal algorithm
class ExampleAlgorithm(BaseAlgorithm):
    def __init__(self):
        super().__init__(name="Example", params=ExampleParams())

    @staticmethod
    def initialize_parameters() -> ExampleParams:  # used by GUI tooling
        return ExampleParams()

    def run(self, data: DataSource) -> dict:
        # do something with data and return a result dictionary
        self.set_progress(100)
        return {"count_tables": len(data.list_tables())}


# Minimal KPI
class CountTablesKPI(BaseKPI):
    def __init__(self):
        super().__init__(name="Tables", improvement_direction=None)

    def compute_and_check(self, result: dict):
        self.value = result["count_tables"]


# Prepare data
ds = DataSource(ds_type=DataClassification.MASTER_DATA, name="warehouse")

# Build and run scenario
scenario = Scenario(
    tag="demo",
    input_data=ds,
    kpis={"tables": CountTablesKPI()},
    algorithm=ExampleAlgorithm(),
)

scenario.process()
assert scenario.status == ScenarioStatus.COMPLETE
print("Tables KPI:", scenario.kpis["tables"].value)

Related docs and examples

  • Example app demonstrates scenario wiring: example/pages/ScenarioPageContent.py
  • Algorithm/KPI examples: example/templates/algorithm/ and example/templates/kpi/

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

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

algomancy_scenario-0.3.13-py3-none-any.whl (16.7 kB view details)

Uploaded Python 3

File details

Details for the file algomancy_scenario-0.3.13-py3-none-any.whl.

File metadata

  • Download URL: algomancy_scenario-0.3.13-py3-none-any.whl
  • Upload date:
  • Size: 16.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.25 {"installer":{"name":"uv","version":"0.9.25","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for algomancy_scenario-0.3.13-py3-none-any.whl
Algorithm Hash digest
SHA256 6d9be042ba3e3e7673b577b7351e2115930cc1b8c5834c5cba583e9de37e7cff
MD5 d19d85af2619aa38ea20b4dd4c2d1706
BLAKE2b-256 74047c0cdf04c56f2b5f61a06da82980fe431e7b40b492a27aeb348981e53071

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