AssetBucket#
- class eclypse.graph.assets.bucket.AssetBucket[source]#
Bases:
dict[str,Asset]Class to store a set of nodes/services assets.
Methods
__init__(**assets)Create a new asset bucket.
aggregate(*assets)Aggregate the assets into a single asset.
consume(assets, amounts)Consume the amount of the asset from the asset.
flip()Flip the assets of the bucket.
is_consistent(assets[, violations])Check if the asset belongs to the interval [lower_bound, upper_bound].
satisfies(assets, constraints[, violations])Checks whether the given asset satisfies the provided constraints.
Attributes
Return the lower bound of the asset bucket.
Return the upper bound of the asset bucket.
- __init__(**assets)[source]#
Create a new asset bucket.
- Parameters:
**assets (dict[str, Asset]) – The assets to store in the bucket.
- aggregate(*assets)[source]#
Aggregate the assets into a single asset.
- Parameters:
assets (Iterable[dict[str, Any]]) – The assets to aggregate.
- Returns:
The aggregated asset.
- Return type:
dict[str, Any]
- satisfies(assets, constraints, violations=False)[source]#
Checks whether the given asset satisfies the provided constraints.
Only functional assets that exist in both buckets are considered. If any key fails its individual satisfies check, it is treated as a violation.
- Parameters:
assets (dict[str, Any]) – The dictionary of asset values to evaluate.
constraints (dict[str, Any]) – The constraint values to satisfy.
violations (bool, optional) – If True, return a dictionary containing only the violated keys and their asset/constraint values. If False (default), return a boolean indicating overall satisfaction.
- Returns:
- If violations=False: True if all constraints are satisfied,
False otherwise.
- If violations=True: A dictionary of violations,
empty if all constraints pass.
- Return type:
bool | dict[str, dict[str, Any]]
- consume(assets, amounts)[source]#
Consume the amount of the asset from the asset.
- Parameters:
assets (dict[str, Any]) – The asset to consume from.
amounts (dict[str, Any]) – The amount to consume.
- Returns:
The remaining assets after the consumption.
- Return type:
dict[str, Any]
- is_consistent(assets, violations=False)[source]#
Check if the asset belongs to the interval [lower_bound, upper_bound].
- Parameters:
assets (dict[str, Any]) – The assets to be checked.
violations (bool, optional) – If True, return a dictionary containing only the violated keys and their asset/constraint values. If False (default), return a boolean indicating overall satisfaction.
- Returns:
- If violations=False: True if all constraints are satisfied,
False otherwise.
- If violations=True: A dictionary of violations,
empty if all assets are consistent.
- Return type:
bool | dict[str, Any]
- flip()[source]#
Flip the assets of the bucket.
It moves from node capabilities to service requirements.
- Returns:
The flipped asset bucket.
- Return type:
- property lower_bound: dict[str, Any]#
Return the lower bound of the asset bucket.
i.e., the lower bound of each asset in the bucket.
- Returns:
The lower bound of the asset bucket.
- Return type:
dict[str, Any]
- property upper_bound: dict[str, Any]#
Return the upper bound of the asset bucket.
i.e., the upper bound of each asset in the bucket.
- Returns:
The upper bound of the asset bucket.
- Return type:
dict[str, Any]