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
from archivist.archivist import Archivist

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


LOGGER = getLogger(__name__)


def run(arch: Archivist, args):
    LOGGER.info("Using version %s of datatrails-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["DATATRAILS_UNIQUE_ID"] = 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.

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 DataTrails instance, this is typically https://app.datatrails.ai

Example usage:

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

For further reading: