# Compliance Documentation

#### Peter Hurford

#### 2019-08-27

Compliance documentation is a premium add-on product to DataRobot. It allows users to automatically generate and download documentation to assist with deploying models in highly regulated industries.

## Connect to DataRobot

To explore compliance documentation, let’s first connect to DataRobot. First, you must load the DataRobot R package library.

If you have set up a credentials file, `library(datarobot)` will initialize a connection to DataRobot automatically. Otherwise, you can specify your `endpoint` and `apiToken` as in this example to connect to DataRobot directly. For more information on connecting to DataRobot, see the “Introduction to DataRobot” vignette.

    library(datarobot)
    endpoint <- "https://<YOUR DATAROBOT URL GOES HERE>/api/v2"
    apiToken <- "<YOUR API TOKEN GOES HERE>"
    ConnectToDataRobot(endpoint = endpoint, token = apiToken)

## Download Compliance Documentation

To download compliance documentation for a particular model, call `DownloadComplianceDocumentation` on a particular model and specify a filepath to download the documentation to. Note that it downloads in DOCX format.

    DownloadComplianceDocumentation(model, "path/to/filename.docx")

## Creating a Custom Template

You can also use your own custom compliance documentation templates.

#### The Default Template

First, let’s get the default template. This can be done just by using `GetComplianceDocTemplate`. It downloads as a JSON file.

    GetComplianceDocTemplate("path/to/filename.json")

#### Updating the Default Template

A common workflow for building your own template is downloading the default template and modifying it.

    DownloadComplianceDocTemplate("path/to/filename.json")
    # ...then modify the compliance doc template in your favorite editor.
    UploadComplianceDocTemplate(name = "myNewTemplate", filename = "path/to/modified_file.json")

Alternatively, you can construct a template via a list:

    sections <- list(list("title" = "Missing Values Report",
                          "highlightedText" = "NOTICE",
                          "regularText" = "This dataset had a lot of Missing Values. See the chart below: {{missingValues}}",
                          "type" = "user"),
                     list("title" = "Blueprints",
                          "regularText" = "{{blueprintDiagram}} /n Blueprint for this model",
                          "type" = "user"))
    UploadComplianceDocTemplate(name = "myNewTemplateFromSections", sections = sections)

You can then get and download your template:

    myTemplate <- ListComplianceDocTemplates(namePart = "myNewTemplateFromSections")[[1]]
    DownloadComplianceDocTemplate(myTemplate)

#### Creating Custom Compliance Documentation from Custom Template

Once you have a custom template made, you can use it to create custom compliance documenation:

    myTemplate <- ListComplianceDocTemplates(namePart = "myNewTemplate")[[1]]
    CreateComplianceDocumentation(model, myTemplate)