Skip to content

pipeline

Simple pipeline workflow processing.

CLASS DESCRIPTION
Action

An action to perform in a pipeline.

Pipeline

A collection of actions to perform on an input.

FUNCTION DESCRIPTION
import_function

Import a function from a dotted path.

noop_func

A function that does nothing when called.

pipeline_factory

Create a Pipeline from a list of actions specified by dictionaries.

Attributes

Classes

Action

Action(
    action: str,
    id_: Optional[str] = None,
    args: Optional[list] = None,
    kwargs: Optional[dict] = None,
    commit_metadata_func: Optional[Callable] = None,
    version_metadata_func: Optional[Callable] = None,
)

An action to perform in a pipeline.

METHOD DESCRIPTION
run

Perform the action on the input.

ATTRIBUTE DESCRIPTION
commit_metadata_func

Function the action can call to set metadata about the commit.

TYPE: Optional[Callable]

id

Identifier for the action.

TYPE: Optional[str]

version_metadata_func

Function the action can call to set metadata about the version a commit belongs to.

TYPE: Optional[Callable]

Attributes

commit_metadata_func instance-attribute
commit_metadata_func: Optional[Callable] = commit_metadata_func or noop_func

Function the action can call to set metadata about the commit.

id class-attribute instance-attribute
id: Optional[str] = id_

Identifier for the action.

version_metadata_func instance-attribute
version_metadata_func: Optional[Callable] = version_metadata_func or noop_func

Function the action can call to set metadata about the version a commit belongs to.

Functions

run
run(context: dict, input_value: Any) -> str

Perform the action on the input.

PARAMETER DESCRIPTION
context

The current pipeline context for rendering args and kwargs

TYPE: dict

input_value

The value to processes

TYPE: Any

RETURNS DESCRIPTION
str

The processed string

Pipeline

Pipeline(actions: Union[list, tuple], **kwargs)

A collection of actions to perform on an input.

METHOD DESCRIPTION
run

Run the pipeline using input_value as the starting point.

ATTRIBUTE DESCRIPTION
actions

The actions to perform on the input.

TYPE: tuple

context

The current state of the pipeline initialized by keyword arguments.

TYPE: dict

Attributes

actions instance-attribute
actions: tuple = tuple(actions)

The actions to perform on the input.

context instance-attribute
context: dict = copy()

The current state of the pipeline initialized by keyword arguments.

Functions

run
run(input_value: Optional[str] = None) -> str

Run the pipeline using input_value as the starting point.

PARAMETER DESCRIPTION
input_value

An optional string value to start the pipeline.

TYPE: Optional[str] DEFAULT: None

RETURNS DESCRIPTION
str

The processed result of the pipeline.

Functions

import_function

import_function(function_path: str) -> Callable

Import a function from a dotted path.

Examples:

>>> import_function("generate_changelog.pipeline.noop_func")
<function noop_func at 0x11016d280>
PARAMETER DESCRIPTION
function_path

A dotted path to a function

TYPE: str

RETURNS DESCRIPTION
Callable

The callable function

noop_func

noop_func(**kwargs) -> None

A function that does nothing when called.

pipeline_factory

pipeline_factory(
    action_list: list,
    commit_metadata_func: Optional[Callable] = None,
    version_metadata_func: Optional[Callable] = None,
    **kwargs: Any
) -> Pipeline

Create a Pipeline from a list of actions specified by dictionaries.

PARAMETER DESCRIPTION
action_list

A list of dicts that specify Action attributes

TYPE: list

commit_metadata_func

Optional callable that actions can use to set commit metadata

TYPE: Optional[Callable] DEFAULT: None

version_metadata_func

Optional callable that actions can use to set version metadata

TYPE: Optional[Callable] DEFAULT: None

**kwargs

keyword arguments to pass to the Pipeline constructor

TYPE: Any DEFAULT: {}

RETURNS DESCRIPTION
Pipeline

The instantiated Pipeline