# create\_test\_session

<pre class="language-python"><code class="lang-python">dbnl.create_test_session(
    *,
    experiment_run: Run,
    baseline: Optional[Union[Run, RunQuery]] = None,
    include_tags: Optional[List[str]] = None,
    exclude_tags: Optional[List[str]] = None,
    require_tags: Optional[List[str]] = None,
) -> <a data-footnote-ref href="#user-content-fn-1">TestSession</a>:
</code></pre>

Start evaluating Tests associated with a Run. Typically, the Run you just completed will be the "Experiment" and you'll compare it to some earlier "Baseline Run".

{% hint style="warning" %}
The Run must already have [Results reported](/v0.20.x/using-distributional/python-sdk/sdk-functions/run-results/report_results-2.md) and be closed before a Test Session can begin.
{% endhint %}

{% hint style="info" %}
A Run must be closed for all [uploaded results](/v0.20.x/using-distributional/python-sdk/sdk-functions/run-results/report_results-2.md) to be shown on the UI.
{% endhint %}

## Parameters

<table><thead><tr><th width="213">Arguments</th><th>Description</th></tr></thead><tbody><tr><td><code>experiment_run</code></td><td>The dbnl <a href="/pages/QtYyvw16aMflnd2CNWFJ">Run</a> to create the TestSession for.</td></tr><tr><td><code>baseline</code></td><td>The dbnl <a href="/pages/QtYyvw16aMflnd2CNWFJ">Run</a> or <a href="/pages/drow2mSYpT7g0rOPvX5M">RunQuery</a> to compare the <code>experiment_run</code>against. If <code>None</code>(or omitted), will use the <code>baseline</code>defined in the TestConfig</td></tr><tr><td><code>include_tags</code></td><td>An optional list of Test Tags to be included. All Tests with any of the tags in this list will be ran after the run is complete.</td></tr><tr><td><code>exclude_tags</code></td><td>An optional list of Test Tags to be excluded. All Tests with any of the tags in this list will be skipped after the run is complete.</td></tr><tr><td><code>require_tags</code></td><td>An optional list of Test Tags that are required. Only tests with all the tags in this list will be ran after the run is complete. </td></tr></tbody></table>

### Managing Tags

Suppose we have the following Tests with the associated Tags in our Project

* Test1 with tags \["A", "B"]
* Test2 with tags \["A"]
* Test3 with tags \["B"]

`dbnl.create_test_session(..., include_tags=["A", "B"])` will trigger Tests 1, 2, 3 to be executed.

`dbnl.create_test_session(..., require_tags=["A", "B"])` will only trigger Test 1.

`dbnl.create_test_session(..., exclude_tags=["A"])` will trigger Test 3.

`dbnl.create_test_session(..., include_tags=["A"], exclude_tags=["B"])` will  trigger Test 2.

## Examples

### Basic example

```python
dbnl.create_test_session(
  experiment_run=new_run,
  baseline=baseline_run,
)
```

### Using a Run Query as a Baseline

```python
dbnl.create_test_session(
  experiment_run=new_run,
  baseline=baseline_run_query,
)
```

### When Baseline Run has already been set

```python
dbnl.create_test_session(
  experiment_run=new_run,
)
```

[^1]: [TestSession](/v0.20.x/using-distributional/python-sdk/sdk-objects/testsession.md)


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.dbnl.com/v0.20.x/using-distributional/python-sdk/sdk-functions/test-session/create_test_session.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
