mloq.config.prompt#

This file contains the logic defining all the parameters needed to set up a project with mloq.

Module Contents#

Classes#

PromptParam

Defines a configuration parameter.

MultiChoicePrompt

Define a configuration parameter that can take multiple values from a pre-defined set of values.

StringPrompt

Define a configuration parameter that can take a string value.

IntPrompt

Define a configuration parameter that can take an integer value.

FloatPrompt

Define a configuration parameter that can take a floating point value.

BooleanPrompt

Defines a boolean configuration parameter.

Prompt

Manage all the functionality needed to display a cli prompt.

Promptable

Configurable class that allows to define the parameter values interactively using CLI prompts.

Attributes#

Choices

PARAM_TO_PROMPT

mloq.config.prompt.Choices#
class mloq.config.prompt.PromptParam(name, target, **kwargs)[source]#

Defines a configuration parameter.

It allows to parse a configuration value from different sources in the following order:
  1. Environment variable named as MLOQ_PARAM_NAME

  2. Values defined in mloq.yaml

  3. Interactive promp from CLI (Optional)

Parameters
property param#

Get the param.Parameter object corresponding to the current configuration parameter.

Return type

param.Parameter

property value#

Return the value of the configuration parameter.

Return type

Any

property config#

Return the value of the parameter as defined in its config DictConfig.

Return type

Any

__call__(interactive=False, default=None, **kwargs)[source]#

Return the value of the parameter parsing it from the different input sources available.

Parameters
  • interactive (bool) – Prompt the user to input the value from CLI if it’s not defined in config or as en environment variable.

  • default (Optional[Any]) – Default value displayed in the interactive mode.

  • **kwargs – Passed to click.prompt in interactive mode. Overrides the values defined in __init__

Returns

Value of the parameter.

_prompt(value, **kwargs)[source]#

Prompt user for value.

class mloq.config.prompt.MultiChoicePrompt(name, target, choices=None, **kwargs)[source]#

Bases: PromptParam

Define a configuration parameter that can take multiple values from a pre-defined set of values.

It allows to parse a configuration value from different sources in the following order:
  1. Environment variable named as MLOQ_PARAM_NAME

  2. Values defined in mloq.yaml

  3. Interactive promp from CLI (Optional)

Parameters
_prompt(value, **kwargs)[source]#

Transform the parsed string from the CLI into a list of selected values.

Return type

List[str]

static _parse_string(value)[source]#
Return type

List[str]

class mloq.config.prompt.StringPrompt(name, target, **kwargs)[source]#

Bases: PromptParam

Define a configuration parameter that can take a string value.

It allows to parse a configuration value from different sources in the following order:
  1. Environment variable named as MLOQ_PARAM_NAME

  2. Values defined in mloq.yaml

  3. Interactive promp from CLI (Optional)

Parameters
class mloq.config.prompt.IntPrompt(name, target, **kwargs)[source]#

Bases: PromptParam

Define a configuration parameter that can take an integer value.

It allows to parse a configuration value from different sources in the following order:
  1. Environment variable named as MLOQ_PARAM_NAME

  2. Values defined in mloq.yaml

  3. Interactive promp from CLI (Optional)

Parameters
class mloq.config.prompt.FloatPrompt(name, target, **kwargs)[source]#

Bases: PromptParam

Define a configuration parameter that can take a floating point value.

It allows to parse a configuration value from different sources in the following order:
  1. Environment variable named as MLOQ_PARAM_NAME

  2. Values defined in mloq.yaml

  3. Interactive promp from CLI (Optional)

Parameters
class mloq.config.prompt.BooleanPrompt(name, target, **kwargs)[source]#

Bases: PromptParam

Defines a boolean configuration parameter.

It allows to parse a configuration value from different sources in the following order:
  1. Environment variable named as MLOQ_PARAM_NAME

  2. Values defined in mloq.yaml

  3. Interactive promp from CLI (Optional)

Parameters
_prompt(value, **kwargs)[source]#

Prompt user for value.

mloq.config.prompt.PARAM_TO_PROMPT#
class mloq.config.prompt.Prompt(target)[source]#

Manage all the functionality needed to display a cli prompt.

It allows to interactively define the values of the different parameters of a class.

Parameters

target (Promptable) –

__call__(key, inplace=False, **kwargs)[source]#

Display the a prompt to interactively define the parameter values of target.

Parameters
  • key (str) –

  • inplace (bool) –

Return type

Any

_init_prompts()[source]#

Initialize the prompts corresponding to the target Promptable parameters.

Return type

None

prompt(key, inplace=False, **kwargs)[source]#

Display the a prompt to interactively define the parameter values of target.

Parameters
  • key (str) –

  • inplace (bool) –

Return type

Any

prompt_all(inplace=False, **kwargs)[source]#

Prompt all the target’s parameters.

Return a dictionary containing the provided values.

Parameters

inplace (bool) –

Return type

Dict[str, Any]

class mloq.config.prompt.Promptable(**kwargs)[source]#

Bases: mloq.config.configuration.Configurable

Configurable class that allows to define the parameter values interactively using CLI prompts.

It contains a prompt attribute in charge of managing the prompting functionality for the param.Parameters defined.