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
Release history Release notifications | RSS feed
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.1.4.tar.gz
(701.1 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
sidas-0.1.4-py3-none-any.whl
(31.5 kB
view details)
File details
Details for the file sidas-0.1.4.tar.gz.
File metadata
- Download URL: sidas-0.1.4.tar.gz
- Upload date:
- Size: 701.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.5.26
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
264de6d2aeaf0f5aaf17ca567ec205d201f761d4db42b1eb9294981fec59b6fd
|
|
| MD5 |
4eed601ccc1fcae89b793c915e293047
|
|
| BLAKE2b-256 |
c722b42c4181bad8e20b23817916d51e7ad97cc62c7a92a64c0c3f6af5913075
|
File details
Details for the file sidas-0.1.4-py3-none-any.whl.
File metadata
- Download URL: sidas-0.1.4-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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
700557547834f9f3d0e7debad4447612759758c81be85d04bbd0018fd0fd1758
|
|
| MD5 |
40aae351b0b014199044356b002687f5
|
|
| BLAKE2b-256 |
5d0ae42cbe7a6c1e37236278218077e77b3b1e9a543bba52f4cac1eacb6903ff
|