@@ -1102,67 +1102,65 @@ def get_literal_type(self, t: Type) -> LiteralType:
11021102 raise TypeTransformerFailedError ("All values must be of the same type" )
11031103
11041104 if base_type == str :
1105- return LiteralType ( simple = SimpleType . STRING )
1105+ return StrTransformer . get_literal_type ( args [ 0 ] )
11061106 elif base_type == int :
1107- return LiteralType ( simple = SimpleType . INTEGER )
1107+ return IntTransformer . get_literal_type ( args [ 0 ] )
11081108 elif base_type == float :
1109- return LiteralType ( simple = SimpleType . FLOAT )
1109+ return FloatTransformer . get_literal_type ( args [ 0 ] )
11101110 elif base_type == bool :
1111- return LiteralType ( simple = SimpleType . BOOLEAN )
1111+ return BoolTransformer . get_literal_type ( args [ 0 ] )
11121112 elif base_type == datetime .datetime :
1113- return LiteralType ( simple = SimpleType . DATETIME )
1113+ return DatetimeTransformer . get_literal_type ( args [ 0 ] )
11141114 elif base_type == datetime .timedelta :
1115- return LiteralType ( simple = SimpleType . DURATION )
1115+ return TimedeltaTransformer . get_literal_type ( args [ 0 ] )
11161116 else :
11171117 raise TypeTransformerFailedError (f"Unsupported Literal base type: { base_type } " )
11181118
11191119 def to_literal (self , ctx : FlyteContext , python_val : T , python_type : Type [T ], expected : LiteralType ) -> Literal :
11201120 if expected .simple == SimpleType .STRING :
1121- return Literal ( scalar = Scalar ( primitive = Primitive ( string_value = python_val )) )
1121+ return StrTransformer . to_literal ( ctx , python_val , python_type , expected )
11221122 elif expected .simple == SimpleType .INTEGER :
1123- return Literal ( scalar = Scalar ( primitive = Primitive ( integer = python_val )) )
1123+ return IntTransformer . to_literal ( ctx , python_val , python_type , expected )
11241124 elif expected .simple == SimpleType .FLOAT :
1125- return Literal ( scalar = Scalar ( primitive = Primitive ( float_value = python_val )) )
1125+ return FloatTransformer . to_literal ( ctx , python_val , python_type , expected )
11261126 elif expected .simple == SimpleType .BOOLEAN :
1127- return Literal ( scalar = Scalar ( primitive = Primitive ( boolean = python_val )) )
1127+ return BoolTransformer . to_literal ( ctx , python_val , python_type , expected )
11281128 elif expected .simple == SimpleType .DATETIME :
1129- return Literal ( scalar = Scalar ( primitive = Primitive ( datetime = python_val )) )
1129+ return DatetimeTransformer . to_literal ( ctx , python_val , python_type , expected )
11301130 elif expected .simple == SimpleType .DURATION :
1131- return Literal ( scalar = Scalar ( primitive = Primitive ( duration = python_val )) )
1131+ return TimedeltaTransformer . to_literal ( ctx , python_val , python_type , expected )
11321132 else :
11331133 raise TypeError (f"Unsupported LiteralType for LiteralTypeTransformer: { expected .simple } " )
11341134
11351135 def to_python_value (self , ctx : FlyteContext , lv : Literal , expected_python_type : Type [T ]) -> T :
1136- if lv .scalar and lv .scalar .binary :
1137- return self .from_binary_idl (lv .scalar .binary , expected_python_type ) # type: ignore
11381136 if lv .scalar .primitive .string_value is not None :
1139- return lv . scalar . primitive . string_value
1137+ return StrTransformer . to_python_value ( ctx , lv , str )
11401138 elif lv .scalar .primitive .integer is not None :
1141- return lv . scalar . primitive . integer
1139+ return IntTransformer . to_python_value ( ctx , lv , int )
11421140 elif lv .scalar .primitive .float_value is not None :
1143- return lv . scalar . primitive . float_value
1141+ return FloatTransformer . to_python_value ( ctx , lv , float )
11441142 elif lv .scalar .primitive .boolean is not None :
1145- return lv . scalar . primitive . boolean
1143+ return BoolTransformer . to_python_value ( ctx , lv , bool )
11461144 elif lv .scalar .primitive .datetime is not None :
1147- return lv . scalar . primitive . datetime
1145+ return DatetimeTransformer . to_python_value ( ctx , lv , datetime . datetime )
11481146 elif lv .scalar .primitive .duration is not None :
1149- return lv . scalar . primitive . duration
1147+ return TimedeltaTransformer . to_python_value ( ctx , lv , datetime . timedelta )
11501148 else :
11511149 raise TypeTransformerFailedError ("Unsupported Literal value" )
11521150
11531151 def guess_python_type (self , literal_type : LiteralType ):
11541152 if literal_type .simple == SimpleType .STRING :
1155- return str
1153+ return StrTransformer . guess_python_type ( literal_type )
11561154 elif literal_type .simple == SimpleType .INTEGER :
1157- return int
1155+ return IntTransformer . guess_python_type ( literal_type )
11581156 elif literal_type .simple == SimpleType .FLOAT :
1159- return float
1157+ return FloatTransformer . guess_python_type ( literal_type )
11601158 elif literal_type .simple == SimpleType .BOOLEAN :
1161- return bool
1159+ return BoolTransformer . guess_python_type ( literal_type )
11621160 elif literal_type .simple == SimpleType .DATETIME :
1163- return datetime . datetime
1161+ return DatetimeTransformer . guess_python_type ( literal_type )
11641162 elif literal_type .simple == SimpleType .DURATION :
1165- return datetime . timedelta
1163+ return TimedeltaTransformer . guess_python_type ( literal_type )
11661164 else :
11671165 raise TypeTransformerFailedError (f"LiteralTypeTransformer cannot reverse { literal_type } " )
11681166
@@ -1337,7 +1335,6 @@ def get_transformer(cls, python_type: Type) -> TypeTransformer[T]:
13371335 """
13381336 Implements a recursive search for the transformer.
13391337 """
1340- logger .warning (f"get_transformer: { python_type } " )
13411338 v = cls ._get_transformer (python_type )
13421339 if v is not None :
13431340 return v
0 commit comments