Exemple #1
0
    def to_flyte_idl(self) -> _idl_parameter_ranges.ParameterRanges:
        """

        :rtype: _idl_parameter_ranges.ParameterRanges
        """
        converted = {}
        for k, v in self._parameter_range_map.items():
            if isinstance(v, IntegerParameterRange):
                converted[k] = _idl_parameter_ranges.ParameterRangeOneOf(
                    integer_parameter_range=v.to_flyte_idl())
            elif isinstance(v, ContinuousParameterRange):
                converted[k] = _idl_parameter_ranges.ParameterRangeOneOf(
                    continuous_parameter_range=v.to_flyte_idl())
            elif isinstance(v, CategoricalParameterRange):
                converted[k] = _idl_parameter_ranges.ParameterRangeOneOf(
                    categorical_parameter_range=v.to_flyte_idl())
            else:
                raise user.FlyteTypeException(
                    received_type=type(v),
                    expected_type=type(Union[IntegerParameterRange,
                                             ContinuousParameterRange,
                                             CategoricalParameterRange]),
                )

        return _idl_parameter_ranges.ParameterRanges(
            parameter_range_map=converted, )
Exemple #2
0
    def to_flyte_idl(self) -> _idl_parameter_ranges.ParameterRanges:
        converted = {}
        for k, v in self._parameter_range_map.items():
            if isinstance(v, IntegerParameterRange):
                converted[k] = _idl_parameter_ranges.ParameterRangeOneOf(
                    integer_parameter_range=v.to_flyte_idl())
            elif isinstance(v, ContinuousParameterRange):
                converted[k] = _idl_parameter_ranges.ParameterRangeOneOf(
                    continuous_parameter_range=v.to_flyte_idl())
            else:
                converted[k] = _idl_parameter_ranges.ParameterRangeOneOf(
                    categorical_parameter_range=v.to_flyte_idl())

        return _idl_parameter_ranges.ParameterRanges(
            parameter_range_map=converted, )
Exemple #3
0
 def to_flyte_idl(self) -> _idl_parameter_ranges.ParameterRangeOneOf:
     return _idl_parameter_ranges.ParameterRangeOneOf(
         integer_parameter_range=self.integer_parameter_range.to_flyte_idl(
         ) if self.integer_parameter_range else None,
         continuous_parameter_range=self.continuous_parameter_range.
         to_flyte_idl() if self.continuous_parameter_range else None,
         categorical_parameter_range=self.categorical_parameter_range.
         to_flyte_idl() if self.categorical_parameter_range else None,
     )
Exemple #4
0
 def to_python_value(
     self, ctx: FlyteContext, lv: Literal, expected_python_type: Type[_params.ParameterRangeOneOf]
 ) -> _params.ParameterRangeOneOf:
     if lv and lv.scalar and lv.scalar.generic is not None:
         d = json.loads(json_format.MessageToJson(lv.scalar.generic))
         o = _pb2_params.ParameterRangeOneOf()
         o = json_format.ParseDict(d, o)
         return _params.ParameterRangeOneOf.from_flyte_idl(o)
     return None