in src/hpc/autoscale/node/constraints.py [0:0]
def from_dict(d: Dict) -> "SharedConsumableConstraint":
inner = d["shared-consumable-constraint"]
initial_values = inner["initial-value"]
current_values = inner["current-value"]
sources = inner["source"]
requested = inner["requested"]
shared_resources = []
for initial_value, current_value, source in zip(
initial_values, current_values, sources
):
assert isinstance(
initial_value, (int, float)
), "Expected initial-value to be a float or int"
assert isinstance(
current_value, (int, float)
), "Expected current-value to be a float or int"
assert isinstance(
requested, (int, float)
), "Expected requested to be a float or int"
shared_res = SharedConsumableResource(
inner["resource-name"], source, initial_value, current_value
)
shared_resources.append(shared_res)
return SharedConsumableConstraint(shared_resources, requested)