Story Runner

A runner attribute of the archivist instance allows running scenarios from a dictionary. Usually the dictionary is read from a yaml or json file.

# pylint:  disable=missing-docstring

from logging import getLogger
from os import environ
from sys import exit as sys_exit
from warnings import filterwarnings

from pyaml_env import parse_config

from archivist import about

# pylint:disable=unused-import      # To prevent cyclical import errors forward referencing is used
# pylint:disable=cyclic-import      # but pylint doesn't understand this feature
from archivist import archivist as type_helper

filterwarnings("ignore", message="Unverified HTTPS request")


LOGGER = getLogger(__name__)


def run(arch: "type_helper.Archivist", args):

    LOGGER.info("Using version %s of jitsuin-archivist", about.__version__)
    LOGGER.info("Namespace %s", args.namespace)

    # if namespace is specified on the commandline then override any environment
    # setting...
    if args.namespace:
        environ["ARCHIVIST_NAMESPACE"] = args.namespace

    with open(args.yamlfile, "r", encoding="utf-8") as y:
        arch.runner(parse_config(data=y))

    sys_exit(0)

This functionality is also available with the CLI tool archivist_runner, which is bundled with version v0.10 onwards of the jitsuin-archivist PIP installation.

See the installation instructions for more information.

You can verify the installation by running the following:

archivist_runner -h

Which will show you the available options when using archivist_runner.

To use the archivist_runner command you will need the following:

  • A Client ID and Client Secret by creating an App Registration

  • The YAML file with the operations you wish to run

  • The URL of your RKVST instance, this is typically https://app.rkvst.io

Example usage:

archivist_runner \
      -u https://app.rkvst.io \
      --client-id <your-client-id> \
      --client-secret <your-client-secret> \
      functests/test_resources/richness_story.yaml

For further reading: