# Data review

A data review runs a published [checklist](https://dev.nominal.io/python/guides/checklists/authoring.md) against a [run](https://dev.nominal.io/python/guides/runs.md).
Each place a check fails becomes an [event](https://dev.nominal.io/python/guides/events.md) for an engineer to review.

For checking live data as it arrives, see [Trigger alerts](https://dev.nominal.io/python/guides/streaming/streaming-checklists.md).

## Connect the client

This guide assumes you have [installed](https://dev.nominal.io/python/guides/install.md) the client and setup your [API keys](https://dev.nominal.io/python/guides/api-keys-setup.md).

```python
from nominal.core import NominalClient

client = NominalClient.from_profile("default")
```

## Run checklists against runs

[`data_review_builder()`](https://dev.nominal.io/python/ref/generated/nominal.core.NominalClient.md#nominal.core.NominalClient.data_review_builder "nominal.core.NominalClient.data_review_builder") returns a [`DataReviewBuilder`](https://dev.nominal.io/python/ref/generated/nominal.core.DataReviewBuilder.md#nominal.core.DataReviewBuilder "nominal.core.DataReviewBuilder").
Add one [`execute_checklist()`](https://dev.nominal.io/python/ref/generated/nominal.core.DataReviewBuilder.md#nominal.core.DataReviewBuilder.execute_checklist "nominal.core.DataReviewBuilder.execute_checklist") per run and checklist pair, then start them all with [`initiate()`](https://dev.nominal.io/python/ref/generated/nominal.core.DataReviewBuilder.md#nominal.core.DataReviewBuilder.initiate "nominal.core.DataReviewBuilder.initiate"):

```python
builder = client.data_review_builder()
builder.execute_checklist("<RUN_RID>", "<CHECKLIST_RID>", commit="<COMMIT_SHA>")  # pin a version
builder.execute_checklist("<OTHER_RUN_RID>", "<CHECKLIST_RID>")  # latest version
builder.add_integration("<INTEGRATION_RID>")  # optional: notify when checks fail

for review in builder.initiate():
    print(review.nominal_url, len(review.get_events()))
```

Copy checklist RIDs and commit SHAs from the [Checklists page](https://app.gov.nominal.io/checklists).
For a run with several assets, pass `asset=` to choose the one to review.

`initiate` waits for the reviews to finish by default, but doesn’t wait for notifications.
Pass `wait_for_completion=False` to return immediately, then call [`poll_for_completion()`](https://dev.nominal.io/python/ref/generated/nominal.core.DataReview.md#nominal.core.DataReview.poll_for_completion "nominal.core.DataReview.poll_for_completion") on each review.

Notifications support Slack, Opsgenie and webhook integrations.

## Read results later

```python
review = client.get_data_review("<DATA_REVIEW_RID>")
events = review.get_events()
```

[`search_data_reviews()`](https://dev.nominal.io/python/ref/generated/nominal.core.NominalClient.md#nominal.core.NominalClient.search_data_reviews "nominal.core.NominalClient.search_data_reviews") and [`search_data_reviews()`](https://dev.nominal.io/python/ref/generated/nominal.core.Asset.md#nominal.core.Asset.search_data_reviews "nominal.core.Asset.search_data_reviews") find reviews by run or asset.
To review the results in the UI, see [Data review](https://docs.nominal.io/core/documentation/platform/flag-events/data-review).
