module documentation

kedro is a CLI for managing Kedro projects.

This module implements commands available from the kedro CLI for creating projects.

Class KedroStarterSpec Specification of custom kedro starter template
Function create_cli Undocumented
Function list_starters List all official project starters available.
Function new Create a new kedro project.
Function starter Commands for working with project starters.
Constant CHECKOUT_ARG_HELP Undocumented
Constant CONFIG_ARG_HELP Undocumented
Constant DIRECTORY_ARG_HELP Undocumented
Constant KEDRO_PATH Undocumented
Constant STARTER_ARG_HELP Undocumented
Constant TEMPLATE_PATH Undocumented
Class _Prompt Represent a single CLI prompt for kedro new
Function _create_project Creates a new kedro project using cookiecutter.
Function _fetch_config_from_file Obtains configuration for a new kedro project non-interactively from a file.
Function _fetch_config_from_user_prompts Interactively obtains information from user prompts.
Function _get_available_tags Undocumented
Function _get_cookiecutter_dir Gives a path to the cookiecutter directory. If template_path is a repo then clones it to tmpdir; if template_path is a file path then directly uses that path without copying anything.
Function _get_prompts_required Finds the information a user must supply according to prompts.yml.
Function _get_starters_dict This function lists all the starter aliases declared in the core repo and in plugins entry points.
Function _make_cookiecutter_args Creates a dictionary of arguments to pass to cookiecutter.
Function _make_cookiecutter_context_for_prompts Undocumented
Function _remove_readonly Remove readonly files on Windows See: https://docs.python.org/3/library/shutil.html?highlight=shutil#rmtree-example
Function _starter_spec_to_dict Convert a dictionary of starters spec to a nicely formatted dictionary
Function _validate_config_file Checks that the configuration file contains all needed variables.
Constant _OFFICIAL_STARTER_SPECS Undocumented
Constant _STARTERS_REPO Undocumented
@click.group(context_settings=CONTEXT_SETTINGS, name='Kedro')
def create_cli(): (source)

Undocumented

@starter.command('list')
def list_starters(): (source)

List all official project starters available.

@command_with_verbosity(create_cli, short_help='Create a new kedro project.')
@click.option('--config', '-c', 'config_path', type=click.Path(exists=True), help=CONFIG_ARG_HELP)
@click.option('--starter', '-s', 'starter_alias', help=STARTER_ARG_HELP)
@click.option('--checkout', help=CHECKOUT_ARG_HELP)
@click.option('--directory', help=DIRECTORY_ARG_HELP)
def new(config_path, starter_alias, checkout, directory, **kwargs): (source)

Create a new kedro project.

@create_cli.group()
def starter(): (source)

Commands for working with project starters.

CHECKOUT_ARG_HELP: str = (source)

Undocumented

Value
'An optional tag, branch or commit to checkout in the starter repository.'
CONFIG_ARG_HELP: str = (source)

Undocumented

Value
'''Non-interactive mode, using a configuration yaml file. This file
must supply  the keys required by the template\'s prompts.yml. When not using a 
starter,
these are `project_name`, `repo_name` and `python_package`.'''
DIRECTORY_ARG_HELP: str = (source)

Undocumented

Value
'An optional directory inside the repository where the starter resides.'
KEDRO_PATH = (source)

Undocumented

Value
Path(kedro.__file__).parent
STARTER_ARG_HELP: str = (source)

Undocumented

Value
'''Specify the starter template to use when creating the project.
This can be the path to a local directory, a URL to a remote VCS repository supp
orted
by `cookiecutter` or one of the aliases listed in ``kedro starter list``.
'''
TEMPLATE_PATH = (source)

Undocumented

Value
(KEDRO_PATH/'templates')/'project'
def _create_project(template_path: str, cookiecutter_args: Dict[str, Any]): (source)

Creates a new kedro project using cookiecutter.

Parameters
template_path:strThe path to the cookiecutter template to create the project. It could either be a local directory or a remote VCS repository supported by cookiecutter. For more details, please see: https://cookiecutter.readthedocs.io/en/latest/usage.html#generate-your-project
cookiecutter_args:Dict[str, Any]Arguments to pass to cookiecutter.
Raises
KedroCliErrorIf it fails to generate a project.
def _fetch_config_from_file(config_path: str) -> Dict[str, str]: (source)

Obtains configuration for a new kedro project non-interactively from a file.

Parameters
config_path:strThe path of the config.yml which should contain the data required by prompts.yml.
Returns
Dict[str, str]
Configuration for starting a new project. This is passed as extra_context
to cookiecutter and will overwrite the cookiecutter.json defaults.
Raises
KedroCliErrorIf the file cannot be parsed.
def _fetch_config_from_user_prompts(prompts: Dict[str, Any], cookiecutter_context: OrderedDict) -> Dict[str, str]: (source)

Interactively obtains information from user prompts.

Parameters
prompts:Dict[str, Any]Prompts from prompts.yml.
cookiecutter_context:OrderedDictCookiecutter context generated from cookiecutter.json.
Returns
Dict[str, str]
Configuration for starting a new project. This is passed as extra_context
to cookiecutter and will overwrite the cookiecutter.json defaults.
def _get_available_tags(template_path: str) -> List: (source)

Undocumented

def _get_cookiecutter_dir(template_path: str, checkout: str, directory: str, tmpdir: str) -> Path: (source)

Gives a path to the cookiecutter directory. If template_path is a repo then clones it to tmpdir; if template_path is a file path then directly uses that path without copying anything.

def _get_prompts_required(cookiecutter_dir: Path) -> Optional[Dict[str, Any]]: (source)

Finds the information a user must supply according to prompts.yml.

def _get_starters_dict() -> Dict[str, KedroStarterSpec]: (source)

This function lists all the starter aliases declared in the core repo and in plugins entry points.

For example, the output for official kedro starters looks like: {"astro-airflow-iris":

KedroStarterSpec(
name="astro-airflow-iris", template_path="git+https://github.com/kedro-org/kedro-starters.git", directory="astro-airflow-iris", origin="kedro"

),

"astro-iris":
KedroStarterSpec(
name="astro-iris", template_path="git+https://github.com/kedro-org/kedro-starters.git", directory="astro-airflow-iris", origin="kedro"

),

}

def _make_cookiecutter_args(config: Dict[str, str], checkout: str, directory: str) -> Dict[str, Any]: (source)

Creates a dictionary of arguments to pass to cookiecutter.

Parameters
config:Dict[str, str]Configuration for starting a new project. This is passed as extra_context to cookiecutter and will overwrite the cookiecutter.json defaults.
checkout:strThe tag, branch or commit in the starter repository to checkout. Maps directly to cookiecutter's checkout argument. Relevant only when using a starter.
directory:strThe directory of a specific starter inside a repository containing multiple starters. Maps directly to cookiecutter's directory argument. Relevant only when using a starter. https://cookiecutter.readthedocs.io/en/1.7.2/advanced/directories.html
Returns
Dict[str, Any]Arguments to pass to cookiecutter.
def _make_cookiecutter_context_for_prompts(cookiecutter_dir: Path): (source)

Undocumented

def _remove_readonly(func: Callable, path: Path, excinfo: Tuple): (source)
def _starter_spec_to_dict(starter_specs: Dict[str, KedroStarterSpec]) -> Dict[str, Dict[str, str]]: (source)

Convert a dictionary of starters spec to a nicely formatted dictionary

def _validate_config_file(config: Dict[str, str], prompts: Dict[str, Any]): (source)

Checks that the configuration file contains all needed variables.

Parameters
config:Dict[str, str]The config as a dictionary.
prompts:Dict[str, Any]Prompts from prompts.yml.
Raises
KedroCliErrorIf the config file is empty or does not contain all the keys required in prompts, or if the output_dir specified does not exist.
_OFFICIAL_STARTER_SPECS = (source)

Undocumented

Value
{spec.alias: spec for spec in _OFFICIAL_STARTER_SPECS}
_STARTERS_REPO: str = (source)

Undocumented

Value
'git+https://github.com/kedro-org/kedro-starters.git'