Skip to content

Latest commit

 

History

History
229 lines (131 loc) · 6.97 KB

ml_buildkit.helpers.build_python.md

File metadata and controls

229 lines (131 loc) · 6.97 KB

module ml_buildkit.helpers.build_python

Utilities to help building Python libraries.

Global Variables

  • FLAG_PYPI_TOKEN
  • FLAG_PYPI_REPOSITORY

function parse_arguments

parse_arguments(
    input_args: List[str] = None,
    argument_parser: ArgumentParser = None
) → dict

Parses all arguments and returns a sanitized & augmented list of arguments.

Sanitized means that, for example, the version is already checked and set depending on our build guidelines. If arguments are not valid, exit the script run.

Args:

  • input_args (List[str], optional): List of arguments that are used instead of the arguments passed to the process. Defaults to None.
  • argument_parser (arparse.ArgumentParser, optional): An argument parser which is passed as a parents parser to the default ArgumentParser to be able to use additional flags besides the default ones.

Returns:

  • dict: The parsed default arguments thar are already checked for validity.

function is_pipenv_environment

is_pipenv_environment() → bool

Check if current working directory is a valid pipenv environment.


function test_with_py_version

test_with_py_version(python_version: str, exit_on_error: bool = True) → None

Run pytest in a environment wiht the specified python version.

Args:

  • python_version (str): Python version to use inside the virutal environment.
  • exit_on_error (bool, optional): Exit process if an error occurs. Defaults to True.

function install_build_env

install_build_env(exit_on_error: bool = True) → None

Installs a new virtual environment via pipenv.

Args:

  • exit_on_error (bool, optional): Exit process if an error occurs. Defaults to True.

function generate_api_docs

generate_api_docs(
    github_url: str,
    main_package: str,
    exit_on_error: bool = True
) → None

Generates API documentation via docsai.

Args:

  • github_url (str): Github URL
  • main_package (str): The main package name to use for docs generation.
  • exit_on_error (bool, optional): Exit process if an error occurs. Defaults to True.

function publish_pypi_distribution

publish_pypi_distribution(
    pypi_token: str,
    pypi_user: str = '__token__',
    pypi_repository: Optional[str] = None,
    exit_on_error: bool = True
) → None

Publish distribution to pypi.

Args:

  • pypi_token (str): Token of PyPi repository.
  • pypi_user (str, optional): User of PyPi repository. Defaults to "token".
  • pypi_repository (Optional[str], optional): PyPi repository. If None provided, use the production instance.
  • exit_on_error (bool, optional): Exit process if an error occurs. Defaults to True.

function code_checks

code_checks(
    black: bool = True,
    isort: bool = True,
    pydocstyle: bool = True,
    mypy: bool = True,
    flake8: bool = True,
    safety: bool = False,
    exit_on_error: bool = True
) → None

Run linting and style checks.

Args:

  • black (bool, optional): Activate black formatting check. Defaults to True.
  • isort (bool, optional): Activate isort import sorting check. Defaults to True.
  • pydocstyle (bool, optional): Activate pydocstyle docstring check. Defaults to True.
  • mypy (bool, optional): Activate mypy typing check. Defaults to True.
  • flake8 (bool, optional): Activate flake8 linting check. Defaults to True.
  • safety (bool, optional): Activate saftey check via pipenv. Defaults to False.
  • exit_on_error (bool, optional): If True, exit process as soon as error occures. Defaults to True.

function update_version

update_version(
    module_path: str,
    version: str,
    exit_on_error: bool = True
) → None

Update version in specified module.

Args:

  • module_path (str): Python module with a __version__ attribute.
  • version (str): New version number to write into __version__ attribute.
  • exit_on_error (bool, optional): If True, exit process as soon as error occures. Defaults to True.

function build_distribution

build_distribution(exit_on_error: bool = True) → None

Build python package distribution.

Args:

  • exit_on_error (bool, optional): If True, exit process as soon as error occures. Defaults to True.

This file was automatically generated via docsai.