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 Distributions

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

Built Distributions

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

sidas-0.1.3-py3-none-any.whl (31.5 kB view details)

Uploaded Python 3

sidas-0.1.3-1-py3-none-any.whl (31.5 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for sidas-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 803312acea970ee6089fd572acd0861a574854a4a7f22d7a346106bbdaab1741
MD5 13d47e5bb93dda4a387e18dcd662cb2e
BLAKE2b-256 cfba044d5fc990b255fc6efcf93c0e7a690088f814b2a36ee4eeef5e5e536f5d

See more details on using hashes here.

File details

Details for the file sidas-0.1.3-1-py3-none-any.whl.

File metadata

  • Download URL: sidas-0.1.3-1-py3-none-any.whl
  • Upload date:
  • Size: 31.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.5.26

File hashes

Hashes for sidas-0.1.3-1-py3-none-any.whl
Algorithm Hash digest
SHA256 45e46f74c9e320360beb9eb43c0372ee242c2e1e0890cb909f96fd143a3fbc74
MD5 4ccf70111e25f83faf81991cb1701a58
BLAKE2b-256 84d7237cf0cfb8b3076874cad876327fe35b7acd962bfbaa8fff52488347a4d3

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