2222 generate_recommendations ,
2323)
2424from src .config .enum_constants import FilterTypeEnum , MetricsDataFrameNameBase , MetricsDataFrameNameEnum
25- from pydantic import validate_call , AfterValidator , SkipValidation
2625from src .database import DatabaseConnection
2726from src .preprocess .preprocess import preprocess_data
2827
@@ -67,28 +66,6 @@ def load_preprocessed_jobs_dataframe_from_duckdb(
6766# Generic type for metrics enums constrained to our abstract base Enum class
6867MetricsDFNameEnumT = TypeVar ("MetricsDFNameEnumT" , bound = MetricsDataFrameNameBase )
6968
70-
71- def _ensure_concrete_metrics_enum (
72- cls : type [MetricsDFNameEnumT ],
73- ) -> type [MetricsDFNameEnumT ]:
74- """Validate that the provided class is a concrete subclass of MetricsDataFrameNameBase.
75-
76- Used by Pydantic to validate the enum argument to the constructor.
77-
78- Raises:
79- TypeError: If the type is not a subclass of the base, or is the abstract base itself.
80-
81- Returns:
82- type[MetricsDFNameEnumT]: The validated enum class.
83- """
84- # Ensure it's a subclass of our abstract base (defensive; helps type checkers and runtime safety)
85- if not isinstance (cls , type ) or not issubclass (cls , MetricsDataFrameNameBase ):
86- raise TypeError ("metrics_df_name_enum must be a subclass of MetricsDataFrameNameBase" )
87- if cls is MetricsDataFrameNameBase :
88- raise TypeError ("metrics_df_name_enum must be a concrete Enum subclass, not the abstract base" )
89- return cls
90-
91-
9269class EfficiencyAnalysis (Generic [MetricsDFNameEnumT ]):
9370 """
9471 Class to encapsulate the efficiency analysis of jobs based on various metrics.
@@ -98,12 +75,10 @@ class EfficiencyAnalysis(Generic[MetricsDFNameEnumT]):
9875 The metrics are generated in separate DataFrames for each category in MetricsDataFrameNameEnum.
9976 """
10077
101- # Apply Pydantic runtime validation for constructor arguments
102- @validate_call (config = {"arbitrary_types_allowed" : True })
10378 def __init__ (
10479 self ,
105- jobs_df : Annotated [ pd .DataFrame , SkipValidation ()] ,
106- metrics_df_name_enum : Annotated [ type [MetricsDFNameEnumT ], AfterValidator ( _ensure_concrete_metrics_enum )],
80+ jobs_df : pd .DataFrame ,
81+ metrics_df_name_enum : type [MetricsDFNameEnumT ] = MetricsDataFrameNameEnum
10782 ) -> None :
10883 """
10984 Initialize the EfficiencyAnalysis class.
0 commit comments