Render a data model diagram

    Included in the diagram are all classes from the model registry.
    For your project, write a small script that imports all models that you would like to
    have included and then calls this function.

    .. note:: This function requires the 'dot' executable from the GraphViz package to be installed
              and its location configured in your `project_config.py` variable :attr:`DOT_EXECUTABLE`.

    Args:
        out_base (str): output base path (file endings will be appended)

def render_diagram(out_base):
    """Render a data model diagram

    Included in the diagram are all classes from the model registry.
    For your project, write a small script that imports all models that you would like to
    have included and then calls this function.

    .. note:: This function requires the 'dot' executable from the GraphViz package to be installed
              and its location configured in your `project_config.py` variable :attr:`DOT_EXECUTABLE`.

    Args:
        out_base (str): output base path (file endings will be appended)
    """
    import codecs
    import subprocess
    import sadisplay

    # generate class descriptions
    desc = sadisplay.describe(list(model_registry.values()),
                              show_methods=False,
                              show_properties=True,
                              show_indexes=True,
                              )

    # write description in DOT format
    with codecs.open(out_base + '.dot', 'w', encoding='utf-8') as f:
        f.write(sadisplay.dot(desc))

    # check existence of DOT_EXECUTABLE variable and file
    if not hasattr(config, 'DOT_EXECUTABLE'):
        raise RuntimeError("Please configure the 'DOT_EXECUTABLE' variable in your 'project_config.py'")
    if not os.path.exists(config.DOT_EXECUTABLE):
        raise IOError("Could not find file pointed to by 'DOT_EXECUTABLE': " + str(config.DOT_EXECUTABLE))

    # render to image using DOT
    # noinspection PyUnresolvedReferences
    subprocess.check_call([
        config.DOT_EXECUTABLE,
        '-T', 'png',
        '-o', out_base + '.png',
              out_base + '.dot'
    ])