Common#

This module contains several functions which are used to run demonstrations in tutorials.

is_interactive_mode()[source]#

Checking whether the tutorial code should be run in interactive mode.

Return type:

bool

Returns:

True if it’s being executed by Jupyter kernel and DISABLE_INTERACTIVE_MODE env variable isn’t set, False otherwise.

check_happy_path(pipeline, happy_path, response_comparer=<function default_comparer>, printout_enable=True)[source]#

Running tutorial with provided pipeline for provided requests, comparing responses with correct expected responses. In cases when additional processing of responses is needed (e.g. in case of response being an HTML string), a special function (response comparer) is used.

Parameters:
  • pipeline (Pipeline) – The Pipeline instance, that will be used for checking.

  • happy_path (Tuple[Tuple[Message, Message], ...]) – A tuple of (request, response) tuples, so-called happy path, its requests are passed to pipeline and the pipeline responses are compared to its responses.

  • response_comparer (Callable[[Message, Message, Context], Optional[str]]) – A special comparer function that accepts received response, true response and context; it returns None is two responses are equal and transformed received response if they are different.

  • printout_enable (bool) – A flag that enables requests and responses fancy printing (to STDOUT).

run_interactive_mode(pipeline)[source]#

Running tutorial with provided pipeline in interactive mode, just like with CLI messenger interface. The dialog won’t be stored anywhere, it will only be outputted to STDOUT.

Parameters:

pipeline (Pipeline) – The Pipeline instance, that will be used for running.