Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

support derived buffer passed in the input desires #121

Merged
merged 2 commits into from
Mar 4, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions service_capacity_modeling/interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -897,9 +897,10 @@ def merge_with(self, defaults: "CapacityDesires") -> "CapacityDesires":
default_buffers["default"] = desired_buffers["default"]
for k, v in desired_buffers.get("desired", {}).items():
default_buffers["desired"][k] = v
for i in desired_buffers.get("derived", []):
if i not in default_buffers["derived"]:
default_buffers["derived"].append(i)

default_buffers.setdefault("derived", {})
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

mind modifying the test_desire_merge.py regression test to verify this?

Copy link
Collaborator Author

@ayushisingh29 ayushisingh29 Mar 4, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Addressed this in a new commit
0df03b6

for k, v in desired_buffers.get("derived", {}).items():
default_buffers["derived"][k] = v

default_dict.update(desires_dict)

Expand Down
11 changes: 10 additions & 1 deletion tests/test_desire_merge.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from service_capacity_modeling.capacity_planner import planner
from service_capacity_modeling.interface import Buffer
from service_capacity_modeling.interface import BufferComponent
from service_capacity_modeling.interface import BufferIntent
from service_capacity_modeling.interface import Buffers
from service_capacity_modeling.interface import CapacityDesires
from service_capacity_modeling.interface import certain_int
Expand All @@ -25,7 +26,12 @@
desired={
"custom": Buffer(ratio=3.8, components=["custom"]),
"custom-cpu": Buffer(ratio=3.0, components=[BufferComponent.cpu]),
}
},
derived={
"compute": Buffer(
intent=BufferIntent.scale, ratio=2, components=["compute"]
)
},
),
)

Expand All @@ -41,6 +47,9 @@ def test_cassandra_merge():
assert merged.query_pattern.estimated_read_per_second.mid == 100000
assert merged.query_pattern.estimated_mean_read_size_bytes.low == 10
assert merged.data_shape.estimated_state_size_gib.mid == 10
assert merged.buffers.derived.get("compute") is not None
assert merged.buffers.derived["compute"].ratio == 2.0
assert merged.buffers.derived["compute"].intent == BufferIntent.scale

# Should come from cassandra model
assert merged.query_pattern.estimated_mean_read_latency_ms.mid == 2.0
Expand Down