Skip to content

Commit

Permalink
fix lint
Browse files Browse the repository at this point in the history
  • Loading branch information
rummadisetty committed Oct 6, 2023
1 parent 00fe476 commit 0f4e682
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 17 deletions.
20 changes: 12 additions & 8 deletions service_capacity_modeling/capacity_planner.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 = []
Expand All @@ -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

Expand Down
13 changes: 7 additions & 6 deletions service_capacity_modeling/models/org/netflix/ddb.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
4 changes: 2 additions & 2 deletions tests/netflix/test_ddb.py
Original file line number Diff line number Diff line change
Expand Up @@ -420,15 +420,15 @@ def test_target_annual_cost():
"estimated": 4380000,
"auto_scale": {
"min": 1,
"max": 558797076.92,
"max": 558797077,
"target_utilization_percentage": 0.2,
},
},
"write_capacity_units": {
"estimated": 8760000,
"auto_scale": {
"min": 1,
"max": 33400758.97,
"max": 33400759,
"target_utilization_percentage": 0.2,
},
},
Expand Down
2 changes: 1 addition & 1 deletion tests/test_hardware.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 0f4e682

Please sign in to comment.