Reference
aflowey.async_flow
- class aflowey.async_flow.AsyncFlow(*args, **kwargs)
Describe an async flow chaining function
>>>flow = (AsyncFlow() >> gen1 >> gen2 >> gen3)
>>>await flow.run()
- Parameters
args (Any) –
kwargs (Any) –
- static from_args(*args, **kwargs)
create a flow with given arguments as first input
- Parameters
args (Any) –
kwargs (Any) –
- Return type
- static from_flow(flow)
create a new flow from given flow, copying it (args, kwargs, and aws functions)
- async run(**kwargs)
run the flow
- Returns
coroutine
- Return type
Any
aflowey.single_executor
- class aflowey.single_executor.SingleFlowExecutor(flow)
Single flow executor
- Parameters
flow (AsyncFlow) –
- async static check_and_execute_flow_if_needed(maybe_flow, **kwargs)
check if we have an async flow and execute it
- Parameters
maybe_flow (Union[Any, AsyncFlow]) –
kwargs (Any) –
- Return type
Any
- async execute_flow(is_root, **kwargs)
Main function to execute a flow
- Parameters
is_root (bool) –
kwargs (Any) –
- Return type
Any
- static get_step_name(func, index)
get the step name
- Parameters
func (F) –
index (int) –
- Return type
str
- static need_to_cancel_flow(result)
check if we need to cancel flow checking sentinel
- Parameters
result (Any) –
- Return type
bool
aflowey.executor
- class aflowey.executor.AsyncFlowExecutor
Execute several flows concurrently
>>> await (aexec().from_flows(flows) | flow).run()
- from_flows(flows)
create a new executor from one flow or array of flows
- Parameters
flows (Any) –
- Return type
- async run(**kwargs)
main function to run stuff in parallel
- Parameters
kwargs (Any) –
- Return type
Any
- aflowey.executor.aexec
alias of
AsyncFlowExecutor
- aflowey.executor.async_exec
alias of
AsyncFlowExecutor
aflowey.f
- class aflowey.f.F(func)
tiny wrapper around a function
- Parameters
func (Function) – callable
aflowey.functions
- aflowey.functions.F0(func)
create a new function from a 0 arity function (takes 0 args). The new function takes exactly one argument and does not pass it to the wrapped function. It allows using a 0 arity function in a flow relatively easily.
- Parameters
func (Function) –
- Return type
- aflowey.functions.F1(func, extractor=None)
wraps a one argument function (with arity 1) and allows to add an extractor to work on the input argument.
- Parameters
func (Function) –
extractor (Optional[Function]) –
- Return type
- aflowey.functions.apartial(func, *args, **kwargs)
make a partial function of the given func and ensure it will work in an async context
- Parameters
func (Function) –
args (Any) –
kwargs (Any) –
- Return type
- aflowey.functions.breaker(func)
simply for readability
- Parameters
func (Function) –
- Return type
Function
- aflowey.functions.ensure_callable(x)
ensure a given args is a callable by returning a new callable if not
- Parameters
x (Union[Any, Function]) –
- Return type
Function
- aflowey.functions.ensure_f(func)
wrap the given function into an F instance
- Parameters
func (Function) –
- Return type
- aflowey.functions.erratic(func)
simply for readability
- Parameters
func (Function) –
- Return type
Function
- aflowey.functions.f0(func)
create a new function from a 0 arity function (takes 0 args). The new function takes exactly one argument and does not pass it to the wrapped function. It allows using a 0 arity function in a flow relatively easily.
- Parameters
func (Function) –
- Return type
- aflowey.functions.f1(func, extractor=None)
wraps a one argument function (with arity 1) and allows to add an extractor to work on the input argument.
- Parameters
func (Function) –
extractor (Optional[Function]) –
- Return type
- aflowey.functions.flog(log_str='', print_arg=False)
utility function to log between steps, printing argument if needed
- Parameters
log_str (str) –
print_arg (bool) –
- Return type
Any
- aflowey.functions.imp(*func)
take an array of function and tag it as side effects function
- aflowey.functions.impure(*func)
take an array of function and tag it as side effects function
- aflowey.functions.log(log_str='', print_arg=False)
utility function to log between steps, printing argument if needed
- Parameters
log_str (str) –
print_arg (bool) –
- Return type
Any
- aflowey.functions.make_impure(func)
tags the given function as impure, i.e. consume an argument but does not create new one
- aflowey.functions.may_fail(func)
simply for readability
- Parameters
func (Function) –
- Return type
Function
- aflowey.functions.named(func, name)
tags a function as a named function
- aflowey.functions.p(func, *args, **kwargs)
make a partial function of the given func and ensure it will work in an async context
- Parameters
func (Function) –
args (Any) –
kwargs (Any) –
- Return type
- aflowey.functions.partial(func, *args, **kwargs)
make a partial function of the given func and ensure it will work in an async context
- Parameters
func (Function) –
args (Any) –
kwargs (Any) –
- Return type
- aflowey.functions.side_effect(*func)
take an array of function and tag it as side effects function
- aflowey.functions.spread(func)
create a function which takes an iterable of args and spread it into the given function
- Parameters
func (Function) –
- Return type
- aflowey.functions.spread_args(func)
create a function which takes an iterable of args and spread it into the given function
- Parameters
func (Function) –
- Return type
- aflowey.functions.spread_kw(func)
create a function which takes a mapping of kwargs and spread it into the given function
- Parameters
func (Function) –
- Return type
- aflowey.functions.spread_kwargs(func)
create a function which takes a mapping of kwargs and spread it into the given function
- Parameters
func (Function) –
- Return type