From 0f4e68218c3daaaa541bf06fd1692cd01a67b079 Mon Sep 17 00:00:00 2001 From: rummadisetty Date: Fri, 6 Oct 2023 16:01:11 -0700 Subject: [PATCH] fix lint --- service_capacity_modeling/capacity_planner.py | 20 +++++++++++-------- .../models/org/netflix/ddb.py | 13 ++++++------ tests/netflix/test_ddb.py | 4 ++-- tests/test_hardware.py | 2 +- 4 files changed, 22 insertions(+), 17 deletions(-) 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..35b4a26 100644 --- a/service_capacity_modeling/models/org/netflix/ddb.py +++ b/service_capacity_modeling/models/org/netflix/ddb.py @@ -472,15 +472,16 @@ def capacity_plan( requirement_context["target_max_annual_cost"] = target_max_annual_cost 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)) + max_read_capacity_units += math.ceil( + (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)) + max_write_capacity_units += math.ceil( + ( + annual_balance_target + / max(1.0, write_plan.total_annual_write_cost) + ) * total_write_capacity_units, - 2, ) requirement = CapacityRequirement( diff --git a/tests/netflix/test_ddb.py b/tests/netflix/test_ddb.py index d222a24..a2bde78 100644 --- a/tests/netflix/test_ddb.py +++ b/tests/netflix/test_ddb.py @@ -420,7 +420,7 @@ def test_target_annual_cost(): "estimated": 4380000, "auto_scale": { "min": 1, - "max": 558797076.92, + "max": 558797077, "target_utilization_percentage": 0.2, }, }, @@ -428,7 +428,7 @@ def test_target_annual_cost(): "estimated": 8760000, "auto_scale": { "min": 1, - "max": 33400758.97, + "max": 33400759, "target_utilization_percentage": 0.2, }, }, 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