1.16.28

flytekit.interaction.click_types

Directory

Classes

Class Description
DateTimeType
DirParamType
DurationParamType
EnumParamType
FileParamType
FlyteLiteralConverter
JSONIteratorParamType
JsonParamType
PickleParamType
StructuredDatasetParamType TODO handle column types.
UnionParamType A composite type that allows for multiple types to be specified.

Methods

Method Description
is_pydantic_basemodel() Checks if the python type is a pydantic BaseModel.
key_value_callback() Callback for click to parse key-value pairs.
labels_callback() Callback for click to parse labels.
literal_type_to_click_type() Converts a Flyte LiteralType given a python_type to a click.
modify_literal_uris() Modifies the literal object recursively to replace the URIs with the native paths.
resource_callback() Click callback to parse resource strings like ‘cpu=1,mem=2Gi’ into a Resources object.

Variables

Property Type Description
SIMPLE_TYPE_CONVERTER dict
click_version str

Methods

is_pydantic_basemodel()

def is_pydantic_basemodel(
    python_type: typing.Type,
) -> bool

Checks if the python type is a pydantic BaseModel

Parameter Type Description
python_type typing.Type

key_value_callback()

def key_value_callback(
    _: typing.Any,
    param: str,
    values: typing.List[str],
) -> typing.Optional[typing.Dict[str, str]]

Callback for click to parse key-value pairs.

Parameter Type Description
_ typing.Any
param str
values typing.List[str]

labels_callback()

def labels_callback(
    _: typing.Any,
    param: str,
    values: typing.List[str],
) -> typing.Optional[typing.Dict[str, str]]

Callback for click to parse labels.

Parameter Type Description
_ typing.Any
param str
values typing.List[str]

literal_type_to_click_type()

def literal_type_to_click_type(
    lt: flytekit.models.types.LiteralType,
    python_type: typing.Type,
) -> click.types.ParamType

Converts a Flyte LiteralType given a python_type to a click.ParamType

Parameter Type Description
lt flytekit.models.types.LiteralType
python_type typing.Type

modify_literal_uris()

def modify_literal_uris(
    lit: flytekit.models.literals.Literal,
)

Modifies the literal object recursively to replace the URIs with the native paths.

Parameter Type Description
lit flytekit.models.literals.Literal

resource_callback()

def resource_callback(
    _: typing.Any,
    param: str,
    value: typing.Optional[str],
) -> typing.Optional[flytekit.core.resources.Resources]

Click callback to parse resource strings like ‘cpu=1,mem=2Gi’ into a Resources object

Parameter Type Description
_ typing.Any
param str
value typing.Optional[str]

flytekit.interaction.click_types.DateTimeType

Parameters

def DateTimeType()

Methods

Method Description
convert() Convert the value to the correct type.

convert()

def convert(
    value: typing.Any,
    param: typing.Optional[click.core.Parameter],
    ctx: typing.Optional[click.core.Context],
) -> typing.Any

Convert the value to the correct type. This is not called if the value is None (the missing value).

This must accept string values from the command line, as well as values that are already the correct type. It may also convert other compatible types.

The param and ctx arguments may be None in certain situations, such as when converting prompt input.

If the value cannot be converted, call fail with a descriptive message.

Parameter Type Description
value typing.Any The value to convert.
param typing.Optional[click.core.Parameter] The parameter that is using this type to convert its value. May be None.
ctx typing.Optional[click.core.Context] The current context that arrived at this value. May be None.

flytekit.interaction.click_types.DirParamType

Methods

Method Description
convert() Convert the value to the correct type.

convert()

def convert(
    value: typing.Any,
    param: typing.Optional[click.core.Parameter],
    ctx: typing.Optional[click.core.Context],
) -> typing.Any

Convert the value to the correct type. This is not called if the value is None (the missing value).

This must accept string values from the command line, as well as values that are already the correct type. It may also convert other compatible types.

The param and ctx arguments may be None in certain situations, such as when converting prompt input.

If the value cannot be converted, call fail with a descriptive message.

Parameter Type Description
value typing.Any The value to convert.
param typing.Optional[click.core.Parameter] The parameter that is using this type to convert its value. May be None.
ctx typing.Optional[click.core.Context] The current context that arrived at this value. May be None.

flytekit.interaction.click_types.DurationParamType

Methods

Method Description
convert() Convert the value to the correct type.

convert()

def convert(
    value: typing.Any,
    param: typing.Optional[click.core.Parameter],
    ctx: typing.Optional[click.core.Context],
) -> typing.Any

Convert the value to the correct type. This is not called if the value is None (the missing value).

This must accept string values from the command line, as well as values that are already the correct type. It may also convert other compatible types.

The param and ctx arguments may be None in certain situations, such as when converting prompt input.

If the value cannot be converted, call fail with a descriptive message.

Parameter Type Description
value typing.Any The value to convert.
param typing.Optional[click.core.Parameter] The parameter that is using this type to convert its value. May be None.
ctx typing.Optional[click.core.Context] The current context that arrived at this value. May be None.

flytekit.interaction.click_types.EnumParamType

Parameters

class EnumParamType(
    enum_type: typing.Type[enum.Enum],
)
Parameter Type Description
enum_type typing.Type[enum.Enum]

Methods

Method Description
convert() Convert the value to the correct type.

convert()

def convert(
    value: typing.Any,
    param: typing.Optional[click.core.Parameter],
    ctx: typing.Optional[click.core.Context],
) -> <enum 'Enum'>

Convert the value to the correct type. This is not called if the value is None (the missing value).

This must accept string values from the command line, as well as values that are already the correct type. It may also convert other compatible types.

The param and ctx arguments may be None in certain situations, such as when converting prompt input.

If the value cannot be converted, call fail with a descriptive message.

Parameter Type Description
value typing.Any The value to convert.
param typing.Optional[click.core.Parameter] The parameter that is using this type to convert its value. May be None.
ctx typing.Optional[click.core.Context] The current context that arrived at this value. May be None.

flytekit.interaction.click_types.FileParamType

Methods

Method Description
convert() Convert the value to the correct type.

convert()

def convert(
    value: typing.Any,
    param: typing.Optional[click.core.Parameter],
    ctx: typing.Optional[click.core.Context],
) -> typing.Any

Convert the value to the correct type. This is not called if the value is None (the missing value).

This must accept string values from the command line, as well as values that are already the correct type. It may also convert other compatible types.

The param and ctx arguments may be None in certain situations, such as when converting prompt input.

If the value cannot be converted, call fail with a descriptive message.

Parameter Type Description
value typing.Any The value to convert.
param typing.Optional[click.core.Parameter] The parameter that is using this type to convert its value. May be None.
ctx typing.Optional[click.core.Context] The current context that arrived at this value. May be None.

flytekit.interaction.click_types.FlyteLiteralConverter

Parameters

class FlyteLiteralConverter(
    flyte_ctx: flytekit.core.context_manager.FlyteContext,
    literal_type: flytekit.models.types.LiteralType,
    python_type: typing.Type,
    is_remote: bool,
)
Parameter Type Description
flyte_ctx flytekit.core.context_manager.FlyteContext
literal_type flytekit.models.types.LiteralType
python_type typing.Type
is_remote bool

Properties

Property Type Description
click_type click.types.ParamType

Methods

Method Description
convert() Convert the value to a Flyte Literal or a python native type.
is_bool()

convert()

def convert(
    ctx: click.core.Context,
    param: typing.Optional[click.core.Parameter],
    value: typing.Any,
) -> typing.Union[flytekit.models.literals.Literal, typing.Any]

Convert the value to a Flyte Literal or a python native type. This is used by click to convert the input.

Parameter Type Description
ctx click.core.Context
param typing.Optional[click.core.Parameter]
value typing.Any

is_bool()

def is_bool()

flytekit.interaction.click_types.JSONIteratorParamType

Methods

Method Description
convert() Convert the value to the correct type.

convert()

def convert(
    value: typing.Any,
    param: typing.Optional[click.core.Parameter],
    ctx: typing.Optional[click.core.Context],
) -> typing.Any

Convert the value to the correct type. This is not called if the value is None (the missing value).

This must accept string values from the command line, as well as values that are already the correct type. It may also convert other compatible types.

The param and ctx arguments may be None in certain situations, such as when converting prompt input.

If the value cannot be converted, call fail with a descriptive message.

Parameter Type Description
value typing.Any The value to convert.
param typing.Optional[click.core.Parameter] The parameter that is using this type to convert its value. May be None.
ctx typing.Optional[click.core.Context] The current context that arrived at this value. May be None.

flytekit.interaction.click_types.JsonParamType

Parameters

class JsonParamType(
    python_type: typing.Type,
)
Parameter Type Description
python_type typing.Type

Methods

Method Description
convert() Convert the value to the correct type.

convert()

def convert(
    value: typing.Any,
    param: typing.Optional[click.core.Parameter],
    ctx: typing.Optional[click.core.Context],
) -> typing.Any

Convert the value to the correct type. This is not called if the value is None (the missing value).

This must accept string values from the command line, as well as values that are already the correct type. It may also convert other compatible types.

The param and ctx arguments may be None in certain situations, such as when converting prompt input.

If the value cannot be converted, call fail with a descriptive message.

Parameter Type Description
value typing.Any The value to convert.
param typing.Optional[click.core.Parameter] The parameter that is using this type to convert its value. May be None.
ctx typing.Optional[click.core.Context] The current context that arrived at this value. May be None.

flytekit.interaction.click_types.PickleParamType

Methods

Method Description
convert() Convert the value to the correct type.
get_metavar() Returns the metavar default for this param if it provides one.

convert()

def convert(
    value: typing.Any,
    param: typing.Optional[click.core.Parameter],
    ctx: typing.Optional[click.core.Context],
) -> typing.Any

Convert the value to the correct type. This is not called if the value is None (the missing value).

This must accept string values from the command line, as well as values that are already the correct type. It may also convert other compatible types.

The param and ctx arguments may be None in certain situations, such as when converting prompt input.

If the value cannot be converted, call fail with a descriptive message.

Parameter Type Description
value typing.Any The value to convert.
param typing.Optional[click.core.Parameter] The parameter that is using this type to convert its value. May be None.
ctx typing.Optional[click.core.Context] The current context that arrived at this value. May be None.

get_metavar()

def get_metavar(
    param: click.core.Parameter,
    *args,
) -> typing.Optional[str]

Returns the metavar default for this param if it provides one.

Parameter Type Description
param click.core.Parameter
*args

flytekit.interaction.click_types.StructuredDatasetParamType

TODO handle column types

Methods

Method Description
convert() Convert the value to the correct type.

convert()

def convert(
    value: typing.Any,
    param: typing.Optional[click.core.Parameter],
    ctx: typing.Optional[click.core.Context],
) -> typing.Any

Convert the value to the correct type. This is not called if the value is None (the missing value).

This must accept string values from the command line, as well as values that are already the correct type. It may also convert other compatible types.

The param and ctx arguments may be None in certain situations, such as when converting prompt input.

If the value cannot be converted, call fail with a descriptive message.

Parameter Type Description
value typing.Any The value to convert.
param typing.Optional[click.core.Parameter] The parameter that is using this type to convert its value. May be None.
ctx typing.Optional[click.core.Context] The current context that arrived at this value. May be None.

flytekit.interaction.click_types.UnionParamType

A composite type that allows for multiple types to be specified. This is used for union types.

Parameters

class UnionParamType(
    types: typing.List[click.types.ParamType],
)
Parameter Type Description
types typing.List[click.types.ParamType]

Properties

Property Type Description
name str

Methods

Method Description
convert() Important to implement NoneType / Optional.

convert()

def convert(
    value: typing.Any,
    param: typing.Optional[click.core.Parameter],
    ctx: typing.Optional[click.core.Context],
) -> typing.Any

Important to implement NoneType / Optional. Also could we just determine the click types from the python types

Parameter Type Description
value typing.Any
param typing.Optional[click.core.Parameter]
ctx typing.Optional[click.core.Context]