diff --git a/service_capacity_modeling/capacity_planner.py b/service_capacity_modeling/capacity_planner.py index 86c5655..54fa4c9 100644 --- a/service_capacity_modeling/capacity_planner.py +++ b/service_capacity_modeling/capacity_planner.py @@ -2,7 +2,7 @@ import functools import logging from hashlib import blake2b -from typing import Any +from typing import Any, cast from typing import Callable from typing import Dict from typing import Generator @@ -382,9 +382,10 @@ def _plan_percentiles( ) ) - mean_plan = [ - functools.reduce(merge_plan, composed) for composed in zip(*mean_plans) - ] + mean_plan = cast( + Sequence[CapacityPlan], + [functools.reduce(merge_plan, composed) for composed in zip(*mean_plans)], + ) percentile_plans = {} for index, percentile in enumerate(sorted_percentiles): percentile_plan = [] @@ -404,10 +405,13 @@ def _plan_percentiles( drives=drives, ) ) - percentile_plans[percentile] = [ - functools.reduce(merge_plan, composed) - for composed in zip(*percentile_plan) - ] + percentile_plans[percentile] = cast( + Sequence[CapacityPlan], + [ + functools.reduce(merge_plan, composed) + for composed in zip(*percentile_plan) + ], + ) return mean_plan, percentile_plans diff --git a/service_capacity_modeling/models/org/netflix/ddb.py b/service_capacity_modeling/models/org/netflix/ddb.py index 3dd77dc..2a18a49 100644 --- a/service_capacity_modeling/models/org/netflix/ddb.py +++ b/service_capacity_modeling/models/org/netflix/ddb.py @@ -473,12 +473,15 @@ def capacity_plan( annual_balance_target = target_max_annual_cost - total_annual_costs if annual_balance_target > 0: max_read_capacity_units += round( - (annual_balance_target / max(1, read_plan.total_annual_read_cost)) + (annual_balance_target / max(1.0, read_plan.total_annual_read_cost)) * read_plan.read_capacity_units, 2, ) max_write_capacity_units += round( - (annual_balance_target / max(1, write_plan.total_annual_write_cost)) + ( + annual_balance_target + / max(1.0, write_plan.total_annual_write_cost) + ) * total_write_capacity_units, 2, ) diff --git a/tests/netflix/test_ddb.py b/tests/netflix/test_ddb.py index d222a24..a3ed25b 100644 --- a/tests/netflix/test_ddb.py +++ b/tests/netflix/test_ddb.py @@ -86,7 +86,7 @@ def test_plan_storage(): - result = planner.plan_certain( + result = planner.plan( model_name="org.netflix.dynamodb", region="us-east-1", num_regions=1, diff --git a/tests/test_hardware.py b/tests/test_hardware.py index 129726d..4da63a5 100644 --- a/tests/test_hardware.py +++ b/tests/test_hardware.py @@ -3,6 +3,6 @@ def test_blob(): s3 = shapes.region("us-east-1").services["blob.standard"] - assert s3.annual_cost_per_gib > 0 + assert s3.annual_cost_gib(1) > 0 assert s3.annual_cost_per_write_io > 0 assert s3.annual_cost_per_read_io > 0