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.2.8.tar.gz
(718.8 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.2.8-py3-none-any.whl
(32.7 kB
view details)
File details
Details for the file sidas-0.2.8.tar.gz.
File metadata
- Download URL: sidas-0.2.8.tar.gz
- Upload date:
- Size: 718.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.6.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5901aec9eb366fab3a9cc6b6de1535413cc4450353045414ebfaf8856e8183c5
|
|
| MD5 |
27009447ac592cb6f9fa72a24a660f2f
|
|
| BLAKE2b-256 |
39612117e9681abf61d63d2807262e8522122a80e9f8d4531e9d6fecdfef808a
|
File details
Details for the file sidas-0.2.8-py3-none-any.whl.
File metadata
- Download URL: sidas-0.2.8-py3-none-any.whl
- Upload date:
- Size: 32.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.6.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8f1a516a03cc831b9d3b6732eca620c314de0f77c73a63528ea84c9055a5d9c0
|
|
| MD5 |
d0771ff56a0381209e191c95d278f23d
|
|
| BLAKE2b-256 |
30afabdf7513f97173c972a9913b35219e10fec1d7bde9daeaa1377582b929a8
|