\n",
@@ -304,6 +303,7 @@
"print(\"\\n=== Mode: disabled ===\")\n",
"os.environ[\"VALIDMIND_PII_DETECTION\"] = \"disabled\"\n",
"\n",
+ "# Run test and tag result with unique ID `disabled`\n",
"run_pii_test(\"disabled\")"
]
},
@@ -325,9 +325,10 @@
"outputs": [],
"source": [
"print(\"\\n=== Mode: test_results ===\")\n",
- "os.environ[\"VALIDMIND_PII_DETECTION\"] = \"results_blocked\"\n",
+ "os.environ[\"VALIDMIND_PII_DETECTION\"] = \"test_results\"\n",
"\n",
- "run_pii_test(\"test_results\")"
+ "# Run test and tag result with unique ID `results_blocked`\n",
+ "run_pii_test(\"results_blocked\")"
]
},
{
@@ -348,9 +349,10 @@
"outputs": [],
"source": [
"print(\"\\n=== Mode: test_descriptions ===\")\n",
- "os.environ[\"VALIDMIND_PII_DETECTION\"] = \"descriptions_blocked\"\n",
+ "os.environ[\"VALIDMIND_PII_DETECTION\"] = \"test_descriptions\"\n",
"\n",
- "run_pii_test(\"test_descriptions\")"
+ "# Run test and tag result with unique ID `desc_blocked`\n",
+ "run_pii_test(\"desc_blocked\")"
]
},
{
@@ -371,9 +373,10 @@
"outputs": [],
"source": [
"print(\"\\n=== Mode: all ===\")\n",
- "os.environ[\"VALIDMIND_PII_DETECTION\"] = \"results_descriptions_blocked\"\n",
+ "os.environ[\"VALIDMIND_PII_DETECTION\"] = \"all\"\n",
"\n",
- "run_pii_test(\"all\")"
+ "# Run test and tag result with unique ID `results_desc_blocked`\n",
+ "run_pii_test(\"results_desc_blocked\")"
]
},
{
From 78486876cd934119998a6140371eb92c5268409f Mon Sep 17 00:00:00 2001
From: Beck <164545837+validbeck@users.noreply.github.com>
Date: Thu, 21 Aug 2025 11:44:04 -0700
Subject: [PATCH 25/37] .
---
notebooks/code_sharing/enable_pii_detection.ipynb | 14 +++++++++++---
1 file changed, 11 insertions(+), 3 deletions(-)
diff --git a/notebooks/code_sharing/enable_pii_detection.ipynb b/notebooks/code_sharing/enable_pii_detection.ipynb
index 3e3d19cd5..840976914 100644
--- a/notebooks/code_sharing/enable_pii_detection.ipynb
+++ b/notebooks/code_sharing/enable_pii_detection.ipynb
@@ -375,8 +375,8 @@
"print(\"\\n=== Mode: all ===\")\n",
"os.environ[\"VALIDMIND_PII_DETECTION\"] = \"all\"\n",
"\n",
- "# Run test and tag result with unique ID `results_desc_blocked`\n",
- "run_pii_test(\"results_desc_blocked\")"
+ "# Run test and tag result with unique ID `all_blocked`\n",
+ "run_pii_test(\"all_blocked\")"
]
},
{
@@ -404,11 +404,19 @@
"id": "310f69e1",
"metadata": {},
"source": [
- "### Test only a subset\n",
+ "#### Test only a subset\n",
"\n",
"To test only a subset (tables or descriptions), adjust the test to emit only that type and re-run the mode loop:"
]
},
+ {
+ "cell_type": "markdown",
+ "id": "9ab973f2",
+ "metadata": {},
+ "source": [
+ "### Review logged test results"
+ ]
+ },
{
"cell_type": "markdown",
"id": "53a1a62d",
From 39d3a0643708308222b8ec6a0fe10966d08d0509 Mon Sep 17 00:00:00 2001
From: Beck <164545837+validbeck@users.noreply.github.com>
Date: Thu, 21 Aug 2025 11:48:18 -0700
Subject: [PATCH 26/37] override
---
.../code_sharing/enable_pii_detection.ipynb | 29 ++++++++++++++++++-
1 file changed, 28 insertions(+), 1 deletion(-)
diff --git a/notebooks/code_sharing/enable_pii_detection.ipynb b/notebooks/code_sharing/enable_pii_detection.ipynb
index 840976914..4ae55a833 100644
--- a/notebooks/code_sharing/enable_pii_detection.ipynb
+++ b/notebooks/code_sharing/enable_pii_detection.ipynb
@@ -396,7 +396,34 @@
"\n",
"You can override blocking by passing `unsafe=True` to `result.log(unsafe=True)`, but this is not recommended outside controlled workflows.\n",
"\n",
- "For example,"
+ "For example, let's rerun our custom test with detection set to `all`, then override the blocking:"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "id": "c8dac20b",
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "print(\"\\n=== Mode: all & unsafe=True ===\")\n",
+ "os.environ[\"VALIDMIND_PII_DETECTION\"] = \"all\"\n",
+ "\n",
+ "# Run test and tag result with unique ID `unsafe_true`\n",
+ "try:\n",
+ " result = run_test(\"pii_demo.PIIDetection:unsafe_true\")\n",
+ "\n",
+ " # Check if the test description was generated by LLM\n",
+ " if not result._was_description_generated:\n",
+ " print(\"PII detected: LLM-generated test description skipped\")\n",
+ " else:\n",
+ " print(\"No PII detected, detection disabled, or override set: Test description generated by LLM\")\n",
+ "\n",
+ " # Try logging test results to the ValidMind Platform\n",
+ " result.log()\n",
+ " print(\"No PII detected, detection disabled, or override set: Test results logged to the ValidMind Platform\")\n",
+ "except Exception as e:\n",
+ " print(\"PII detected: Test results not logged to the ValidMind Platform\")"
]
},
{
From 6c7cab2e1bc17232412d517130931ceeece68779 Mon Sep 17 00:00:00 2001
From: Beck <164545837+validbeck@users.noreply.github.com>
Date: Thu, 21 Aug 2025 11:58:01 -0700
Subject: [PATCH 27/37] Ugh
---
notebooks/code_sharing/enable_pii_detection.ipynb | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/notebooks/code_sharing/enable_pii_detection.ipynb b/notebooks/code_sharing/enable_pii_detection.ipynb
index 4ae55a833..4ed04d33d 100644
--- a/notebooks/code_sharing/enable_pii_detection.ipynb
+++ b/notebooks/code_sharing/enable_pii_detection.ipynb
@@ -276,7 +276,7 @@
"id": "e349b5f5",
"metadata": {},
"source": [
- "We'll then switch `VALIDMIND_PII_DETECTION` across modes in the below examples.\n",
+ "We'll then switch the `VALIDMIND_PII_DETECTION` environment variable across modes in the below examples.\n",
"\n",
"
Note that since we are running a custom test that does not exist in your model's default documentation template, we'll receive output indicating that a test-driven block doesn't currently exist in your model's documentation for that particular test ID.\n",
"
\n",
@@ -411,7 +411,7 @@
"\n",
"# Run test and tag result with unique ID `unsafe_true`\n",
"try:\n",
- " result = run_test(\"pii_demo.PIIDetection:unsafe_true\")\n",
+ " result = run_test(\"pii_demo.PIIDetection:all_unsafe_true\")\n",
"\n",
" # Check if the test description was generated by LLM\n",
" if not result._was_description_generated:\n",
@@ -420,7 +420,7 @@
" print(\"No PII detected, detection disabled, or override set: Test description generated by LLM\")\n",
"\n",
" # Try logging test results to the ValidMind Platform\n",
- " result.log()\n",
+ " result.log(unsafe=True)\n",
" print(\"No PII detected, detection disabled, or override set: Test results logged to the ValidMind Platform\")\n",
"except Exception as e:\n",
" print(\"PII detected: Test results not logged to the ValidMind Platform\")"
From 0ae145d2eafe7b1b554e6393957db54cd9dcd7f7 Mon Sep 17 00:00:00 2001
From: Beck <164545837+validbeck@users.noreply.github.com>
Date: Thu, 21 Aug 2025 12:08:40 -0700
Subject: [PATCH 28/37] Save point
---
.../code_sharing/enable_pii_detection.ipynb | 24 +++++++++++++++----
1 file changed, 20 insertions(+), 4 deletions(-)
diff --git a/notebooks/code_sharing/enable_pii_detection.ipynb b/notebooks/code_sharing/enable_pii_detection.ipynb
index 4ed04d33d..c9b8d6ab4 100644
--- a/notebooks/code_sharing/enable_pii_detection.ipynb
+++ b/notebooks/code_sharing/enable_pii_detection.ipynb
@@ -409,9 +409,9 @@
"print(\"\\n=== Mode: all & unsafe=True ===\")\n",
"os.environ[\"VALIDMIND_PII_DETECTION\"] = \"all\"\n",
"\n",
- "# Run test and tag result with unique ID `unsafe_true`\n",
+ "# Run test and tag result with unique ID `override`\n",
"try:\n",
- " result = run_test(\"pii_demo.PIIDetection:all_unsafe_true\")\n",
+ " result = run_test(\"pii_demo.PIIDetection:override\")\n",
"\n",
" # Check if the test description was generated by LLM\n",
" if not result._was_description_generated:\n",
@@ -431,7 +431,7 @@
"id": "310f69e1",
"metadata": {},
"source": [
- "#### Test only a subset\n",
+ "#### Test only a subset*\n",
"\n",
"To test only a subset (tables or descriptions), adjust the test to emit only that type and re-run the mode loop:"
]
@@ -441,7 +441,23 @@
"id": "9ab973f2",
"metadata": {},
"source": [
- "### Review logged test results"
+ "### Review logged test results\n",
+ "\n",
+ "Now let's take a look at the results that were logged to the ValidMind Platform:\n",
+ "\n",
+ "1. From the **Inventory** in the ValidMind Platform, go to the model you registered earlier. ([Need more help?](https://docs.validmind.ai/guide/model-inventory/working-with-model-inventory.html))\n",
+ "\n",
+ "2. In the left sidebar that appears for your model, click **Documentation** under Documents.\n",
+ "\n",
+ "3. Click on any section heading to expand that section to add a new test-driven block ([Need more help?](https://docs.validmind.ai/developer/model-documentation/work-with-test-results.html)).\n",
+ "\n",
+ "4. Under TEST-DRIVEN in the sidebar, click **Custom**.\n",
+ "\n",
+ "5. Confirm that you're able to insert the following logged results:\n",
+ "\n",
+ " - `pii_demo.PIIDetection:disabled`\n",
+ " - `pii_demo.PIIDetection:desc_blocked`\n",
+ " - `pii_demo.PIIDetection:override`"
]
},
{
From 6d5105ab93aa84dcfaae9bcfe96421b003e17f4e Mon Sep 17 00:00:00 2001
From: Beck <164545837+validbeck@users.noreply.github.com>
Date: Thu, 21 Aug 2025 13:56:10 -0700
Subject: [PATCH 29/37] Finishing up?
---
.../code_sharing/enable_pii_detection.ipynb | 52 +++++++++++++------
1 file changed, 35 insertions(+), 17 deletions(-)
diff --git a/notebooks/code_sharing/enable_pii_detection.ipynb b/notebooks/code_sharing/enable_pii_detection.ipynb
index c9b8d6ab4..30435bd57 100644
--- a/notebooks/code_sharing/enable_pii_detection.ipynb
+++ b/notebooks/code_sharing/enable_pii_detection.ipynb
@@ -379,24 +379,16 @@
"run_pii_test(\"all_blocked\")"
]
},
- {
- "cell_type": "markdown",
- "id": "d2c36322",
- "metadata": {},
- "source": [
- "### Detection adjustments"
- ]
- },
{
"cell_type": "markdown",
"id": "284e69e5",
"metadata": {},
"source": [
- "#### Overriding detection\n",
+ "### Override detection\n",
"\n",
"You can override blocking by passing `unsafe=True` to `result.log(unsafe=True)`, but this is not recommended outside controlled workflows.\n",
"\n",
- "For example, let's rerun our custom test with detection set to `all`, then override the blocking:"
+ "To demonstrate, let's rerun our custom test with some override scenarios. First, let's rerun our custom test with detection set to `all`, which will send the test results but not the test descriptions to the ValidMind Platform:"
]
},
{
@@ -409,15 +401,15 @@
"print(\"\\n=== Mode: all & unsafe=True ===\")\n",
"os.environ[\"VALIDMIND_PII_DETECTION\"] = \"all\"\n",
"\n",
- "# Run test and tag result with unique ID `override`\n",
+ "# Run test and tag result with unique ID `override_results`\n",
"try:\n",
- " result = run_test(\"pii_demo.PIIDetection:override\")\n",
+ " result = run_test(\"pii_demo.PIIDetection:override_results\")\n",
"\n",
" # Check if the test description was generated by LLM\n",
" if not result._was_description_generated:\n",
" print(\"PII detected: LLM-generated test description skipped\")\n",
" else:\n",
- " print(\"No PII detected, detection disabled, or override set: Test description generated by LLM\")\n",
+ " print(\"No PII detected or detection disabled: Test description generated by LLM\")\n",
"\n",
" # Try logging test results to the ValidMind Platform\n",
" result.log(unsafe=True)\n",
@@ -428,12 +420,37 @@
},
{
"cell_type": "markdown",
- "id": "310f69e1",
+ "id": "b2b4c7ab",
+ "metadata": {},
+ "source": [
+ "To send both the test descriptions and test results via override, set the `VALIDMIND_PII_DETECTION` environment variable to `test_results` while including the override flag:"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "id": "3aeef63b",
"metadata": {},
+ "outputs": [],
"source": [
- "#### Test only a subset*\n",
+ "print(\"\\n=== Mode: test_results & unsafe=True ===\")\n",
+ "os.environ[\"VALIDMIND_PII_DETECTION\"] = \"test_results\"\n",
+ "\n",
+ "# Run test and tag result with unique ID `override_both`\n",
+ "try:\n",
+ " result = run_test(\"pii_demo.PIIDetection:override_both\")\n",
"\n",
- "To test only a subset (tables or descriptions), adjust the test to emit only that type and re-run the mode loop:"
+ " # Check if the test description was generated by LLM\n",
+ " if not result._was_description_generated:\n",
+ " print(\"PII detected: LLM-generated test description skipped\")\n",
+ " else:\n",
+ " print(\"No PII detected or detection disabled: Test description generated by LLM\")\n",
+ "\n",
+ " # Try logging test results to the ValidMind Platform\n",
+ " result.log(unsafe=True)\n",
+ " print(\"No PII detected, detection disabled, or override set: Test results logged to the ValidMind Platform\")\n",
+ "except Exception as e:\n",
+ " print(\"PII detected: Test results not logged to the ValidMind Platform\")"
]
},
{
@@ -457,7 +474,8 @@
"\n",
" - `pii_demo.PIIDetection:disabled`\n",
" - `pii_demo.PIIDetection:desc_blocked`\n",
- " - `pii_demo.PIIDetection:override`"
+ " - `pii_demo.PIIDetection:override_results`\n",
+ " - `pii_demo.PIIDetection:override_both`"
]
},
{
From 688ac945541c2a5e8f11ce6b680d06d5aa3330e0 Mon Sep 17 00:00:00 2001
From: Beck <164545837+validbeck@users.noreply.github.com>
Date: Thu, 21 Aug 2025 13:57:04 -0700
Subject: [PATCH 30/37] hdgkj
---
notebooks/code_sharing/enable_pii_detection.ipynb | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/notebooks/code_sharing/enable_pii_detection.ipynb b/notebooks/code_sharing/enable_pii_detection.ipynb
index 30435bd57..7b32c6f8e 100644
--- a/notebooks/code_sharing/enable_pii_detection.ipynb
+++ b/notebooks/code_sharing/enable_pii_detection.ipynb
@@ -444,7 +444,7 @@
" if not result._was_description_generated:\n",
" print(\"PII detected: LLM-generated test description skipped\")\n",
" else:\n",
- " print(\"No PII detected or detection disabled: Test description generated by LLM\")\n",
+ " print(\"No PII detected, detection disabled, or override set: Test description generated by LLM\")\n",
"\n",
" # Try logging test results to the ValidMind Platform\n",
" result.log(unsafe=True)\n",
From c20853b7ffe2e08de5928c4dbf7b5e7f3d7959d5 Mon Sep 17 00:00:00 2001
From: Beck <164545837+validbeck@users.noreply.github.com>
Date: Thu, 21 Aug 2025 14:01:37 -0700
Subject: [PATCH 31/37] Proofreading
---
notebooks/code_sharing/enable_pii_detection.ipynb | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/notebooks/code_sharing/enable_pii_detection.ipynb b/notebooks/code_sharing/enable_pii_detection.ipynb
index 7b32c6f8e..56ac520e6 100644
--- a/notebooks/code_sharing/enable_pii_detection.ipynb
+++ b/notebooks/code_sharing/enable_pii_detection.ipynb
@@ -462,7 +462,7 @@
"\n",
"Now let's take a look at the results that were logged to the ValidMind Platform:\n",
"\n",
- "1. From the **Inventory** in the ValidMind Platform, go to the model you registered earlier. ([Need more help?](https://docs.validmind.ai/guide/model-inventory/working-with-model-inventory.html))\n",
+ "1. From the **Inventory** in the ValidMind Platform, go to the model you registered earlier.\n",
"\n",
"2. In the left sidebar that appears for your model, click **Documentation** under Documents.\n",
"\n",
From 28f5e7abebb5b00a857776ba1e1774cb85dee3a5 Mon Sep 17 00:00:00 2001
From: Beck <164545837+validbeck@users.noreply.github.com>
Date: Thu, 21 Aug 2025 14:22:57 -0700
Subject: [PATCH 32/37] Moving file
---
.../how_to/configure_pii_detection.ipynb | 189 ------------------
.../enable_pii_detection.ipynb | 0
2 files changed, 189 deletions(-)
delete mode 100644 notebooks/how_to/configure_pii_detection.ipynb
rename notebooks/{code_sharing => how_to}/enable_pii_detection.ipynb (100%)
diff --git a/notebooks/how_to/configure_pii_detection.ipynb b/notebooks/how_to/configure_pii_detection.ipynb
deleted file mode 100644
index e9461279b..000000000
--- a/notebooks/how_to/configure_pii_detection.ipynb
+++ /dev/null
@@ -1,189 +0,0 @@
-{
- "cells": [
- {
- "cell_type": "markdown",
- "metadata": {},
- "source": [
- "# PII Detection Modes with a Custom Test\n",
- "\n",
- "This notebook shows how to initialize ValidMind, implement a custom test that emits PII, and observe behavior differences under each `VALIDMIND_PII_DETECTION` mode when running the test with `validmind.tests.run_test`.\n"
- ]
- },
- {
- "cell_type": "markdown",
- "metadata": {},
- "source": [
- "## Prerequisites\n",
- "\n",
- "- `validmind` installed with PII extras:\n",
- "\n",
- "```bash\n",
- "%pip install -q validmind[pii-detection]\n",
- "```\n",
- "\n",
- "- A ValidMind model registered. We'll initialize the library using your model snippet.\n"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "metadata": {},
- "outputs": [],
- "source": [
- "%pip install -q \"validmind[pii-detection]\""
- ]
- },
- {
- "cell_type": "markdown",
- "metadata": {},
- "source": [
- "## Initialize ValidMind\n",
- "\n",
- "Initialize using your model code snippet or a `.env` file, as shown in other quickstarts.\n"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "metadata": {},
- "outputs": [],
- "source": [
- "# Load your model identifier credentials from an `.env` file\n",
- "%load_ext dotenv\n",
- "%dotenv .env\n",
- "\n",
- "# Or initialize with your code snippet\n",
- "import validmind as vm\n",
- "\n",
- "vm.init(\n",
- " # api_host=\"...\",\n",
- " # api_key=\"...\",\n",
- " # api_secret=\"...\",\n",
- " # model=\"...\",\n",
- ")"
- ]
- },
- {
- "cell_type": "markdown",
- "metadata": {},
- "source": [
- "## Create a custom test that emits PII\n",
- "\n",
- "We'll create a custom test that returns:\n",
- "- A description string containing PII (name, email, phone)\n",
- "- A small table containing PII in columns\n",
- "\n",
- "This mirrors the structure used in other custom test notebooks and will exercise both table and description PII detection paths.\n"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "metadata": {},
- "outputs": [],
- "source": [
- "import pandas as pd\n",
- "\n",
- "from validmind import test\n",
- "\n",
- "@test(\"my_pii_demo.PIIEmittingTest\")\n",
- "def pii_emitting_test():\n",
- " \"\"\"A demo test that returns PII\"\"\"\n",
- " return pd.DataFrame(\n",
- " {\n",
- " \"name\": [\"Jane Smith\", \"John Doe\", \"Alice Johnson\"],\n",
- " \"email\": [\n",
- " \"jane.smith@bank.example\",\n",
- " \"john.doe@company.example\",\n",
- " \"alice.johnson@service.example\",\n",
- " ],\n",
- " \"phone\": [\"(212) 555-9876\", \"(415) 555-1234\", \"(646) 555-5678\"],\n",
- " }\n",
- " )"
- ]
- },
- {
- "cell_type": "markdown",
- "metadata": {},
- "source": [
- "## Run the test under different PII detection modes\n",
- "\n",
- "We'll switch `VALIDMIND_PII_DETECTION` across modes and run the same test with `validmind.tests.run_test`. We catch exceptions to observe blocking behavior.\n"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "metadata": {},
- "outputs": [],
- "source": [
- "import os\n",
- "from validmind.tests import run_test\n",
- "\n",
- "MODES = [\"disabled\", \"test_results\", \"test_descriptions\", \"all\"]\n",
- "\n",
- "for mode in MODES:\n",
- " print(\"\\n=== Mode:\", mode, \"===\")\n",
- " os.environ[\"VALIDMIND_PII_DETECTION\"] = mode\n",
- " try:\n",
- " result = run_test(\"my_pii_demo.PIIEmittingTest\")\n",
- "\n",
- " # check if the description was generated\n",
- " if not result._was_description_generated:\n",
- " print(\"Blocked: Test Description Generation was not run due to PII\")\n",
- " else:\n",
- " print(\"Description was generated by LLM\")\n",
- "\n",
- " # Try logging (this triggers PII checks before upload)\n",
- " result.log()\n",
- " print(\"Logging to API succeeded\")\n",
- " except Exception as e:\n",
- " print(\"Blocked: Test Result was not logged due to PII\")\n",
- " # print(e)"
- ]
- },
- {
- "cell_type": "markdown",
- "metadata": {},
- "source": [
- "### Expected behavior by mode\n",
- "\n",
- "- disabled: No PII checks.\n",
- "- test_results: Description is generated but result is not logged.\n",
- "- test_descriptions: Description generation is blocked but result is logged.\n",
- "- all: Description generation and logging are both blocked.\n"
- ]
- },
- {
- "cell_type": "markdown",
- "metadata": {},
- "source": [
- "## Notes\n",
- "\n",
- "- If you see warnings that Presidio is unavailable, ensure you installed extras: `validmind[pii-detection]`.\n",
- "- You can override blocking by passing `unsafe=True` to `result.log(unsafe=True)`, but this is not recommended outside controlled workflows.\n"
- ]
- }
- ],
- "metadata": {
- "kernelspec": {
- "display_name": ".venv",
- "language": "python",
- "name": "python3"
- },
- "language_info": {
- "codemirror_mode": {
- "name": "ipython",
- "version": 3
- },
- "file_extension": ".py",
- "mimetype": "text/x-python",
- "name": "python",
- "nbconvert_exporter": "python",
- "pygments_lexer": "ipython3",
- "version": "3.12.11"
- }
- },
- "nbformat": 4,
- "nbformat_minor": 2
-}
diff --git a/notebooks/code_sharing/enable_pii_detection.ipynb b/notebooks/how_to/enable_pii_detection.ipynb
similarity index 100%
rename from notebooks/code_sharing/enable_pii_detection.ipynb
rename to notebooks/how_to/enable_pii_detection.ipynb
From 150304144cc5b636162c9d7f183a14861d769013 Mon Sep 17 00:00:00 2001
From: Beck <164545837+validbeck@users.noreply.github.com>
Date: Thu, 21 Aug 2025 14:24:32 -0700
Subject: [PATCH 33/37] Edit
---
notebooks/how_to/enable_pii_detection.ipynb | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/notebooks/how_to/enable_pii_detection.ipynb b/notebooks/how_to/enable_pii_detection.ipynb
index 56ac520e6..7e97a93a5 100644
--- a/notebooks/how_to/enable_pii_detection.ipynb
+++ b/notebooks/how_to/enable_pii_detection.ipynb
@@ -5,7 +5,7 @@
"id": "dd37d6f9",
"metadata": {},
"source": [
- "# Enable PII detection in test results"
+ "# Enable PII detection in tests"
]
},
{
From b5c7bae32bf93d35eaeab7a2e52fe528797748af Mon Sep 17 00:00:00 2001
From: Beck <164545837+validbeck@users.noreply.github.com>
Date: Thu, 21 Aug 2025 14:24:50 -0700
Subject: [PATCH 34/37] UGH
---
notebooks/how_to/enable_pii_detection.ipynb | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/notebooks/how_to/enable_pii_detection.ipynb b/notebooks/how_to/enable_pii_detection.ipynb
index 7e97a93a5..08db8cd6a 100644
--- a/notebooks/how_to/enable_pii_detection.ipynb
+++ b/notebooks/how_to/enable_pii_detection.ipynb
@@ -13,7 +13,7 @@
"id": "d4721b73",
"metadata": {},
"source": [
- "Learn how to enable and configure Personally Identifiable Information (PII) detection when generating test results with the ValidMind Library. Choose whether or not to include PII in test descriptions generated, or whether or not to include PII in test results logged to the ValidMind Platform."
+ "Learn how to enable and configure Personally Identifiable Information (PII) detection when running test results with the ValidMind Library. Choose whether or not to include PII in test descriptions generated, or whether or not to include PII in test results logged to the ValidMind Platform."
]
},
{
From 1c467f0984019a0536afd796bdf89716714accd5 Mon Sep 17 00:00:00 2001
From: Beck <164545837+validbeck@users.noreply.github.com>
Date: Thu, 21 Aug 2025 14:25:00 -0700
Subject: [PATCH 35/37] sdjfksd
---
notebooks/how_to/enable_pii_detection.ipynb | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/notebooks/how_to/enable_pii_detection.ipynb b/notebooks/how_to/enable_pii_detection.ipynb
index 08db8cd6a..208f37d21 100644
--- a/notebooks/how_to/enable_pii_detection.ipynb
+++ b/notebooks/how_to/enable_pii_detection.ipynb
@@ -13,7 +13,7 @@
"id": "d4721b73",
"metadata": {},
"source": [
- "Learn how to enable and configure Personally Identifiable Information (PII) detection when running test results with the ValidMind Library. Choose whether or not to include PII in test descriptions generated, or whether or not to include PII in test results logged to the ValidMind Platform."
+ "Learn how to enable and configure Personally Identifiable Information (PII) detection when running tests with the ValidMind Library. Choose whether or not to include PII in test descriptions generated, or whether or not to include PII in test results logged to the ValidMind Platform."
]
},
{
From b80f9479077a17b651a77b7254e8bd77cea70ea5 Mon Sep 17 00:00:00 2001
From: Beck <164545837+validbeck@users.noreply.github.com>
Date: Thu, 21 Aug 2025 14:26:27 -0700
Subject: [PATCH 36/37] ToC
---
notebooks/how_to/enable_pii_detection.ipynb | 133 +++++++++++++++-----
1 file changed, 99 insertions(+), 34 deletions(-)
diff --git a/notebooks/how_to/enable_pii_detection.ipynb b/notebooks/how_to/enable_pii_detection.ipynb
index 208f37d21..910cb0e19 100644
--- a/notebooks/how_to/enable_pii_detection.ipynb
+++ b/notebooks/how_to/enable_pii_detection.ipynb
@@ -2,7 +2,7 @@
"cells": [
{
"cell_type": "markdown",
- "id": "dd37d6f9",
+ "id": "766eb526",
"metadata": {},
"source": [
"# Enable PII detection in tests"
@@ -10,7 +10,7 @@
},
{
"cell_type": "markdown",
- "id": "d4721b73",
+ "id": "fec7c460",
"metadata": {},
"source": [
"Learn how to enable and configure Personally Identifiable Information (PII) detection when running tests with the ValidMind Library. Choose whether or not to include PII in test descriptions generated, or whether or not to include PII in test results logged to the ValidMind Platform."
@@ -18,9 +18,49 @@
},
{
"cell_type": "markdown",
- "id": "about-intro-85b40b47-34c7-4da4-b0e7-c491341a9f20",
+ "id": "fb872491",
+ "metadata": {},
+ "source": [
+ "::: {.content-hidden when-format=\"html\"}\n",
+ "## Contents \n",
+ "- [About ValidMind](#toc1__) \n",
+ " - [Before you begin](#toc1_1__) \n",
+ " - [New to ValidMind?](#toc1_2__) \n",
+ " - [Key concepts](#toc1_3__) \n",
+ "- [Setting up](#toc2__) \n",
+ " - [Install the ValidMind Library with PII detection](#toc2_1__) \n",
+ " - [Initialize the ValidMind Library](#toc2_2__) \n",
+ " - [Get your code snippet](#toc2_2_1__) \n",
+ "- [Using PII detection](#toc3__) \n",
+ " - [Create a custom test that outputs PII](#toc3_1__) \n",
+ " - [Run test under different PII detection modes](#toc3_2__) \n",
+ " - [disabled](#toc3_2_1__) \n",
+ " - [test_results](#toc3_2_2__) \n",
+ " - [test_descriptions](#toc3_2_3__) \n",
+ " - [all](#toc3_2_4__) \n",
+ " - [Override detection](#toc3_3__) \n",
+ " - [Review logged test results](#toc3_4__) \n",
+ "- [Troubleshooting](#toc4__) \n",
+ "- [Learn more](#toc5__) \n",
+ "\n",
+ ":::\n",
+ "\n",
+ ""
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "id": "3df66161",
"metadata": {},
"source": [
+ "
\n",
+ "\n",
"## About ValidMind\n",
"\n",
"ValidMind is a suite of tools for managing model risk, including risk associated with AI and statistical models. \n",
@@ -30,9 +70,11 @@
},
{
"cell_type": "markdown",
- "id": "about-begin-c86ec11e-4e52-4799-bf11-fea595c2671e",
+ "id": "3231a54b",
"metadata": {},
"source": [
+ "
\n",
+ "\n",
"### Before you begin\n",
"\n",
"This notebook assumes you have basic familiarity with Python, including an understanding of how functions work. If you are new to Python, you can still run the notebook but we recommend further familiarizing yourself with the language. \n",
@@ -42,9 +84,11 @@
},
{
"cell_type": "markdown",
- "id": "about-signup-db4c0a03-ea37-4e81-b417-2e79eed1bc53",
+ "id": "035c6116",
"metadata": {},
"source": [
+ "
\n",
+ "\n",
"### New to ValidMind?\n",
"\n",
"If you haven't already seen our documentation on the [ValidMind Library](https://docs.validmind.ai/developer/validmind-library.html), we recommend you begin by exploring the available resources in this section. There, you can learn more about documenting models and running tests, as well as find code samples and our Python Library API reference.\n",
@@ -56,9 +100,11 @@
},
{
"cell_type": "markdown",
- "id": "about-concepts-fd7b60a6-60a8-420a-8ec2-287874cae377",
+ "id": "2325efaf",
"metadata": {},
"source": [
+ "
\n",
+ "\n",
"### Key concepts\n",
"\n",
"**Model documentation**: A structured and detailed record pertaining to a model, encompassing key components such as its underlying assumptions, methodologies, data sources, inputs, performance metrics, evaluations, limitations, and intended uses. It serves to ensure transparency, adherence to regulatory requirements, and a clear understanding of potential risks associated with the model’s application.\n",
@@ -89,17 +135,20 @@
},
{
"cell_type": "markdown",
- "id": "33f87f48",
+ "id": "279d6958",
"metadata": {},
"source": [
+ "
\n",
+ "\n",
"## Setting up"
]
},
{
"cell_type": "markdown",
- "id": "install-library-f5c5d59c-e356-4f22-a71e-d0c84c269273",
"metadata": {},
"source": [
+ "
\n",
+ "\n",
"### Install the ValidMind Library with PII detection\n",
"\n",
"
Recommended Python versions\n",
@@ -112,7 +161,7 @@
{
"cell_type": "code",
"execution_count": null,
- "id": "install-python-6511976a-8cb2-423d-bfbf-a6e39cc90e4a",
+ "id": "b830ae91",
"metadata": {},
"outputs": [],
"source": [
@@ -121,9 +170,11 @@
},
{
"cell_type": "markdown",
- "id": "install-initialize-e13c0197-f742-453c-9422-ebae53ddcf68",
+ "id": "1d15779d",
"metadata": {},
"source": [
+ "
\n",
+ "\n",
"### Initialize the ValidMind Library\n",
"\n",
"ValidMind generates a unique _code snippet_ for each registered model to connect with your developer environment. You initialize the ValidMind Library with this code snippet, which ensures that your documentation and tests are uploaded to the correct model when you run the notebook."
@@ -131,9 +182,10 @@
},
{
"cell_type": "markdown",
- "id": "install-snippet-dc2c3a8b-a2d8-4632-84f9-bb5c9dd8721c",
"metadata": {},
"source": [
+ "
\n",
+ "\n",
"#### Get your code snippet\n",
"\n",
"1. In a browser, [log in to ValidMind](https://docs.validmind.ai/guide/configuration/log-in-to-validmind.html).\n",
@@ -150,7 +202,7 @@
{
"cell_type": "code",
"execution_count": null,
- "id": "install-init-43c8827f-b023-4324-be38-c58c999d4575",
+ "id": "eeda4c8c",
"metadata": {},
"outputs": [],
"source": [
@@ -173,17 +225,20 @@
},
{
"cell_type": "markdown",
- "id": "9296d9c8",
+ "id": "4acf7d3c",
"metadata": {},
"source": [
+ "
\n",
+ "\n",
"## Using PII detection"
]
},
{
"cell_type": "markdown",
- "id": "a5cb8d86",
"metadata": {},
"source": [
+ "
\n",
+ "\n",
"### Create a custom test that outputs PII\n",
"\n",
"To demonstrate the feature, we'll need a test that outputs PII. First we'll create a custom test that returns:\n",
@@ -197,7 +252,7 @@
{
"cell_type": "code",
"execution_count": null,
- "id": "6452da1f",
+ "id": "04d8c802",
"metadata": {},
"outputs": [],
"source": [
@@ -224,7 +279,7 @@
},
{
"cell_type": "markdown",
- "id": "e210b665",
+ "id": "57a011d9",
"metadata": {},
"source": [
"
Want to learn more about custom tests?\n",
@@ -234,9 +289,10 @@
},
{
"cell_type": "markdown",
- "id": "f3e47f7a",
"metadata": {},
"source": [
+ "
\n",
+ "\n",
"### Run test under different PII detection modes\n",
"\n",
"Next, let's import [the `run_test` function](https://docs.validmind.ai/validmind/validmind/tests.html#run_test) provided by the `validmind.tests` module to run our custom test via a function called `run_pii_test()` that catches exceptions to observe blocking behavior when PII is present:"
@@ -245,7 +301,7 @@
{
"cell_type": "code",
"execution_count": null,
- "id": "ef7c2b50",
+ "id": "b42288e5",
"metadata": {},
"outputs": [],
"source": [
@@ -273,7 +329,7 @@
},
{
"cell_type": "markdown",
- "id": "e349b5f5",
+ "id": "5bf99fc0",
"metadata": {},
"source": [
"We'll then switch the `VALIDMIND_PII_DETECTION` environment variable across modes in the below examples.\n",
@@ -285,9 +341,10 @@
},
{
"cell_type": "markdown",
- "id": "b39d6c1e",
"metadata": {},
"source": [
+ "
\n",
+ "\n",
"#### disabled\n",
"\n",
"When detection is set to `disabled`, tests run and generate test descriptions. Logging tests with [`.log()`](https://docs.validmind.ai/validmind/validmind/vm_models.html#TestResult.log) will also send test descriptions and test results to the ValidMind Platform as usual:"
@@ -296,7 +353,7 @@
{
"cell_type": "code",
"execution_count": null,
- "id": "0c6cbcba",
+ "id": "3078af64",
"metadata": {},
"outputs": [],
"source": [
@@ -309,9 +366,10 @@
},
{
"cell_type": "markdown",
- "id": "dcaf5605",
"metadata": {},
"source": [
+ "
\n",
+ "\n",
"#### test_results\n",
"\n",
"When detection is set for `test_results`, tests run and generate test descriptions for review in your environment, but logging tests will not send descriptions or test results to the ValidMind Platform:"
@@ -320,7 +378,7 @@
{
"cell_type": "code",
"execution_count": null,
- "id": "06c3f4f9",
+ "id": "12e61a80",
"metadata": {},
"outputs": [],
"source": [
@@ -333,9 +391,10 @@
},
{
"cell_type": "markdown",
- "id": "808f95fb",
"metadata": {},
"source": [
+ "
\n",
+ "\n",
"#### test_descriptions\n",
"\n",
"When detection is set for `test_descriptions`, tests run but will not generate test descriptions, and logging tests will not send descriptions but will send test results to the ValidMind Platform:"
@@ -344,7 +403,7 @@
{
"cell_type": "code",
"execution_count": null,
- "id": "46636a1c",
+ "id": "feba6207",
"metadata": {},
"outputs": [],
"source": [
@@ -357,9 +416,10 @@
},
{
"cell_type": "markdown",
- "id": "6121b341",
"metadata": {},
"source": [
+ "
\n",
+ "\n",
"#### all\n",
"\n",
"When detection is set to `all`, tests run will not generate test descriptions or log test results to the ValidMind Platform."
@@ -368,7 +428,7 @@
{
"cell_type": "code",
"execution_count": null,
- "id": "cb627f9a",
+ "id": "af5040b5",
"metadata": {},
"outputs": [],
"source": [
@@ -381,9 +441,10 @@
},
{
"cell_type": "markdown",
- "id": "284e69e5",
"metadata": {},
"source": [
+ "
\n",
+ "\n",
"### Override detection\n",
"\n",
"You can override blocking by passing `unsafe=True` to `result.log(unsafe=True)`, but this is not recommended outside controlled workflows.\n",
@@ -394,7 +455,7 @@
{
"cell_type": "code",
"execution_count": null,
- "id": "c8dac20b",
+ "id": "0387be21",
"metadata": {},
"outputs": [],
"source": [
@@ -420,7 +481,6 @@
},
{
"cell_type": "markdown",
- "id": "b2b4c7ab",
"metadata": {},
"source": [
"To send both the test descriptions and test results via override, set the `VALIDMIND_PII_DETECTION` environment variable to `test_results` while including the override flag:"
@@ -429,7 +489,7 @@
{
"cell_type": "code",
"execution_count": null,
- "id": "3aeef63b",
+ "id": "b40a2670",
"metadata": {},
"outputs": [],
"source": [
@@ -455,9 +515,11 @@
},
{
"cell_type": "markdown",
- "id": "9ab973f2",
+ "id": "7704a4c5",
"metadata": {},
"source": [
+ "
\n",
+ "\n",
"### Review logged test results\n",
"\n",
"Now let's take a look at the results that were logged to the ValidMind Platform:\n",
@@ -480,9 +542,11 @@
},
{
"cell_type": "markdown",
- "id": "53a1a62d",
+ "id": "ac2922dd",
"metadata": {},
"source": [
+ "
\n",
+ "\n",
"## Troubleshooting\n",
"\n",
"- [x] If you see warnings that Presidio or Presidio analyzer is unavailable, ensure you installed extras: `validmind[pii-detection]`.\n",
@@ -491,9 +555,10 @@
},
{
"cell_type": "markdown",
- "id": "next-resources-c5b44493-85c8-491b-8eaa-d1bdfd81bc86",
"metadata": {},
"source": [
+ "
\n",
+ "\n",
"## Learn more\n",
"\n",
"We offer many interactive notebooks to help you document models:\n",
From f2cf7492ffaf9cae51d9b399bb5f3794c2f559af Mon Sep 17 00:00:00 2001
From: Beck <164545837+validbeck@users.noreply.github.com>
Date: Thu, 21 Aug 2025 14:29:29 -0700
Subject: [PATCH 37/37] Blah
---
notebooks/how_to/enable_pii_detection.ipynb | 59 +++++++++++++++------
1 file changed, 44 insertions(+), 15 deletions(-)
diff --git a/notebooks/how_to/enable_pii_detection.ipynb b/notebooks/how_to/enable_pii_detection.ipynb
index 910cb0e19..a7e123286 100644
--- a/notebooks/how_to/enable_pii_detection.ipynb
+++ b/notebooks/how_to/enable_pii_detection.ipynb
@@ -2,7 +2,7 @@
"cells": [
{
"cell_type": "markdown",
- "id": "766eb526",
+ "id": "f5b060b7",
"metadata": {},
"source": [
"# Enable PII detection in tests"
@@ -10,7 +10,7 @@
},
{
"cell_type": "markdown",
- "id": "fec7c460",
+ "id": "403b35b1",
"metadata": {},
"source": [
"Learn how to enable and configure Personally Identifiable Information (PII) detection when running tests with the ValidMind Library. Choose whether or not to include PII in test descriptions generated, or whether or not to include PII in test results logged to the ValidMind Platform."
@@ -18,7 +18,7 @@
},
{
"cell_type": "markdown",
- "id": "fb872491",
+ "id": "1f0a64f3",
"metadata": {},
"source": [
"::: {.content-hidden when-format=\"html\"}\n",
@@ -39,6 +39,8 @@
" - [test_descriptions](#toc3_2_3__) \n",
" - [all](#toc3_2_4__) \n",
" - [Override detection](#toc3_3__) \n",
+ " - [Override test result logging](#toc3_3_1__) \n",
+ " - [Override test descriptions and test result logging](#toc3_3_2__) \n",
" - [Review logged test results](#toc3_4__) \n",
"- [Troubleshooting](#toc4__) \n",
"- [Learn more](#toc5__) \n",
@@ -56,7 +58,7 @@
},
{
"cell_type": "markdown",
- "id": "3df66161",
+ "id": "68cf8398",
"metadata": {},
"source": [
"
\n",
@@ -70,7 +72,7 @@
},
{
"cell_type": "markdown",
- "id": "3231a54b",
+ "id": "ba6bd554",
"metadata": {},
"source": [
"
\n",
@@ -84,7 +86,7 @@
},
{
"cell_type": "markdown",
- "id": "035c6116",
+ "id": "ac231640",
"metadata": {},
"source": [
"
\n",
@@ -100,7 +102,7 @@
},
{
"cell_type": "markdown",
- "id": "2325efaf",
+ "id": "75626c3d",
"metadata": {},
"source": [
"
\n",
@@ -135,7 +137,7 @@
},
{
"cell_type": "markdown",
- "id": "279d6958",
+ "id": "ee06fdea",
"metadata": {},
"source": [
"
\n",
@@ -145,6 +147,7 @@
},
{
"cell_type": "markdown",
+ "id": "1343e1dd",
"metadata": {},
"source": [
"
\n",
@@ -170,7 +173,7 @@
},
{
"cell_type": "markdown",
- "id": "1d15779d",
+ "id": "b5eae826",
"metadata": {},
"source": [
"
\n",
@@ -182,6 +185,7 @@
},
{
"cell_type": "markdown",
+ "id": "e6cc7cd2",
"metadata": {},
"source": [
"
\n",
@@ -225,7 +229,7 @@
},
{
"cell_type": "markdown",
- "id": "4acf7d3c",
+ "id": "5676cd64",
"metadata": {},
"source": [
"
\n",
@@ -235,6 +239,7 @@
},
{
"cell_type": "markdown",
+ "id": "120644e3",
"metadata": {},
"source": [
"
\n",
@@ -279,7 +284,7 @@
},
{
"cell_type": "markdown",
- "id": "57a011d9",
+ "id": "a8ab74cd",
"metadata": {},
"source": [
"
Want to learn more about custom tests?\n",
@@ -289,6 +294,7 @@
},
{
"cell_type": "markdown",
+ "id": "7d2110d3",
"metadata": {},
"source": [
"
\n",
@@ -329,7 +335,7 @@
},
{
"cell_type": "markdown",
- "id": "5bf99fc0",
+ "id": "e3c82205",
"metadata": {},
"source": [
"We'll then switch the `VALIDMIND_PII_DETECTION` environment variable across modes in the below examples.\n",
@@ -341,6 +347,7 @@
},
{
"cell_type": "markdown",
+ "id": "543b08dc",
"metadata": {},
"source": [
"
\n",
@@ -366,6 +373,7 @@
},
{
"cell_type": "markdown",
+ "id": "490c397c",
"metadata": {},
"source": [
"
\n",
@@ -391,6 +399,7 @@
},
{
"cell_type": "markdown",
+ "id": "c21de2bb",
"metadata": {},
"source": [
"
\n",
@@ -416,6 +425,7 @@
},
{
"cell_type": "markdown",
+ "id": "0e3c9f24",
"metadata": {},
"source": [
"
\n",
@@ -441,6 +451,7 @@
},
{
"cell_type": "markdown",
+ "id": "e30c0ccd",
"metadata": {},
"source": [
"
\n",
@@ -449,7 +460,19 @@
"\n",
"You can override blocking by passing `unsafe=True` to `result.log(unsafe=True)`, but this is not recommended outside controlled workflows.\n",
"\n",
- "To demonstrate, let's rerun our custom test with some override scenarios. First, let's rerun our custom test with detection set to `all`, which will send the test results but not the test descriptions to the ValidMind Platform:"
+ "To demonstrate, let's rerun our custom test with some override scenarios."
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "id": "6b5b2df9",
+ "metadata": {},
+ "source": [
+ "
\n",
+ "\n",
+ "#### Override test result logging\n",
+ "\n",
+ "First, let's rerun our custom test with detection set to `all`, which will send the test results but not the test descriptions to the ValidMind Platform:"
]
},
{
@@ -481,8 +504,13 @@
},
{
"cell_type": "markdown",
+ "id": "a11072fb",
"metadata": {},
"source": [
+ "
\n",
+ "\n",
+ "#### Override test descriptions and test result logging\n",
+ "\n",
"To send both the test descriptions and test results via override, set the `VALIDMIND_PII_DETECTION` environment variable to `test_results` while including the override flag:"
]
},
@@ -515,7 +543,7 @@
},
{
"cell_type": "markdown",
- "id": "7704a4c5",
+ "id": "017ff3ed",
"metadata": {},
"source": [
"
\n",
@@ -542,7 +570,7 @@
},
{
"cell_type": "markdown",
- "id": "ac2922dd",
+ "id": "e60ecaf4",
"metadata": {},
"source": [
"
\n",
@@ -555,6 +583,7 @@
},
{
"cell_type": "markdown",
+ "id": "7e0641e1",
"metadata": {},
"source": [
"
\n",