Skip to main content

No project description provided

Project description

sida

import random
import statistics

from sidas.extensions import REGISTER_ASSETS_IN_MEMORY
from sidas.extensions.assets import DownstreamAsset, ScheduledAsset
from sidas.extensions.coordinators import SimpleCoordinator


class Numbers(ScheduledAsset[list[float]]):
    cron_expression = "0 0 * * *"

    def transformation(self) -> list[float]:
        return [random.normalvariate() for i in range(10)]


class Mean(DownstreamAsset[float]):
    def transformation(self, n: Numbers) -> float:
        return statistics.mean(n.data)


class Variance(DownstreamAsset[float]):
    def transformation(self, n: Numbers) -> float:
        return statistics.variance(n.data)


class Report(DownstreamAsset[str]):
    def transformation(self, m: Mean, v: Variance) -> str:
        return f"Todays random numbers: mean {m.data} and var {v.data}"


# define the Persisters
REGISTER_ASSETS_IN_MEMORY(Numbers, Mean, Variance, Report)

# instantiate the assets
n = Numbers()
m = Mean()
v = Variance()
r = Report()

# instantiate a cooridnator
coordinator = SimpleCoordinator()
class Numbers(ScheduledAsset[list[float]]):
    cron_expression = "0 0 * * *"

    def __init__(self, resource: File)
    def transformation(self) -> list[float]:
        return [random.normalvariate() for i in range(10)]


def test_report() -> None:
    m = Mean()
    m.data = 0.0

    v = Variance()
    v.data = 1.1

    r = Report()
    assert r.transformation() == "Todays random numbers: mean 0.0 and var 1.0"

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

sidas-0.2.10.tar.gz (738.2 kB view details)

Uploaded Source

Built Distribution

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

sidas-0.2.10-py3-none-any.whl (34.3 kB view details)

Uploaded Python 3

File details

Details for the file sidas-0.2.10.tar.gz.

File metadata

  • Download URL: sidas-0.2.10.tar.gz
  • Upload date:
  • Size: 738.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.6.14

File hashes

Hashes for sidas-0.2.10.tar.gz
Algorithm Hash digest
SHA256 480a28a38da2ed021f91889ef05057aef85c0d9d414940111434017a0efd32fb
MD5 53d5798db531701f6fdc66bb89b7eda8
BLAKE2b-256 b4a204818e7ee63a2429e31f5163faa92e96351794e1acb422edef8573c21e40

See more details on using hashes here.

File details

Details for the file sidas-0.2.10-py3-none-any.whl.

File metadata

  • Download URL: sidas-0.2.10-py3-none-any.whl
  • Upload date:
  • Size: 34.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.6.14

File hashes

Hashes for sidas-0.2.10-py3-none-any.whl
Algorithm Hash digest
SHA256 f9948f2220ac85cb559f2f196ec60c3012ef097ab15e9e7ac69089b0760f3c65
MD5 a8ffd65e78c0005913b93d255a33fdd5
BLAKE2b-256 edd57f3c510dacb97aff7dc775911cce6c757705652b421ec8bd4c537a94aa0b

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