service-capacity-modeling 0.3.89__py3-none-any.whl → 0.3.90__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -638,8 +638,14 @@ def _target_rf(desires: CapacityDesires, user_copies: Optional[int]) -> int:
638
638
 
639
639
 
640
640
  class NflxCassandraArguments(BaseModel):
641
- copies_per_region: int = Field(
642
- default=3,
641
+ """Configuration arguments for the Netflix Cassandra capacity model.
642
+
643
+ This model centralizes all tunable parameters with their defaults.
644
+ Use `from_extra_model_arguments()` to parse a dict into a validated instance.
645
+ """
646
+
647
+ copies_per_region: Optional[int] = Field(
648
+ default=None,
643
649
  description="How many copies of the data will exist e.g. RF=3. If unsupplied"
644
650
  " this will be deduced from durability and consistency desires",
645
651
  )
@@ -663,9 +669,13 @@ class NflxCassandraArguments(BaseModel):
663
669
  default=192,
664
670
  description="What is the maximum size of a cluster in this region",
665
671
  )
666
- max_local_disk_gib: int = Field(
667
- default=5120,
668
- description="The maximum amount of data we store per machine",
672
+ max_local_data_per_node_gib: int = Field(
673
+ default=1280,
674
+ description="Maximum data per node for local disk instances (GiB)",
675
+ )
676
+ max_attached_data_per_node_gib: int = Field(
677
+ default=2048,
678
+ description="Maximum data per node for attached disk instances (GiB)",
669
679
  )
670
680
  max_write_buffer_percent: float = Field(
671
681
  default=0.25,
@@ -680,6 +690,26 @@ class NflxCassandraArguments(BaseModel):
680
690
  "automatically adjust to 0.2",
681
691
  )
682
692
 
693
+ @classmethod
694
+ def from_extra_model_arguments(
695
+ cls, extra_model_arguments: Dict[str, Any]
696
+ ) -> "NflxCassandraArguments":
697
+ """Parse extra_model_arguments dict into a validated NflxCassandraArguments.
698
+
699
+ This centralizes default values - any field not in extra_model_arguments
700
+ will use the default defined in this model.
701
+
702
+ Handles legacy field name mappings:
703
+ - max_local_disk_gib -> max_local_data_per_node_gib (if not explicitly set)
704
+ """
705
+ # Handle legacy field name: max_local_disk_gib -> max_local_data_per_node_gib
706
+ args = dict(extra_model_arguments)
707
+ if "max_local_data_per_node_gib" not in args and "max_local_disk_gib" in args:
708
+ args["max_local_data_per_node_gib"] = args["max_local_disk_gib"]
709
+
710
+ # Pydantic will use defaults for any missing fields
711
+ return cls.model_validate(args)
712
+
683
713
 
684
714
  class NflxCassandraCapacityModel(CapacityModel):
685
715
  def __init__(self) -> None:
@@ -722,40 +752,22 @@ class NflxCassandraCapacityModel(CapacityModel):
722
752
  desires: CapacityDesires,
723
753
  extra_model_arguments: Dict[str, Any],
724
754
  ) -> Optional[CapacityPlan]:
725
- # TODO: Standardize these extra model argument defaults in a single
726
- # place. Many of them are defined here and as default values in the
727
- # downstream method but only these ones are used which is confusing for
728
- # readability
729
-
730
- # Use durabiliy and consistency to compute RF.
731
- copies_per_region = _target_rf(
732
- desires, extra_model_arguments.get("copies_per_region", None)
733
- )
734
- require_local_disks: bool = extra_model_arguments.get(
735
- "require_local_disks", False
736
- )
737
- require_attached_disks: bool = extra_model_arguments.get(
738
- "require_attached_disks", False
739
- )
755
+ # Parse extra_model_arguments into a validated model with centralized defaults
756
+ args = NflxCassandraArguments.from_extra_model_arguments(extra_model_arguments)
757
+
758
+ # Use durability and consistency to compute RF if not explicitly set
759
+ copies_per_region = _target_rf(desires, args.copies_per_region)
760
+
761
+ # Validate required_cluster_size for critical tiers
740
762
  required_cluster_size: Optional[int] = (
741
763
  NflxCassandraCapacityModel.get_required_cluster_size(
742
764
  desires.service_tier, extra_model_arguments
743
765
  )
744
766
  )
745
767
 
746
- max_rps_to_disk: int = extra_model_arguments.get("max_rps_to_disk", 500)
747
- max_regional_size: int = extra_model_arguments.get("max_regional_size", 192)
748
- max_local_data_per_node_gib: int = extra_model_arguments.get(
749
- "max_local_data_per_node_gib",
750
- extra_model_arguments.get("max_local_disk_gib", 1280),
751
- )
752
-
753
- max_write_buffer_percent: float = min(
754
- 0.5, extra_model_arguments.get("max_write_buffer_percent", 0.25)
755
- )
756
- max_table_buffer_percent: float = min(
757
- 0.5, extra_model_arguments.get("max_table_buffer_percent", 0.11)
758
- )
768
+ # Apply caps to buffer percentages
769
+ max_write_buffer_percent = min(0.5, args.max_write_buffer_percent)
770
+ max_table_buffer_percent = min(0.5, args.max_table_buffer_percent)
759
771
 
760
772
  # Adjust heap defaults for high write clusters
761
773
  if (
@@ -772,12 +784,12 @@ class NflxCassandraCapacityModel(CapacityModel):
772
784
  desires=desires,
773
785
  zones_per_region=context.zones_in_region,
774
786
  copies_per_region=copies_per_region,
775
- require_local_disks=require_local_disks,
776
- require_attached_disks=require_attached_disks,
787
+ require_local_disks=args.require_local_disks,
788
+ require_attached_disks=args.require_attached_disks,
777
789
  required_cluster_size=required_cluster_size,
778
- max_rps_to_disk=max_rps_to_disk,
779
- max_regional_size=max_regional_size,
780
- max_local_data_per_node_gib=max_local_data_per_node_gib,
790
+ max_rps_to_disk=args.max_rps_to_disk,
791
+ max_regional_size=args.max_regional_size,
792
+ max_local_data_per_node_gib=args.max_local_data_per_node_gib,
781
793
  max_write_buffer_percent=max_write_buffer_percent,
782
794
  max_table_buffer_percent=max_table_buffer_percent,
783
795
  )
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: service-capacity-modeling
3
- Version: 0.3.89
3
+ Version: 0.3.90
4
4
  Summary: Contains utilities for modeling capacity for pluggable workloads
5
5
  Author: Joseph Lynch
6
6
  Author-email: josephl@netflix.com
@@ -53,7 +53,7 @@ service_capacity_modeling/models/utils.py,sha256=WosEEg4o1_WSbTb5mL-M1v8JuWJgvS2
53
53
  service_capacity_modeling/models/org/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
54
54
  service_capacity_modeling/models/org/netflix/__init__.py,sha256=2Ld2NPxiO3vbYtOMqHtrV4f1nEH390Hoxqo3I5NbBDI,2553
55
55
  service_capacity_modeling/models/org/netflix/aurora.py,sha256=Js33ZjxCtt34HiDPsWRT9mjKCAsnnCo9du15QArVFMo,13073
56
- service_capacity_modeling/models/org/netflix/cassandra.py,sha256=Fp37bHtWRJctJYYJhW78YbLeFXoX26QxREP_BMEItNE,39003
56
+ service_capacity_modeling/models/org/netflix/cassandra.py,sha256=MUILIhdxlqIxOwMbFJvy7luRYqBxraIkIVU_ZKnjxOo,39627
57
57
  service_capacity_modeling/models/org/netflix/control.py,sha256=wkJnqG7Nn7kQNcKEMzl9LFlA9xTAji2wYxL011VAKPI,5762
58
58
  service_capacity_modeling/models/org/netflix/counter.py,sha256=kTDL7dCnkn-XU27_Z1VBc4CCLCPoOqJZe9WgcENHHd4,10517
59
59
  service_capacity_modeling/models/org/netflix/crdb.py,sha256=iW7tyG8jpXhHIdXrw3DPYSHRAknPN42MlCRLJO4o9C8,20826
@@ -77,9 +77,9 @@ service_capacity_modeling/tools/auto_shape.py,sha256=Jx9H2ay9-H_kUDjtB141owQNxGF
77
77
  service_capacity_modeling/tools/fetch_pricing.py,sha256=Qp-XMymkY1dvtyS51RufmEpfgOHv-IQ-XyzS8wp2-qM,4021
78
78
  service_capacity_modeling/tools/generate_missing.py,sha256=F7YqvMJAV4nZc20GNrlIsnQSF8_77sLgwYZqc5k4LDg,3099
79
79
  service_capacity_modeling/tools/instance_families.py,sha256=e5RuYkCLUITvsAazDH12B6KjX_PaBsv6Ne3mj0HK_sQ,9223
80
- service_capacity_modeling-0.3.89.dist-info/licenses/LICENSE,sha256=nl_Lt5v9VvJ-5lWJDT4ddKAG-VZ-2IaLmbzpgYDz2hU,11343
81
- service_capacity_modeling-0.3.89.dist-info/METADATA,sha256=ATxeW6sDZDkk4HQpmYGdmIlAXVXYj7zQaK5QJwkml8o,10366
82
- service_capacity_modeling-0.3.89.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
83
- service_capacity_modeling-0.3.89.dist-info/entry_points.txt,sha256=ZsjzpG5SomWpT1zCE19n1uSXKH2gTI_yc33sdl0vmJg,146
84
- service_capacity_modeling-0.3.89.dist-info/top_level.txt,sha256=H8XjTCLgR3enHq5t3bIbxt9SeUkUT8HT_SDv2dgIT_A,26
85
- service_capacity_modeling-0.3.89.dist-info/RECORD,,
80
+ service_capacity_modeling-0.3.90.dist-info/licenses/LICENSE,sha256=nl_Lt5v9VvJ-5lWJDT4ddKAG-VZ-2IaLmbzpgYDz2hU,11343
81
+ service_capacity_modeling-0.3.90.dist-info/METADATA,sha256=QAmQcpV4CC-6rKvYKnmzrb4OjpW7sCQdaFAdB5u9TVo,10366
82
+ service_capacity_modeling-0.3.90.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
83
+ service_capacity_modeling-0.3.90.dist-info/entry_points.txt,sha256=ZsjzpG5SomWpT1zCE19n1uSXKH2gTI_yc33sdl0vmJg,146
84
+ service_capacity_modeling-0.3.90.dist-info/top_level.txt,sha256=H8XjTCLgR3enHq5t3bIbxt9SeUkUT8HT_SDv2dgIT_A,26
85
+ service_capacity_modeling-0.3.90.dist-info/RECORD,,