Initiate Data Review in Nominal with Python

Data review is the process of:

  1. Applying a checklist to a run
  2. Reviewing time ranges where checks were violated
  3. Determining if violations should be ignored or require further action

Read more on data review in the platform guide

In this guide, we focus on Step 1: Applying a checklist to a run using the Nominal Python client.

Prerequisites

Make sure you have the nominal Python package installed. You can install it using:

1pip3 install nominal

Connect to Nominal

When using the Nominal client library, there are two primary ways of authenticating:

First, run the following in your terminal and follow on-screen prompts to insert the base_url and API key:

$$ python -m nominal auth set-token
>
># Alternatively, use the globally installed CLI
>$ nom auth set-token

This will store your API key in a config file ~/.nominal.yml. The API key will automatically be used when using the client again.

1import nominal
2
3# Simply grab the "default" client using your stored credentials
4client = nominal.get_default_client()
5
6# Get details about the currently logged-in user to validate authentication
7# Will display an object like: `User(display_name='your_email@your_company.com', ...)`
8print(client.get_user())
1import nominal
2
3# Set login details for the user
4nominal.set_token("<insert api key>")
5
6# Get an instance of the client using provided credentials
7client = nominal.get_default_client()
8
9# Get details about the currently logged-in user to validate authentication
10# Will display an object like: `User(display_name='your_email@your_company.com', ...)`
11print(client.get_user())

NOTE: you should never share your Nominal API key with anyone. We therefore recommend that you not save it in your code and/or scripts.

  • If you trust the computer you are on, use nom to store the credential to disk.
  • Otherwise, use a password manager such as 1password or bitwarden to keep your token safe.
If you’re not sure whether your company has a Nominal tenant, please reach out to us.

Applying Checklists to Runs

Nominal allows you to apply multiple checklists to multiple runs simultaneously. You can also optionally specify integrations to send notifications if violations are found.

  1. Locate or Create Run RIDs

    Find the run RID(s) in the platform or create new runs with the Nominal client. Then paste the run RID(s) below.

    1run1_rid = "paste_rid_here"
    2run2_rid = "paste_rid_here"
  2. Locate Checklist RIDs and Commits

    Find the checklist RID(s) in the platform. You will also need the commit SHA for the version you want to apply (listed under “Latest version”).

    1checklist1_rid = "paste_rid_here"
    2checklist1_commit = "paste_commit_sha_here"
    3
    4checklist2_rid = "paste_rid_here"
    5checklist2_commit = "paste_commit_sha_here"
  3. Optionally, Specify an Integration

    If you would like to send notifications when violations occur, you can specify an integration RID. You can find the integration RID in the platform.

    1integration_rid = "paste_rid_here"
  4. Apply Checklists Use the Nominal client to create a data review builder, add your integration (optional), and add each request (which associates a run with a checklist). Then initiate the reviews.

    1review_builder = nm.data_review_builder()
    2review_builder.add_integration(integration_rid) # Optional
    3
    4# Add requests for run1
    5review_builder.add_request(run1_rid, checklist1_rid, checklist1_commit)
    6review_builder.add_request(run1_rid, checklist2_rid, checklist2_commit) # Optional
    7
    8# Add requests for run2
    9review_builder.add_request(run2_rid, checklist1_rid, checklist1_commit) # Optional
    10
    11# Initiate reviews
    12reviews = review_builder.initiate()
    13
    14# Print out results
    15for review in reviews:
    16 print(f"review: {review.rid}, URL: {review.nominal_url}")
    17 print(f" nr. of violations: {len(review.get_violations())})

That’s it! You have now applied one or more checklists to your runs, and you’ll be able to see any violations that arose.

Retrieving Data Review Results Later

You can retrieve the results of a data review at any time using the nm.get_data_review() function.

1review = nm.get_data_review(review_rid)