mloq.command
Contents
mloq.command
#
This module defines the base Command class used for defining mloq commands.
Module Contents#
Classes#
Class containing the interface for defining an MLOQ Command. |
|
Define blueprints for generating custom mloq commands. |
- class mloq.command.CommandMixin(record, interactive=False, *args, **kwargs)[source]#
Class containing the interface for defining an MLOQ Command.
- Parameters
record (mloq.writer.CMDRecord) –
interactive (bool) –
- files :tuple#
- cmd_name = command#
- property record#
Return a CMDRecord that keeps track of the files and directories the command creates.
- Return type
mloq.writer.CMDRecord
- property directories#
Tuple containing Paths objects representing the directories the Command creates.
Override this property if your command creates any directories.
- Returns
Tuple of
Path
objects representing the path to the directories that theCommand
will create.- Return type
Tuple[pathlib.Path]
- parse_config()[source]#
Update the configuration dictionary from the data entered by the user.
Given the basic configuration skeleton (contained in mloq.yaml), this method updates the values of those parameters (included in CONFIG object) that are related to the selected command. Incoming values are introduced either interactively or via a custom user’s mloq.yaml file.
- Returns
It returns an updated version of the ‘config’ attribute of the ‘record’ instance.
- Return type
omegaconf.DictConfig
- abstract interactive_config()[source]#
Pass user’s configuration interactively.
- Return type
omegaconf.DictConfig
- record_directories()[source]#
Register the directories that will be generated by mloq.
- Return type
None
- configure()[source]#
Save the updated version of the ‘config’ attribute.
After parsing the new configuration values introduced by the user, this method registers and saves this updated configuration within the ‘_config’ attribute of the ‘record’ instance.
- Return type
None
- run()[source]#
Record the files and directories generated by mloq according to the user’s configuration.
This method updates the configuration dictionary with the values introduced by the user. Once the parameters have been revised, the files and directories that will be generated by mloq are registered within the ‘record’ instance.
- Returns
- It returns an updated version of the CMDRecord instance, where
the files and directories that will be generated by mloq are recorded within the ‘record’ instance.
- Return type
mloq.writer.CMDRecord
- class mloq.command.Command(record, interactive=False, **kwargs)[source]#
Bases:
CommandMixin
,mloq.config.prompt.Promptable
Define blueprints for generating custom mloq commands.
Base class used for defining new mloq commands. It establishes the fundamental methods for defining and updating the configuration values used to create the necessary files for the user’s project, while registering the latter for later use.
This class is initialized from a CMDRecord instance, object where the user’s configuration, as well as the files and directories that will be generated, are stored.
- class Attributes:
name: Name of the command. files: Tuple containing the templates used for creating the necessary files of your project. CONFIG: NamedTuple containing the keys and values of your configuration RELATIVE to the command.
- Parameters
record (mloq.writer.CMDRecord) –
interactive (bool) –