From e22acaa3200ddc2ee3857e00ed9856cb2100499c Mon Sep 17 00:00:00 2001
From: Beck <164545837+validbeck@users.noreply.github.com>
Date: Tue, 31 Dec 2024 15:15:13 -0800
Subject: [PATCH 01/38] Stole templates from documentation repo
---
notebooks/templates/about-validmind.ipynb | 63 ++++++++++++++++
.../install-initialize-validmind.ipynb | 75 +++++++++++++++++++
notebooks/templates/next-steps.ipynb | 70 +++++++++++++++++
notebooks/templates/upgrade-validmind.ipynb | 53 +++++++++++++
4 files changed, 261 insertions(+)
create mode 100644 notebooks/templates/about-validmind.ipynb
create mode 100644 notebooks/templates/install-initialize-validmind.ipynb
create mode 100644 notebooks/templates/next-steps.ipynb
create mode 100644 notebooks/templates/upgrade-validmind.ipynb
diff --git a/notebooks/templates/about-validmind.ipynb b/notebooks/templates/about-validmind.ipynb
new file mode 100644
index 000000000..e2d202ffb
--- /dev/null
+++ b/notebooks/templates/about-validmind.ipynb
@@ -0,0 +1,63 @@
+{
+ "cells": [
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## About ValidMind\n",
+ "\n",
+ "ValidMind is a suite of tools for managing model risk, including risk associated with AI and statistical models. \n",
+ "\n",
+ "You use the ValidMind Library to automate documentation and validation tests, and then use the ValidMind Platform to collaborate on model documentation. Together, these products simplify model risk management, facilitate compliance with regulations and institutional standards, and enhance collaboration between yourself and model validators.\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",
+ "\n",
+ "If you encounter errors due to missing modules in your Python environment, install the modules with `pip install`, and then re-run the notebook. For more help, refer to [Installing Python Modules](https://docs.python.org/3/installing/index.html).\n",
+ "\n",
+ "### New to ValidMind?\n",
+ "\n",
+ "If you haven't already seen our [Get started with the ValidMind Library](https://docs.validmind.ai/guide/get-started-validmind-library.html), we recommend you explore the available resources for developers at some point. There, you can learn more about documenting models, find code samples, or read our developer reference.\n",
+ "\n",
+ "
For access to all features available in this notebook, create a free ValidMind account.\n",
+ "
\n",
+ "Signing up is FREE —
Register with ValidMind \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",
+ "\n",
+ "**Documentation template**: Functions as a test suite and lays out the structure of model documentation, segmented into various sections and sub-sections. Documentation templates define the structure of your model documentation, specifying the tests that should be run, and how the results should be displayed.\n",
+ "\n",
+ "**Tests**: A function contained in the ValidMind Library, designed to run a specific quantitative test on the dataset or model. Tests are the building blocks of ValidMind, used to evaluate and document models and datasets, and can be run individually or as part of a suite defined by your model documentation template.\n",
+ "\n",
+ "**Metrics**: A subset of tests that do not have thresholds. In the context of this notebook, metrics and tests can be thought of as interchangeable concepts.\n",
+ "\n",
+ "**Custom metrics**: Custom metrics are functions that you define to evaluate your model or dataset. These functions can be registered with the ValidMind Library to be used in the ValidMind Platform.\n",
+ "\n",
+ "**Inputs**: Objects to be evaluated and documented in the ValidMind Library. They can be any of the following:\n",
+ "\n",
+ " - **model**: A single model that has been initialized in ValidMind with [`vm.init_model()`](/validmind/validmind.html#init_model).\n",
+ " - **dataset**: Single dataset that has been initialized in ValidMind with [`vm.init_dataset()`](/validmind/validmind.html#init_dataset).\n",
+ " - **models**: A list of ValidMind models - usually this is used when you want to compare multiple models in your custom metric.\n",
+ " - **datasets**: A list of ValidMind datasets - usually this is used when you want to compare multiple datasets in your custom metric. See this [example](/notebooks/how_to/run_tests_that_require_multiple_datasets.ipynb) for more information.\n",
+ "\n",
+ "**Parameters**: Additional arguments that can be passed when running a ValidMind test, used to pass additional information to a metric, customize its behavior, or provide additional context.\n",
+ "\n",
+ "**Outputs**: Custom metrics can return elements like tables or plots. Tables may be a list of dictionaries (each representing a row) or a pandas DataFrame. Plots may be matplotlib or plotly figures.\n",
+ "\n",
+ "**Test suites**: Collections of tests designed to run together to automate and generate model documentation end-to-end for specific use-cases.\n",
+ "\n",
+ "Example: the [`classifier_full_suite`](/validmind/validmind/test_suites/classifier.html#ClassifierFullSuite) test suite runs tests from the [`tabular_dataset`](/validmind/validmind/test_suites/tabular_datasets.html) and [`classifier`](/validmind/validmind/test_suites/classifier.html) test suites to fully document the data and model sections for binary classification model use-cases."
+ ]
+ }
+ ],
+ "metadata": {
+ "language_info": {
+ "name": "python"
+ }
+ },
+ "nbformat": 4,
+ "nbformat_minor": 2
+}
diff --git a/notebooks/templates/install-initialize-validmind.ipynb b/notebooks/templates/install-initialize-validmind.ipynb
new file mode 100644
index 000000000..bf7c62b2a
--- /dev/null
+++ b/notebooks/templates/install-initialize-validmind.ipynb
@@ -0,0 +1,75 @@
+{
+ "cells": [
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Install the ValidMind Library\n",
+ "\n",
+ "To install the library:"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "%pip install -q validmind"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## 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.\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",
+ "\n",
+ "2. In the left sidebar, navigate to **Model Inventory** and click **+ Register new model**.\n",
+ "\n",
+ "3. Enter the model details and click **Continue**. ([Need more help?](https://docs.validmind.ai/guide/model-inventory/register-models-in-inventory.html))\n",
+ "\n",
+ " For example, to register a model for use with this notebook, select:\n",
+ "\n",
+ " - Documentation template: `Template name here`\n",
+ " - Use case: `Use case here`\n",
+ "\n",
+ " You can fill in other options according to your preference.\n",
+ "\n",
+ "4. Go to **Getting Started** and click **Copy snippet to clipboard**.\n",
+ "\n",
+ "Next, replace this placeholder with your own code snippet:\n"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "# Replace with your code snippet\n",
+ "\n",
+ "import validmind as vm\n",
+ "\n",
+ "vm.init(\n",
+ " api_host=\"https://api.prod.validmind.ai/api/v1/tracking\",\n",
+ " api_key=\"...\",\n",
+ " api_secret=\"...\",\n",
+ " model=\"...\",\n",
+ ")"
+ ]
+ }
+ ],
+ "metadata": {
+ "language_info": {
+ "name": "python"
+ }
+ },
+ "nbformat": 4,
+ "nbformat_minor": 2
+}
diff --git a/notebooks/templates/next-steps.ipynb b/notebooks/templates/next-steps.ipynb
new file mode 100644
index 000000000..45bf565db
--- /dev/null
+++ b/notebooks/templates/next-steps.ipynb
@@ -0,0 +1,70 @@
+{
+ "cells": [
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Next steps\n",
+ "\n",
+ "You can look at the output produced by the ValidMind Library right in the notebook where you ran the code, as you would expect. But there is a better way: use the ValidMind Platform to work with your model documentation.\n",
+ "\n",
+ "### Work with your model documentation\n",
+ "\n",
+ "1. From the **Model 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. Click and expand the **Model Development** section.\n",
+ "\n",
+ "What you see is the full draft of your model documentation in a more easily consumable version. From here, you can make qualitative edits to model documentation, view guidelines, collaborate with validators, and submit your model documentation for approval when it's ready. [Learn more ...](https://docs.validmind.ai/guide/working-with-model-documentation.html)\n",
+ "\n",
+ "### Discover more learning resources\n",
+ "\n",
+ "We offer many interactive notebooks to help you document models:\n",
+ "\n",
+ "- [Run tests & test suites](https://docs.validmind.ai/guide/testing-overview.html)\n",
+ "- [Code samples](https://docs.validmind.ai/guide/samples-jupyter-notebooks.html)\n",
+ "\n",
+ "Or, visit our [documentation](https://docs.validmind.ai/) to learn more about ValidMind."
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Upgrade ValidMind\n",
+ "\n",
+ "After installing ValidMind, you’ll want to periodically make sure you are on the latest version to access any new features and other enhancements.
\n",
+ "\n",
+ "Retrieve the information for the currently installed version of ValidMind:"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "%pip show validmind"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "If the version returned is lower than the version indicated in our [production open-source code](https://github.com/validmind/developer-framework/blob/prod/validmind/__version__.py), restart your notebook and run:\n",
+ "\n",
+ "```bash\n",
+ "%pip install --upgrade validmind\n",
+ "```\n",
+ "\n",
+ "You may need to restart your kernel after running the upgrade package for changes to be applied."
+ ]
+ }
+ ],
+ "metadata": {
+ "language_info": {
+ "name": "python"
+ }
+ },
+ "nbformat": 4,
+ "nbformat_minor": 2
+}
diff --git a/notebooks/templates/upgrade-validmind.ipynb b/notebooks/templates/upgrade-validmind.ipynb
new file mode 100644
index 000000000..6a630aa50
--- /dev/null
+++ b/notebooks/templates/upgrade-validmind.ipynb
@@ -0,0 +1,53 @@
+{
+ "cells": [
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Upgrade ValidMind\n",
+ "\n",
+ "After installing ValidMind, you’ll want to periodically make sure you are on the latest version to access any new features and other enhancements.
\n",
+ "\n",
+ "Retrieve the information for the currently installed version of ValidMind:"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "vscode": {
+ "languageId": "plaintext"
+ }
+ },
+ "outputs": [],
+ "source": [
+ "%pip show validmind"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "If the version returned is lower than the version indicated in our [production open-source code](https://github.com/validmind/validmind-library/blob/prod/validmind/__version__.py), restart your notebook and run:\n",
+ "\n",
+ "```bash\n",
+ "%pip install --upgrade validmind\n",
+ "```"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "You may need to restart your kernel after running the upgrade package for changes to be applied."
+ ]
+ }
+ ],
+ "metadata": {
+ "language_info": {
+ "name": "python"
+ }
+ },
+ "nbformat": 4,
+ "nbformat_minor": 2
+}
From 75f3f7dbe6dfe9745e4e143b481799399461887b Mon Sep 17 00:00:00 2001
From: Beck <164545837+validbeck@users.noreply.github.com>
Date: Tue, 31 Dec 2024 15:19:54 -0800
Subject: [PATCH 02/38] Edits to templates
---
.../install-initialize-validmind.ipynb | 19 ++++++----
notebooks/templates/next-steps.ipynb | 35 +------------------
2 files changed, 13 insertions(+), 41 deletions(-)
diff --git a/notebooks/templates/install-initialize-validmind.ipynb b/notebooks/templates/install-initialize-validmind.ipynb
index bf7c62b2a..91b1495c8 100644
--- a/notebooks/templates/install-initialize-validmind.ipynb
+++ b/notebooks/templates/install-initialize-validmind.ipynb
@@ -30,7 +30,7 @@
"\n",
"1. In a browser, [log in to ValidMind](https://docs.validmind.ai/guide/configuration/log-in-to-validmind.html).\n",
"\n",
- "2. In the left sidebar, navigate to **Model Inventory** and click **+ Register new model**.\n",
+ "2. In the left sidebar, navigate to **Model Inventory** and click **+ Register Model**.\n",
"\n",
"3. Enter the model details and click **Continue**. ([Need more help?](https://docs.validmind.ai/guide/model-inventory/register-models-in-inventory.html))\n",
"\n",
@@ -43,7 +43,7 @@
"\n",
"4. Go to **Getting Started** and click **Copy snippet to clipboard**.\n",
"\n",
- "Next, replace this placeholder with your own code snippet:\n"
+ "Next, [load your model identifier credentials from an `.env` file](https://docs.validmind.ai/developer/model-documentation/store-credentials-in-env-file.html) or replace the placeholder with your own code snippet:\n"
]
},
{
@@ -52,15 +52,20 @@
"metadata": {},
"outputs": [],
"source": [
- "# Replace with your code snippet\n",
+ "# Load your model identifier credentials from an `.env` file\n",
+ "\n",
+ "%load_ext dotenv\n",
+ "%dotenv .env\n",
+ "\n",
+ "# Or replace with your code snippet\n",
"\n",
"import validmind as vm\n",
"\n",
"vm.init(\n",
- " api_host=\"https://api.prod.validmind.ai/api/v1/tracking\",\n",
- " api_key=\"...\",\n",
- " api_secret=\"...\",\n",
- " model=\"...\",\n",
+ " # api_host=\"...\",\n",
+ " # api_key=\"...\",\n",
+ " # api_secret=\"...\",\n",
+ " # model=\"...\",\n",
")"
]
}
diff --git a/notebooks/templates/next-steps.ipynb b/notebooks/templates/next-steps.ipynb
index 45bf565db..4ca8fa187 100644
--- a/notebooks/templates/next-steps.ipynb
+++ b/notebooks/templates/next-steps.ipynb
@@ -12,7 +12,7 @@
"\n",
"1. From the **Model 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. Click and expand the **Model Development** section.\n",
+ "2. In the left sidebar that appears for your mode, click **Documentation**.\n",
"\n",
"What you see is the full draft of your model documentation in a more easily consumable version. From here, you can make qualitative edits to model documentation, view guidelines, collaborate with validators, and submit your model documentation for approval when it's ready. [Learn more ...](https://docs.validmind.ai/guide/working-with-model-documentation.html)\n",
"\n",
@@ -25,39 +25,6 @@
"\n",
"Or, visit our [documentation](https://docs.validmind.ai/) to learn more about ValidMind."
]
- },
- {
- "cell_type": "markdown",
- "metadata": {},
- "source": [
- "## Upgrade ValidMind\n",
- "\n",
- "After installing ValidMind, you’ll want to periodically make sure you are on the latest version to access any new features and other enhancements.
\n",
- "\n",
- "Retrieve the information for the currently installed version of ValidMind:"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "metadata": {},
- "outputs": [],
- "source": [
- "%pip show validmind"
- ]
- },
- {
- "cell_type": "markdown",
- "metadata": {},
- "source": [
- "If the version returned is lower than the version indicated in our [production open-source code](https://github.com/validmind/developer-framework/blob/prod/validmind/__version__.py), restart your notebook and run:\n",
- "\n",
- "```bash\n",
- "%pip install --upgrade validmind\n",
- "```\n",
- "\n",
- "You may need to restart your kernel after running the upgrade package for changes to be applied."
- ]
}
],
"metadata": {
From bad8488e694a65a36716948e8984dd754ffbedbe Mon Sep 17 00:00:00 2001
From: Beck <164545837+validbeck@users.noreply.github.com>
Date: Tue, 31 Dec 2024 15:21:08 -0800
Subject: [PATCH 03/38] Updating README
---
notebooks/README.md | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/notebooks/README.md b/notebooks/README.md
index 327645c77..af6dcc519 100644
--- a/notebooks/README.md
+++ b/notebooks/README.md
@@ -8,7 +8,7 @@ Sample notebooks are organized into the following folders:
* `notebooks/how_to` — Learn how to use specific ValidMind features, e.g. how to list all test suites
* `notebooks/tutorials` — Get step-by-step instructions and learn about ValidMind concepts in depth
* `notebooks/code_sharing` — Share your own notebooks or document code internally
-* `notebooks/archive` — Deprecrated notebooks, that have either been retired or replaced with newer content
+* `notebooks/templates` — Template notebooks to help you create your own custom ValidMind code samples
## Getting started
From e5a68ee0c5d75934cced1b47da6937742a91bb93 Mon Sep 17 00:00:00 2001
From: Beck <164545837+validbeck@users.noreply.github.com>
Date: Tue, 31 Dec 2024 15:32:02 -0800
Subject: [PATCH 04/38] Testing a script
---
notebooks/templates/e2e-notebook.ipynb | 57 ++++++++++++++++++++++++++
notebooks/templates/e2e_template.py | 55 +++++++++++++++++++++++++
2 files changed, 112 insertions(+)
create mode 100644 notebooks/templates/e2e-notebook.ipynb
create mode 100644 notebooks/templates/e2e_template.py
diff --git a/notebooks/templates/e2e-notebook.ipynb b/notebooks/templates/e2e-notebook.ipynb
new file mode 100644
index 000000000..5e0b8fdd4
--- /dev/null
+++ b/notebooks/templates/e2e-notebook.ipynb
@@ -0,0 +1,57 @@
+{
+ "cells": [
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "import the script"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 1,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "import e2e_template as tm"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "create the notebook file in code_sharing"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "tm.create_notebook()"
+ ]
+ }
+ ],
+ "metadata": {
+ "kernelspec": {
+ "display_name": "Python 3",
+ "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.10.13"
+ }
+ },
+ "nbformat": 4,
+ "nbformat_minor": 2
+}
diff --git a/notebooks/templates/e2e_template.py b/notebooks/templates/e2e_template.py
new file mode 100644
index 000000000..2ea6fca82
--- /dev/null
+++ b/notebooks/templates/e2e_template.py
@@ -0,0 +1,55 @@
+import nbformat
+import os
+
+def create_notebook():
+ """Creates a new Jupyter Notebook file by asking the user for a filename."""
+ # Prompt the user for a filename
+ filename = input("Enter the name for the new notebook (without .ipynb extension): ").strip()
+
+ # Ensure the filename is valid
+ if not filename:
+ print("Filename cannot be empty.")
+ return
+
+ # Add the .ipynb extension if not provided
+ if not filename.endswith(".ipynb"):
+ filename += ".ipynb"
+
+ # Define the directory to save the file (relative to the current script's location)
+ current_dir = os.path.dirname(__file__)
+ directory = os.path.join(current_dir, "..", "code_sharing")
+
+ # Ensure the directory exists
+ if not os.path.exists(directory):
+ os.makedirs(directory)
+
+ # Full file path
+ filepath = os.path.join(directory, filename)
+
+ # Create a new notebook object
+ notebook = nbformat.v4.new_notebook()
+
+ # Add some default metadata (optional)
+ notebook["metadata"] = {
+ "kernelspec": {
+ "name": "python3",
+ "display_name": "Python 3",
+ "language": "python"
+ },
+ "language_info": {
+ "name": "python",
+ "version": "3.10" # Modify based on your Python version
+ }
+ }
+
+ # Write the notebook to a file
+ try:
+ with open(filepath, "w") as f:
+ nbformat.write(notebook, f)
+ print(f"Notebook '{filepath}' created successfully.")
+ except Exception as e:
+ print(f"Error creating notebook: {e}")
+
+# Example usage
+if __name__ == "__main__":
+ create_notebook()
From b8bc4defa94fd221f6d4730d3b06f9d366728213 Mon Sep 17 00:00:00 2001
From: Beck <164545837+validbeck@users.noreply.github.com>
Date: Tue, 31 Dec 2024 15:41:03 -0800
Subject: [PATCH 05/38] Adding title
---
notebooks/templates/e2e-notebook.ipynb | 39 +++++++++++++++++++++--
notebooks/templates/e2e_template.py | 44 ++++++++++++++++++++++++--
2 files changed, 77 insertions(+), 6 deletions(-)
diff --git a/notebooks/templates/e2e-notebook.ipynb b/notebooks/templates/e2e-notebook.ipynb
index 5e0b8fdd4..0bb111090 100644
--- a/notebooks/templates/e2e-notebook.ipynb
+++ b/notebooks/templates/e2e-notebook.ipynb
@@ -25,11 +25,44 @@
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 2,
"metadata": {},
- "outputs": [],
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "'/Users/beckchan/Documents/GitHub/validmind/validmind-library/notebooks/templates/../code_sharing/test_2.ipynb' created successfully\n"
+ ]
+ }
+ ],
+ "source": [
+ "filepath = tm.create_notebook()"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "insert title"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 3,
+ "metadata": {},
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "'Another title' added to notebook '/Users/beckchan/Documents/GitHub/validmind/validmind-library/notebooks/templates/../code_sharing/test_2.ipynb' as title\n"
+ ]
+ }
+ ],
"source": [
- "tm.create_notebook()"
+ "if filepath:\n",
+ " tm.add_title(filepath)"
]
}
],
diff --git a/notebooks/templates/e2e_template.py b/notebooks/templates/e2e_template.py
index 2ea6fca82..4b71907dd 100644
--- a/notebooks/templates/e2e_template.py
+++ b/notebooks/templates/e2e_template.py
@@ -8,7 +8,7 @@ def create_notebook():
# Ensure the filename is valid
if not filename:
- print("Filename cannot be empty.")
+ print("Filename cannot be empty")
return
# Add the .ipynb extension if not provided
@@ -46,10 +46,48 @@ def create_notebook():
try:
with open(filepath, "w") as f:
nbformat.write(notebook, f)
- print(f"Notebook '{filepath}' created successfully.")
+ print(f"'{filepath}' created successfully")
except Exception as e:
print(f"Error creating notebook: {e}")
+ return filepath
+
+def add_title(filepath):
+ """Adds a markdown cell with a title to the specified notebook."""
+ if not os.path.exists(filepath):
+ print("The specified notebook file does not exist")
+ return
+
+ # Load the existing notebook
+ try:
+ with open(filepath, "r") as f:
+ notebook = nbformat.read(f, as_version=4)
+ except Exception as e:
+ print(f"Error reading notebook: {e}")
+ return
+
+ # Prompt the user for a title
+ title = input("Enter the title for the notebook: ").strip()
+ if not title:
+ print("Title cannot be empty")
+ return
+
+ # Create a markdown cell with the title
+ markdown_cell = nbformat.v4.new_markdown_cell(f"# {title}")
+
+ # Add the markdown cell at the beginning of the notebook
+ notebook.cells.insert(0, markdown_cell)
+
+ # Write the updated notebook back to the file
+ try:
+ with open(filepath, "w") as f:
+ nbformat.write(notebook, f)
+ print(f"'{title}' added to '{filepath}' as title")
+ except Exception as e:
+ print(f"Error updating notebook: {e}")
+
# Example usage
if __name__ == "__main__":
- create_notebook()
+ filepath = create_notebook()
+ if filepath:
+ add_title(filepath)
From 0509213025f8d6f740d648cf6650c1e3e2be9287 Mon Sep 17 00:00:00 2001
From: Beck <164545837+validbeck@users.noreply.github.com>
Date: Tue, 31 Dec 2024 15:42:32 -0800
Subject: [PATCH 06/38] Setup the other cells
---
notebooks/templates/e2e-notebook.ipynb | 80 +++++++++++++++++++-------
1 file changed, 60 insertions(+), 20 deletions(-)
diff --git a/notebooks/templates/e2e-notebook.ipynb b/notebooks/templates/e2e-notebook.ipynb
index 0bb111090..c3eeb58d5 100644
--- a/notebooks/templates/e2e-notebook.ipynb
+++ b/notebooks/templates/e2e-notebook.ipynb
@@ -25,17 +25,9 @@
},
{
"cell_type": "code",
- "execution_count": 2,
+ "execution_count": null,
"metadata": {},
- "outputs": [
- {
- "name": "stdout",
- "output_type": "stream",
- "text": [
- "'/Users/beckchan/Documents/GitHub/validmind/validmind-library/notebooks/templates/../code_sharing/test_2.ipynb' created successfully\n"
- ]
- }
- ],
+ "outputs": [],
"source": [
"filepath = tm.create_notebook()"
]
@@ -49,21 +41,69 @@
},
{
"cell_type": "code",
- "execution_count": 3,
+ "execution_count": null,
"metadata": {},
- "outputs": [
- {
- "name": "stdout",
- "output_type": "stream",
- "text": [
- "'Another title' added to notebook '/Users/beckchan/Documents/GitHub/validmind/validmind-library/notebooks/templates/../code_sharing/test_2.ipynb' as title\n"
- ]
- }
- ],
+ "outputs": [],
"source": [
"if filepath:\n",
" tm.add_title(filepath)"
]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "insert about validmind y/n"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {},
+ "outputs": [],
+ "source": []
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "insert install y/n"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {},
+ "outputs": [],
+ "source": []
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "insert next steps y/n"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {},
+ "outputs": [],
+ "source": []
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "insert upgrade y/n"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {},
+ "outputs": [],
+ "source": []
}
],
"metadata": {
From 4ddf5fd17554a8e2432ee8c4cd42561ce03b532a Mon Sep 17 00:00:00 2001
From: Beck <164545837+validbeck@users.noreply.github.com>
Date: Tue, 31 Dec 2024 15:50:26 -0800
Subject: [PATCH 07/38] Test append
---
notebooks/templates/e2e-notebook.ipynb | 5 +++-
notebooks/templates/e2e_template.py | 38 ++++++++++++++++++++++++++
2 files changed, 42 insertions(+), 1 deletion(-)
diff --git a/notebooks/templates/e2e-notebook.ipynb b/notebooks/templates/e2e-notebook.ipynb
index c3eeb58d5..5b367a0ef 100644
--- a/notebooks/templates/e2e-notebook.ipynb
+++ b/notebooks/templates/e2e-notebook.ipynb
@@ -61,7 +61,10 @@
"execution_count": null,
"metadata": {},
"outputs": [],
- "source": []
+ "source": [
+ "if filepath:\n",
+ " tm.add_about(filepath)"
+ ]
},
{
"cell_type": "markdown",
diff --git a/notebooks/templates/e2e_template.py b/notebooks/templates/e2e_template.py
index 4b71907dd..58e6846ee 100644
--- a/notebooks/templates/e2e_template.py
+++ b/notebooks/templates/e2e_template.py
@@ -86,8 +86,46 @@ def add_title(filepath):
except Exception as e:
print(f"Error updating notebook: {e}")
+def add_about(filepath):
+ """Appends the contents of 'about-validmind.ipynb' to the specified notebook if the user agrees."""
+ source_notebook_path = os.path.join(os.path.dirname(__file__), "about-validmind.ipynb")
+
+ # Check if the source notebook exists
+ if not os.path.exists(source_notebook_path):
+ print(f"Source notebook '{source_notebook_path}' does not exist")
+ return
+
+ # Ask the user if they want to append the source notebook
+ user_input = input("Do you want to include 'about-validmind.ipynb'? (yes/no): ").strip().lower()
+ if user_input not in ("yes", "y"):
+ print("Skipping appending 'about-validmind.ipynb'")
+ return
+
+ # Load the target and source notebooks
+ try:
+ with open(filepath, "r") as target_file:
+ target_notebook = nbformat.read(target_file, as_version=4)
+
+ with open(source_notebook_path, "r") as source_file:
+ source_notebook = nbformat.read(source_file, as_version=4)
+ except Exception as e:
+ print(f"Error reading notebooks: {e}")
+ return
+
+ # Append the cells from the source notebook to the target notebook
+ target_notebook.cells.extend(source_notebook.cells)
+
+ # Write the updated target notebook back to the file
+ try:
+ with open(filepath, "w") as target_file:
+ nbformat.write(target_notebook, target_file)
+ print(f"Contents of 'about-validmind.ipynb' appended to '{filepath}' successfully.")
+ except Exception as e:
+ print(f"Error appending notebooks: {e}")
+
# Example usage
if __name__ == "__main__":
filepath = create_notebook()
if filepath:
add_title(filepath)
+ add_about(filepath)
\ No newline at end of file
From cb9fb8b67c37e157de2f8976bb1ca223363df1c1 Mon Sep 17 00:00:00 2001
From: Beck <164545837+validbeck@users.noreply.github.com>
Date: Tue, 31 Dec 2024 15:54:49 -0800
Subject: [PATCH 08/38] Test adding IDs to cells
---
notebooks/templates/e2e_template.py | 43 +++++++++++++----------------
1 file changed, 19 insertions(+), 24 deletions(-)
diff --git a/notebooks/templates/e2e_template.py b/notebooks/templates/e2e_template.py
index 58e6846ee..63698c20e 100644
--- a/notebooks/templates/e2e_template.py
+++ b/notebooks/templates/e2e_template.py
@@ -1,35 +1,33 @@
import nbformat
import os
+import uuid
+
+def ensure_cell_ids(notebook):
+ """Ensure every cell in the notebook has a unique id."""
+ for cell in notebook.cells:
+ if "id" not in cell:
+ cell["id"] = str(uuid.uuid4())
+ return notebook
def create_notebook():
"""Creates a new Jupyter Notebook file by asking the user for a filename."""
- # Prompt the user for a filename
filename = input("Enter the name for the new notebook (without .ipynb extension): ").strip()
-
- # Ensure the filename is valid
if not filename:
print("Filename cannot be empty")
return
- # Add the .ipynb extension if not provided
if not filename.endswith(".ipynb"):
filename += ".ipynb"
- # Define the directory to save the file (relative to the current script's location)
current_dir = os.path.dirname(__file__)
directory = os.path.join(current_dir, "..", "code_sharing")
- # Ensure the directory exists
if not os.path.exists(directory):
os.makedirs(directory)
- # Full file path
filepath = os.path.join(directory, filename)
- # Create a new notebook object
notebook = nbformat.v4.new_notebook()
-
- # Add some default metadata (optional)
notebook["metadata"] = {
"kernelspec": {
"name": "python3",
@@ -38,11 +36,13 @@ def create_notebook():
},
"language_info": {
"name": "python",
- "version": "3.10" # Modify based on your Python version
+ "version": "3.10"
}
}
- # Write the notebook to a file
+ # Ensure cells have IDs
+ notebook = ensure_cell_ids(notebook)
+
try:
with open(filepath, "w") as f:
nbformat.write(notebook, f)
@@ -58,7 +58,6 @@ def add_title(filepath):
print("The specified notebook file does not exist")
return
- # Load the existing notebook
try:
with open(filepath, "r") as f:
notebook = nbformat.read(f, as_version=4)
@@ -66,19 +65,17 @@ def add_title(filepath):
print(f"Error reading notebook: {e}")
return
- # Prompt the user for a title
title = input("Enter the title for the notebook: ").strip()
if not title:
print("Title cannot be empty")
return
- # Create a markdown cell with the title
markdown_cell = nbformat.v4.new_markdown_cell(f"# {title}")
-
- # Add the markdown cell at the beginning of the notebook
notebook.cells.insert(0, markdown_cell)
- # Write the updated notebook back to the file
+ # Ensure all cells have IDs
+ notebook = ensure_cell_ids(notebook)
+
try:
with open(filepath, "w") as f:
nbformat.write(notebook, f)
@@ -90,18 +87,15 @@ def add_about(filepath):
"""Appends the contents of 'about-validmind.ipynb' to the specified notebook if the user agrees."""
source_notebook_path = os.path.join(os.path.dirname(__file__), "about-validmind.ipynb")
- # Check if the source notebook exists
if not os.path.exists(source_notebook_path):
print(f"Source notebook '{source_notebook_path}' does not exist")
return
- # Ask the user if they want to append the source notebook
user_input = input("Do you want to include 'about-validmind.ipynb'? (yes/no): ").strip().lower()
if user_input not in ("yes", "y"):
print("Skipping appending 'about-validmind.ipynb'")
return
- # Load the target and source notebooks
try:
with open(filepath, "r") as target_file:
target_notebook = nbformat.read(target_file, as_version=4)
@@ -112,14 +106,15 @@ def add_about(filepath):
print(f"Error reading notebooks: {e}")
return
- # Append the cells from the source notebook to the target notebook
target_notebook.cells.extend(source_notebook.cells)
- # Write the updated target notebook back to the file
+ # Ensure all cells have IDs
+ target_notebook = ensure_cell_ids(target_notebook)
+
try:
with open(filepath, "w") as target_file:
nbformat.write(target_notebook, target_file)
- print(f"Contents of 'about-validmind.ipynb' appended to '{filepath}' successfully.")
+ print(f"Contents of 'about-validmind.ipynb' appended to '{filepath}' successfully")
except Exception as e:
print(f"Error appending notebooks: {e}")
From e2f9bfec63f51b4352d61996e91275186a113c69 Mon Sep 17 00:00:00 2001
From: Beck <164545837+validbeck@users.noreply.github.com>
Date: Tue, 31 Dec 2024 16:00:57 -0800
Subject: [PATCH 09/38] Add install info
---
notebooks/templates/e2e-notebook.ipynb | 5 +++-
notebooks/templates/e2e_template.py | 40 ++++++++++++++++++++++++--
2 files changed, 42 insertions(+), 3 deletions(-)
diff --git a/notebooks/templates/e2e-notebook.ipynb b/notebooks/templates/e2e-notebook.ipynb
index 5b367a0ef..a59e424fc 100644
--- a/notebooks/templates/e2e-notebook.ipynb
+++ b/notebooks/templates/e2e-notebook.ipynb
@@ -78,7 +78,10 @@
"execution_count": null,
"metadata": {},
"outputs": [],
- "source": []
+ "source": [
+ "if filepath:\n",
+ " tm.add_install(filepath)"
+ ]
},
{
"cell_type": "markdown",
diff --git a/notebooks/templates/e2e_template.py b/notebooks/templates/e2e_template.py
index 63698c20e..abde112a7 100644
--- a/notebooks/templates/e2e_template.py
+++ b/notebooks/templates/e2e_template.py
@@ -114,7 +114,42 @@ def add_about(filepath):
try:
with open(filepath, "w") as target_file:
nbformat.write(target_notebook, target_file)
- print(f"Contents of 'about-validmind.ipynb' appended to '{filepath}' successfully")
+ print(f"'about-validmind.ipynb' appended to '{filepath}' successfully")
+ except Exception as e:
+ print(f"Error appending notebooks: {e}")
+
+def add_install(filepath):
+ """Appends the contents of 'install-initialize-validmind.ipynb' to the specified notebook if the user agrees."""
+ source_notebook_path = os.path.join(os.path.dirname(__file__), "install-initialize-validmind.ipynb")
+
+ if not os.path.exists(source_notebook_path):
+ print(f"Source notebook '{source_notebook_path}' does not exist")
+ return
+
+ user_input = input("Do you want to include 'install-initialize-validmind.ipynb'? (yes/no): ").strip().lower()
+ if user_input not in ("yes", "y"):
+ print("Skipping appending 'install-initialize-validmind.ipynb'")
+ return
+
+ try:
+ with open(filepath, "r") as target_file:
+ target_notebook = nbformat.read(target_file, as_version=4)
+
+ with open(source_notebook_path, "r") as source_file:
+ source_notebook = nbformat.read(source_file, as_version=4)
+ except Exception as e:
+ print(f"Error reading notebooks: {e}")
+ return
+
+ target_notebook.cells.extend(source_notebook.cells)
+
+ # Ensure all cells have IDs
+ target_notebook = ensure_cell_ids(target_notebook)
+
+ try:
+ with open(filepath, "w") as target_file:
+ nbformat.write(target_notebook, target_file)
+ print(f"'install-initialize-validmind.ipynb' appended to '{filepath}' successfully")
except Exception as e:
print(f"Error appending notebooks: {e}")
@@ -123,4 +158,5 @@ def add_about(filepath):
filepath = create_notebook()
if filepath:
add_title(filepath)
- add_about(filepath)
\ No newline at end of file
+ add_about(filepath)
+ add_install(filepath)
\ No newline at end of file
From ee110fda95c1c3b59b940d4084cf4a2709ee396f Mon Sep 17 00:00:00 2001
From: Beck <164545837+validbeck@users.noreply.github.com>
Date: Tue, 31 Dec 2024 16:04:27 -0800
Subject: [PATCH 10/38] Add next steps & upgrade info
---
notebooks/templates/e2e-notebook.ipynb | 12 +++-
notebooks/templates/e2e_template.py | 78 +++++++++++++++++++++++++-
2 files changed, 84 insertions(+), 6 deletions(-)
diff --git a/notebooks/templates/e2e-notebook.ipynb b/notebooks/templates/e2e-notebook.ipynb
index a59e424fc..b7155a22c 100644
--- a/notebooks/templates/e2e-notebook.ipynb
+++ b/notebooks/templates/e2e-notebook.ipynb
@@ -46,7 +46,7 @@
"outputs": [],
"source": [
"if filepath:\n",
- " tm.add_title(filepath)"
+ " tm.set_title(filepath)"
]
},
{
@@ -95,7 +95,10 @@
"execution_count": null,
"metadata": {},
"outputs": [],
- "source": []
+ "source": [
+ "if filepath:\n",
+ " tm.next_steps(filepath)"
+ ]
},
{
"cell_type": "markdown",
@@ -109,7 +112,10 @@
"execution_count": null,
"metadata": {},
"outputs": [],
- "source": []
+ "source": [
+ "if filepath:\n",
+ " tm.add_upgrade(filepath)"
+ ]
}
],
"metadata": {
diff --git a/notebooks/templates/e2e_template.py b/notebooks/templates/e2e_template.py
index abde112a7..78b102c22 100644
--- a/notebooks/templates/e2e_template.py
+++ b/notebooks/templates/e2e_template.py
@@ -52,7 +52,7 @@ def create_notebook():
return filepath
-def add_title(filepath):
+def set_title(filepath):
"""Adds a markdown cell with a title to the specified notebook."""
if not os.path.exists(filepath):
print("The specified notebook file does not exist")
@@ -153,10 +153,82 @@ def add_install(filepath):
except Exception as e:
print(f"Error appending notebooks: {e}")
+def next_steps(filepath):
+ """Appends the contents of 'next-steps.ipynb' to the specified notebook if the user agrees."""
+ source_notebook_path = os.path.join(os.path.dirname(__file__), "next-steps.ipynb")
+
+ if not os.path.exists(source_notebook_path):
+ print(f"Source notebook '{source_notebook_path}' does not exist")
+ return
+
+ user_input = input("Do you want to include 'next-steps.ipynb'? (yes/no): ").strip().lower()
+ if user_input not in ("yes", "y"):
+ print("Skipping appending 'next-steps.ipynb'")
+ return
+
+ try:
+ with open(filepath, "r") as target_file:
+ target_notebook = nbformat.read(target_file, as_version=4)
+
+ with open(source_notebook_path, "r") as source_file:
+ source_notebook = nbformat.read(source_file, as_version=4)
+ except Exception as e:
+ print(f"Error reading notebooks: {e}")
+ return
+
+ target_notebook.cells.extend(source_notebook.cells)
+
+ # Ensure all cells have IDs
+ target_notebook = ensure_cell_ids(target_notebook)
+
+ try:
+ with open(filepath, "w") as target_file:
+ nbformat.write(target_notebook, target_file)
+ print(f"'next-steps.ipynb' appended to '{filepath}' successfully")
+ except Exception as e:
+ print(f"Error appending notebooks: {e}")
+
+def add_upgrade(filepath):
+ """Appends the contents of 'upgrade-validmind.ipynb' to the specified notebook if the user agrees."""
+ source_notebook_path = os.path.join(os.path.dirname(__file__), "upgrade-validmind.ipynb")
+
+ if not os.path.exists(source_notebook_path):
+ print(f"Source notebook '{source_notebook_path}' does not exist")
+ return
+
+ user_input = input("Do you want to include 'upgrade-validmind.ipynb'? (yes/no): ").strip().lower()
+ if user_input not in ("yes", "y"):
+ print("Skipping appending 'upgrade-validmind.ipynb'")
+ return
+
+ try:
+ with open(filepath, "r") as target_file:
+ target_notebook = nbformat.read(target_file, as_version=4)
+
+ with open(source_notebook_path, "r") as source_file:
+ source_notebook = nbformat.read(source_file, as_version=4)
+ except Exception as e:
+ print(f"Error reading notebooks: {e}")
+ return
+
+ target_notebook.cells.extend(source_notebook.cells)
+
+ # Ensure all cells have IDs
+ target_notebook = ensure_cell_ids(target_notebook)
+
+ try:
+ with open(filepath, "w") as target_file:
+ nbformat.write(target_notebook, target_file)
+ print(f"'upgrade-validmind.ipynb' appended to '{filepath}' successfully")
+ except Exception as e:
+ print(f"Error appending notebooks: {e}")
+
# Example usage
if __name__ == "__main__":
filepath = create_notebook()
if filepath:
- add_title(filepath)
+ set_title(filepath)
add_about(filepath)
- add_install(filepath)
\ No newline at end of file
+ add_install(filepath)
+ next_steps(filepath)
+ add_upgrade(filepath)
\ No newline at end of file
From 69b0cdf3b0d37cf51ee1e45393a9f8c5c9b98cf8 Mon Sep 17 00:00:00 2001
From: Beck <164545837+validbeck@users.noreply.github.com>
Date: Tue, 31 Dec 2024 16:23:37 -0800
Subject: [PATCH 11/38] Cleanup & testing Makefile
---
Makefile | 5 ++-
notebooks/templates/README.md | 2 ++
notebooks/templates/e2e_template.py | 55 ++++++++++++++---------------
3 files changed, 33 insertions(+), 29 deletions(-)
create mode 100644 notebooks/templates/README.md
diff --git a/Makefile b/Makefile
index e8d9782f5..8048417b4 100644
--- a/Makefile
+++ b/Makefile
@@ -1,4 +1,4 @@
-# https://stackoverflow.com/questions/10858261/how-to-abort-makefile-if-variable-not-set
+ # https://stackoverflow.com/questions/10858261/how-to-abort-makefile-if-variable-not-set
check_defined = \
$(strip $(foreach 1,$1, \
$(call __check_defined,$1,$(strip $(value 2)))))
@@ -79,3 +79,6 @@ ensure-clean-notebooks:
check: copyright format lint test verify-copyright verify-exposed-credentials ensure-clean-notebooks
.PHONY: docs
+
+notebook:
+ @python notebooks/templates/e2e_template.py
diff --git a/notebooks/templates/README.md b/notebooks/templates/README.md
new file mode 100644
index 000000000..ad22727de
--- /dev/null
+++ b/notebooks/templates/README.md
@@ -0,0 +1,2 @@
+# Jupyter Notebook templates
+
diff --git a/notebooks/templates/e2e_template.py b/notebooks/templates/e2e_template.py
index 78b102c22..66741c2c3 100644
--- a/notebooks/templates/e2e_template.py
+++ b/notebooks/templates/e2e_template.py
@@ -1,8 +1,9 @@
import nbformat
import os
import uuid
+import subprocess
-def ensure_cell_ids(notebook):
+def ensure_ids(notebook):
"""Ensure every cell in the notebook has a unique id."""
for cell in notebook.cells:
if "id" not in cell:
@@ -10,7 +11,7 @@ def ensure_cell_ids(notebook):
return notebook
def create_notebook():
- """Creates a new Jupyter Notebook file by asking the user for a filename."""
+ """Creates a new Jupyter Notebook file by asking the user for a filename and opens it in VS Code."""
filename = input("Enter the name for the new notebook (without .ipynb extension): ").strip()
if not filename:
print("Filename cannot be empty")
@@ -40,20 +41,21 @@ def create_notebook():
}
}
- # Ensure cells have IDs
- notebook = ensure_cell_ids(notebook)
+ notebook = ensure_ids(notebook)
try:
with open(filepath, "w") as f:
nbformat.write(notebook, f)
- print(f"'{filepath}' created successfully")
+ print(f"Created '{filepath}'")
+
+ subprocess.run(["code", filepath], check=True)
except Exception as e:
- print(f"Error creating notebook: {e}")
+ print(f"Error creating or opening notebook: {e}")
return filepath
def set_title(filepath):
- """Adds a markdown cell with a title to the specified notebook."""
+ """Adds a markdown cell with a h1 title to the specified notebook."""
if not os.path.exists(filepath):
print("The specified notebook file does not exist")
return
@@ -73,13 +75,12 @@ def set_title(filepath):
markdown_cell = nbformat.v4.new_markdown_cell(f"# {title}")
notebook.cells.insert(0, markdown_cell)
- # Ensure all cells have IDs
- notebook = ensure_cell_ids(notebook)
+ notebook = ensure_ids(notebook)
try:
with open(filepath, "w") as f:
nbformat.write(notebook, f)
- print(f"'{title}' added to '{filepath}' as title")
+ print(f"Set title for '{filepath}': '{title}'")
except Exception as e:
print(f"Error updating notebook: {e}")
@@ -91,7 +92,7 @@ def add_about(filepath):
print(f"Source notebook '{source_notebook_path}' does not exist")
return
- user_input = input("Do you want to include 'about-validmind.ipynb'? (yes/no): ").strip().lower()
+ user_input = input("Do you want to include information about ValidMind? (yes/no): ").strip().lower()
if user_input not in ("yes", "y"):
print("Skipping appending 'about-validmind.ipynb'")
return
@@ -108,13 +109,12 @@ def add_about(filepath):
target_notebook.cells.extend(source_notebook.cells)
- # Ensure all cells have IDs
- target_notebook = ensure_cell_ids(target_notebook)
+ target_notebook = ensure_ids(target_notebook)
try:
with open(filepath, "w") as target_file:
nbformat.write(target_notebook, target_file)
- print(f"'about-validmind.ipynb' appended to '{filepath}' successfully")
+ print(f"'about-validmind.ipynb' appended to '{filepath}'")
except Exception as e:
print(f"Error appending notebooks: {e}")
@@ -126,7 +126,7 @@ def add_install(filepath):
print(f"Source notebook '{source_notebook_path}' does not exist")
return
- user_input = input("Do you want to include 'install-initialize-validmind.ipynb'? (yes/no): ").strip().lower()
+ user_input = input("Do you want to include installation and initialization instructions? (yes/no): ").strip().lower()
if user_input not in ("yes", "y"):
print("Skipping appending 'install-initialize-validmind.ipynb'")
return
@@ -143,13 +143,12 @@ def add_install(filepath):
target_notebook.cells.extend(source_notebook.cells)
- # Ensure all cells have IDs
- target_notebook = ensure_cell_ids(target_notebook)
+ target_notebook = ensure_ids(target_notebook)
try:
with open(filepath, "w") as target_file:
nbformat.write(target_notebook, target_file)
- print(f"'install-initialize-validmind.ipynb' appended to '{filepath}' successfully")
+ print(f"'install-initialize-validmind.ipynb' appended to '{filepath}'")
except Exception as e:
print(f"Error appending notebooks: {e}")
@@ -161,7 +160,7 @@ def next_steps(filepath):
print(f"Source notebook '{source_notebook_path}' does not exist")
return
- user_input = input("Do you want to include 'next-steps.ipynb'? (yes/no): ").strip().lower()
+ user_input = input("Do you want to include next steps? (yes/no): ").strip().lower()
if user_input not in ("yes", "y"):
print("Skipping appending 'next-steps.ipynb'")
return
@@ -178,13 +177,12 @@ def next_steps(filepath):
target_notebook.cells.extend(source_notebook.cells)
- # Ensure all cells have IDs
- target_notebook = ensure_cell_ids(target_notebook)
+ target_notebook = ensure_ids(target_notebook)
try:
with open(filepath, "w") as target_file:
nbformat.write(target_notebook, target_file)
- print(f"'next-steps.ipynb' appended to '{filepath}' successfully")
+ print(f"'next-steps.ipynb' appended to '{filepath}'")
except Exception as e:
print(f"Error appending notebooks: {e}")
@@ -196,7 +194,7 @@ def add_upgrade(filepath):
print(f"Source notebook '{source_notebook_path}' does not exist")
return
- user_input = input("Do you want to include 'upgrade-validmind.ipynb'? (yes/no): ").strip().lower()
+ user_input = input("Do you want to include information about upgrading ValidMind? (yes/no): ").strip().lower()
if user_input not in ("yes", "y"):
print("Skipping appending 'upgrade-validmind.ipynb'")
return
@@ -212,19 +210,20 @@ def add_upgrade(filepath):
return
target_notebook.cells.extend(source_notebook.cells)
-
- # Ensure all cells have IDs
- target_notebook = ensure_cell_ids(target_notebook)
+ target_notebook = ensure_ids(target_notebook)
try:
with open(filepath, "w") as target_file:
nbformat.write(target_notebook, target_file)
- print(f"'upgrade-validmind.ipynb' appended to '{filepath}' successfully")
+ print(f"'upgrade-validmind.ipynb' appended to '{filepath}'")
except Exception as e:
print(f"Error appending notebooks: {e}")
-# Example usage
if __name__ == "__main__":
+
+ script_dir = os.path.dirname(os.path.abspath(__file__))
+ os.chdir(script_dir)
+
filepath = create_notebook()
if filepath:
set_title(filepath)
From 53c81f54b37b93b0b5361c00e2826b671fb23073 Mon Sep 17 00:00:00 2001
From: Beck <164545837+validbeck@users.noreply.github.com>
Date: Tue, 31 Dec 2024 16:42:09 -0800
Subject: [PATCH 12/38] Draft for notebook wording
---
notebooks/templates/README.md | 1 +
notebooks/templates/e2e-notebook.ipynb | 101 +++++++++++++++++++++++--
2 files changed, 95 insertions(+), 7 deletions(-)
diff --git a/notebooks/templates/README.md b/notebooks/templates/README.md
index ad22727de..f71e9365a 100644
--- a/notebooks/templates/README.md
+++ b/notebooks/templates/README.md
@@ -1,2 +1,3 @@
# Jupyter Notebook templates
+The easiest way to get started is to run the
\ No newline at end of file
diff --git a/notebooks/templates/e2e-notebook.ipynb b/notebooks/templates/e2e-notebook.ipynb
index b7155a22c..8621f992f 100644
--- a/notebooks/templates/e2e-notebook.ipynb
+++ b/notebooks/templates/e2e-notebook.ipynb
@@ -4,7 +4,25 @@
"cell_type": "markdown",
"metadata": {},
"source": [
- "import the script"
+ "# End-to-end notebook template generation\n",
+ "\n",
+ "This notebook (and attached script) creates a new `.ipynb` file in `~notebooks/code_sharing` to get you started with crafting a custom code sample for ValidMind."
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Setting up"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "### Import the notebook creation script\n",
+ "\n",
+ "This step loads our custom [`e2e_template.py`](e2e_template.py) so that the subsequent cells have access to the script."
]
},
{
@@ -20,7 +38,11 @@
"cell_type": "markdown",
"metadata": {},
"source": [
- "create the notebook file in code_sharing"
+ "### Designate the filename\n",
+ "\n",
+ "You'll be asked to input the filename, without the `.ipynb` extension. \n",
+ "\n",
+ "**This step will create a `.ipynb` file in `~/notebooks/code_sharing` on your behalf.** It will also open up the file for you so you don't have to go and find it. "
]
},
{
@@ -36,7 +58,9 @@
"cell_type": "markdown",
"metadata": {},
"source": [
- "insert title"
+ "### Set the title\n",
+ "\n",
+ "You'll then be asked to add a title, which will be inserted as an `h1` header in a markdown cell at the top of the notebook."
]
},
{
@@ -53,7 +77,16 @@
"cell_type": "markdown",
"metadata": {},
"source": [
- "insert about validmind y/n"
+ "## Single-sourcing from mini-templates"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "### Insert information about ValidMind\n",
+ "\n",
+ "You'll be asked if you want to include the contents of [`about-validmind.ipynb`](about-validmind.ipynb). "
]
},
{
@@ -70,7 +103,9 @@
"cell_type": "markdown",
"metadata": {},
"source": [
- "insert install y/n"
+ "### Insert installation instructions\n",
+ "\n",
+ "Next, you'll be asked if you want to include the contents of [`install-initialize-validmind.ipynb`](install-initialize-validmind.ipynb). "
]
},
{
@@ -87,7 +122,9 @@
"cell_type": "markdown",
"metadata": {},
"source": [
- "insert next steps y/n"
+ "### Insert next steps\n",
+ "\n",
+ "You'll also be asked if you want to include the contents of [`next-steps.ipynb`](next-steps.ipynb). "
]
},
{
@@ -104,7 +141,9 @@
"cell_type": "markdown",
"metadata": {},
"source": [
- "insert upgrade y/n"
+ "### Insert upgrade information\n",
+ "\n",
+ "Finally, you'll be asked if you want to include the contents of [`upgrade-validmind.ipynb`](upgrade-validmind.ipynb). "
]
},
{
@@ -116,6 +155,54 @@
"if filepath:\n",
" tm.add_upgrade(filepath)"
]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Next steps\n"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "### Show files to commit\n",
+ "\n",
+ "This block shows you the files changed or added by the notebook you need to commit — it should omit any files in `~notebooks/templates`. "
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "%%bash\n",
+ "cd ../../\n",
+ "git status | grep -v 'notebooks/templates'"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "On commiting files\n",
+ "
\n",
+ "Make sure that when you commit your changes to remote, do NOT include the changes in the ~/notebooks/templates folder as that would commit changed notebook with the output cells.
"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "\n",
+ "### Wrap it up\n",
+ "\n",
+ "- [ ] Review the generated notebook to confirm that everything you expect to be inserted is there.\n",
+ "- [ ] If inserted, adjust the **Documentation template** and **Use case** under `Get your code snippet` from [`install-initialize-validmind.ipynb`](install-initialize-validmind.ipynb) to match your actual requirements.\n",
+ "- [ ] Go forth and complete that custom sample!"
+ ]
}
],
"metadata": {
From 455b86794c4aec0ac8ba1cd8265782211d6250f6 Mon Sep 17 00:00:00 2001
From: Beck <164545837+validbeck@users.noreply.github.com>
Date: Tue, 31 Dec 2024 16:51:43 -0800
Subject: [PATCH 13/38] README
---
notebooks/templates/README.md | 19 +++++++++++++++++--
1 file changed, 17 insertions(+), 2 deletions(-)
diff --git a/notebooks/templates/README.md b/notebooks/templates/README.md
index f71e9365a..98ba54b19 100644
--- a/notebooks/templates/README.md
+++ b/notebooks/templates/README.md
@@ -1,3 +1,18 @@
-# Jupyter Notebook templates
+# Jupyter Notebook template QuickStart
-The easiest way to get started is to run the
\ No newline at end of file
+**The easiest way to get started with creating code samples for ValidMind is to run the [End-to-end notebook template generation](e2e-notebook.ipynb) notebook.**
+
+The same functionality is also accesible [in our root folder Makefile](../../Makefile) as a command:
+
+```bash
+make notebook
+```
+
+## Mini-templates
+
+The template generation script/notebook draws from the following mini-templates, should you need to revise them or grab the information from them manually:
+
+- [`about-validmind.ipynb`](about-validmind.ipynb): Conceptual overview of ValidMind & prerequisites.
+- [`install-initialize-validmind.ipynb`](install-initialize-validmind.ipynb): ValidMind Library installation & initialization instructions.
+- [`next-steps.ipynb`](next-steps.ipynb): Directions to review the generated documentation within the ValidMind Platform & additional learning resources.
+- [`upgrade-validmind.ipynb`](upgrade-validmind.ipynb): Instructions for comparing & upgrading versions of the ValidMind Library.
\ No newline at end of file
From 1d78229c6a9a384dc8a230d189551766b2b029ae Mon Sep 17 00:00:00 2001
From: Beck <164545837+validbeck@users.noreply.github.com>
Date: Tue, 31 Dec 2024 16:56:59 -0800
Subject: [PATCH 14/38] ToC
---
notebooks/templates/e2e-notebook.ipynb | 78 +++++++++++++++++++++-----
notebooks/templates/e2e_template.py | 4 +-
2 files changed, 67 insertions(+), 15 deletions(-)
diff --git a/notebooks/templates/e2e-notebook.ipynb b/notebooks/templates/e2e-notebook.ipynb
index 8621f992f..6e8dbc71c 100644
--- a/notebooks/templates/e2e-notebook.ipynb
+++ b/notebooks/templates/e2e-notebook.ipynb
@@ -13,21 +13,53 @@
"cell_type": "markdown",
"metadata": {},
"source": [
- "## Setting up"
+ "## Contents\n",
+ "- [Setting up](#toc1_) \n",
+ " - [Import the notebook creation script](#toc1_1_) \n",
+ " - [Designate the filename](#toc1_2_) \n",
+ " - [Set the title](#toc1_3_) \n",
+ "- [Single-sourcing from mini-templates](#toc2_) \n",
+ " - [Insert information about ValidMind](#toc2_1_) \n",
+ " - [Insert installation instructions](#toc2_2_) \n",
+ " - [Insert next steps](#toc2_3_) \n",
+ " - [Insert upgrade information](#toc2_4_) \n",
+ "- [Next steps](#toc3_) \n",
+ " - [Show files to commit](#toc3_1_) \n",
+ " - [Wrap it up](#toc3_2_) \n",
+ "\n",
+ "\n",
+ ""
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "\n",
+ "\n",
+ "## Setting up "
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
- "### Import the notebook creation script\n",
+ "\n",
+ "\n",
+ "### Import the notebook creation script \n",
"\n",
"This step loads our custom [`e2e_template.py`](e2e_template.py) so that the subsequent cells have access to the script."
]
},
{
"cell_type": "code",
- "execution_count": 1,
+ "execution_count": null,
"metadata": {},
"outputs": [],
"source": [
@@ -38,7 +70,9 @@
"cell_type": "markdown",
"metadata": {},
"source": [
- "### Designate the filename\n",
+ "\n",
+ "\n",
+ "### Designate the filename \n",
"\n",
"You'll be asked to input the filename, without the `.ipynb` extension. \n",
"\n",
@@ -58,7 +92,9 @@
"cell_type": "markdown",
"metadata": {},
"source": [
- "### Set the title\n",
+ "\n",
+ "\n",
+ "### Set the title \n",
"\n",
"You'll then be asked to add a title, which will be inserted as an `h1` header in a markdown cell at the top of the notebook."
]
@@ -77,14 +113,18 @@
"cell_type": "markdown",
"metadata": {},
"source": [
- "## Single-sourcing from mini-templates"
+ "\n",
+ "\n",
+ "## Single-sourcing from mini-templates "
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
- "### Insert information about ValidMind\n",
+ "\n",
+ "\n",
+ "### Insert information about ValidMind \n",
"\n",
"You'll be asked if you want to include the contents of [`about-validmind.ipynb`](about-validmind.ipynb). "
]
@@ -103,7 +143,9 @@
"cell_type": "markdown",
"metadata": {},
"source": [
- "### Insert installation instructions\n",
+ "\n",
+ "\n",
+ "### Insert installation instructions \n",
"\n",
"Next, you'll be asked if you want to include the contents of [`install-initialize-validmind.ipynb`](install-initialize-validmind.ipynb). "
]
@@ -122,7 +164,9 @@
"cell_type": "markdown",
"metadata": {},
"source": [
- "### Insert next steps\n",
+ "\n",
+ "\n",
+ "### Insert next steps \n",
"\n",
"You'll also be asked if you want to include the contents of [`next-steps.ipynb`](next-steps.ipynb). "
]
@@ -141,7 +185,9 @@
"cell_type": "markdown",
"metadata": {},
"source": [
- "### Insert upgrade information\n",
+ "\n",
+ "\n",
+ "### Insert upgrade information \n",
"\n",
"Finally, you'll be asked if you want to include the contents of [`upgrade-validmind.ipynb`](upgrade-validmind.ipynb). "
]
@@ -160,14 +206,18 @@
"cell_type": "markdown",
"metadata": {},
"source": [
- "## Next steps\n"
+ "\n",
+ "\n",
+ "## Next steps \n"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
- "### Show files to commit\n",
+ "\n",
+ "\n",
+ "### Show files to commit \n",
"\n",
"This block shows you the files changed or added by the notebook you need to commit — it should omit any files in `~notebooks/templates`. "
]
@@ -197,7 +247,9 @@
"metadata": {},
"source": [
"\n",
- "### Wrap it up\n",
+ "\n",
+ "\n",
+ "### Wrap it up \n",
"\n",
"- [ ] Review the generated notebook to confirm that everything you expect to be inserted is there.\n",
"- [ ] If inserted, adjust the **Documentation template** and **Use case** under `Get your code snippet` from [`install-initialize-validmind.ipynb`](install-initialize-validmind.ipynb) to match your actual requirements.\n",
diff --git a/notebooks/templates/e2e_template.py b/notebooks/templates/e2e_template.py
index 66741c2c3..fc03064f3 100644
--- a/notebooks/templates/e2e_template.py
+++ b/notebooks/templates/e2e_template.py
@@ -14,7 +14,7 @@ def create_notebook():
"""Creates a new Jupyter Notebook file by asking the user for a filename and opens it in VS Code."""
filename = input("Enter the name for the new notebook (without .ipynb extension): ").strip()
if not filename:
- print("Filename cannot be empty")
+ print("Filename cannot be empty, file not created")
return
if not filename.endswith(".ipynb"):
@@ -69,7 +69,7 @@ def set_title(filepath):
title = input("Enter the title for the notebook: ").strip()
if not title:
- print("Title cannot be empty")
+ print("No title inputted, skipped insertion")
return
markdown_cell = nbformat.v4.new_markdown_cell(f"# {title}")
From ae96d1938e74371af3ad82782b6f241c6cd50bd2 Mon Sep 17 00:00:00 2001
From: Beck <164545837+validbeck@users.noreply.github.com>
Date: Tue, 31 Dec 2024 16:59:45 -0800
Subject: [PATCH 15/38] Wording tweaks
---
notebooks/templates/e2e-notebook.ipynb | 10 ++++++----
1 file changed, 6 insertions(+), 4 deletions(-)
diff --git a/notebooks/templates/e2e-notebook.ipynb b/notebooks/templates/e2e-notebook.ipynb
index 6e8dbc71c..c35ef1caf 100644
--- a/notebooks/templates/e2e-notebook.ipynb
+++ b/notebooks/templates/e2e-notebook.ipynb
@@ -54,7 +54,7 @@
"\n",
"### Import the notebook creation script \n",
"\n",
- "This step loads our custom [`e2e_template.py`](e2e_template.py) so that the subsequent cells have access to the script."
+ "This step loads our custom [`e2e_template.py`](e2e_template.py) and its dependencies with a shortened alias so that the subsequent cells have access to the script."
]
},
{
@@ -74,7 +74,7 @@
"\n",
"### Designate the filename \n",
"\n",
- "You'll be asked to input the filename, without the `.ipynb` extension. \n",
+ "You'll be asked to input the filename, without the `.ipynb` extension. If you don't provide one, no file will be created.\n",
"\n",
"**This step will create a `.ipynb` file in `~/notebooks/code_sharing` on your behalf.** It will also open up the file for you so you don't have to go and find it. "
]
@@ -96,7 +96,9 @@
"\n",
"### Set the title \n",
"\n",
- "You'll then be asked to add a title, which will be inserted as an `h1` header in a markdown cell at the top of the notebook."
+ "You'll then be asked to add a title, which will be inserted as an `h1` header in a markdown cell at the top of the notebook.\n",
+ "\n",
+ "If you don't provide input, adding the title will be skipped."
]
},
{
@@ -251,7 +253,7 @@
"\n",
"### Wrap it up \n",
"\n",
- "- [ ] Review the generated notebook to confirm that everything you expect to be inserted is there.\n",
+ "- [ ] Review the generated notebook to confirm that everything you expect to be included is there.\n",
"- [ ] If inserted, adjust the **Documentation template** and **Use case** under `Get your code snippet` from [`install-initialize-validmind.ipynb`](install-initialize-validmind.ipynb) to match your actual requirements.\n",
"- [ ] Go forth and complete that custom sample!"
]
From 39ddc2a80175ba5697cb8be64226a51346cb71b4 Mon Sep 17 00:00:00 2001
From: Beck <164545837+validbeck@users.noreply.github.com>
Date: Tue, 31 Dec 2024 17:04:59 -0800
Subject: [PATCH 16/38] Updated main notebooks/ README
---
notebooks/README.md | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/notebooks/README.md b/notebooks/README.md
index af6dcc519..9624ce30a 100644
--- a/notebooks/README.md
+++ b/notebooks/README.md
@@ -10,7 +10,6 @@ Sample notebooks are organized into the following folders:
* `notebooks/code_sharing` — Share your own notebooks or document code internally
* `notebooks/templates` — Template notebooks to help you create your own custom ValidMind code samples
-
## Getting started
ValidMind enables organizations to identify, document, and manage model risks for all types of models, including AI/ML models, LLMs, and statistical models. As a model developer, you use the ValidMind Library to automate documentation and validation tests, and then use the ValidMind Platform to collaborate on documentation projects. Together, these products simplify model risk management, facilitate compliance with regulations and institutional standards, and enhance collaboration between yourself and model validators.
@@ -19,3 +18,7 @@ If this is your first time trying out ValidMind, you can make use of the followi
- [Get started](https://docs.validmind.ai/get-started/get-started.html) — The basics, including key concepts, and how our products work
- [Get started with the ValidMind Library](https://docs.validmind.ai/developer/get-started-validmind-library.html) — The path for developers, more code samples, and our developer reference
+
+## Contributing code samples
+
+Want to create some code samples for ValidMind? Our [End-to-end notebook template generation](templates/e2e-notebook.ipynb) notebook will generate a new file with all the bits and pieces of a standard ValidMind notebook to get you started.
From 476a50adcbf2e0524cbdf4742bb14600c8786743 Mon Sep 17 00:00:00 2001
From: Beck <164545837+validbeck@users.noreply.github.com>
Date: Tue, 31 Dec 2024 17:06:56 -0800
Subject: [PATCH 17/38] Modifying Makefile
---
Makefile | 1 +
1 file changed, 1 insertion(+)
diff --git a/Makefile b/Makefile
index 8048417b4..d7494b6f9 100644
--- a/Makefile
+++ b/Makefile
@@ -82,3 +82,4 @@ check: copyright format lint test verify-copyright verify-exposed-credentials en
notebook:
@python notebooks/templates/e2e_template.py
+ git status | grep -v 'notebooks/templates'
From 09ca0d8d3da295ef6eda9b37fd203af95dc437e1 Mon Sep 17 00:00:00 2001
From: Beck <164545837+validbeck@users.noreply.github.com>
Date: Thu, 2 Jan 2025 10:30:39 -0800
Subject: [PATCH 18/38] Tweaking the READMEs
---
notebooks/README.md | 3 +--
notebooks/templates/README.md | 2 +-
2 files changed, 2 insertions(+), 3 deletions(-)
diff --git a/notebooks/README.md b/notebooks/README.md
index 9624ce30a..24a923b91 100644
--- a/notebooks/README.md
+++ b/notebooks/README.md
@@ -8,7 +8,6 @@ Sample notebooks are organized into the following folders:
* `notebooks/how_to` — Learn how to use specific ValidMind features, e.g. how to list all test suites
* `notebooks/tutorials` — Get step-by-step instructions and learn about ValidMind concepts in depth
* `notebooks/code_sharing` — Share your own notebooks or document code internally
-* `notebooks/templates` — Template notebooks to help you create your own custom ValidMind code samples
## Getting started
@@ -21,4 +20,4 @@ If this is your first time trying out ValidMind, you can make use of the followi
## Contributing code samples
-Want to create some code samples for ValidMind? Our [End-to-end notebook template generation](templates/e2e-notebook.ipynb) notebook will generate a new file with all the bits and pieces of a standard ValidMind notebook to get you started.
+Head over to [`notebooks/templates`](templates/) to find templates to help you create your own custom ValidMind code samples.
diff --git a/notebooks/templates/README.md b/notebooks/templates/README.md
index 98ba54b19..42dc5d518 100644
--- a/notebooks/templates/README.md
+++ b/notebooks/templates/README.md
@@ -1,6 +1,6 @@
# Jupyter Notebook template QuickStart
-**The easiest way to get started with creating code samples for ValidMind is to run the [End-to-end notebook template generation](e2e-notebook.ipynb) notebook.**
+Want to create some code samples for ValidMind? Our **[End-to-end notebook template generation](e2e-notebook.ipynb) notebook** will generate a new file with all the bits and pieces of a standard ValidMind notebook to get you started.
The same functionality is also accesible [in our root folder Makefile](../../Makefile) as a command:
From 981201ba47e4f0e4603648d701e81158226ce2ee Mon Sep 17 00:00:00 2001
From: Beck <164545837+validbeck@users.noreply.github.com>
Date: Thu, 2 Jan 2025 11:48:52 -0800
Subject: [PATCH 19/38] Trying somtehing with the cell IDs
---
notebooks/templates/e2e_template.py | 3 +++
1 file changed, 3 insertions(+)
diff --git a/notebooks/templates/e2e_template.py b/notebooks/templates/e2e_template.py
index fc03064f3..7bc1f8001 100644
--- a/notebooks/templates/e2e_template.py
+++ b/notebooks/templates/e2e_template.py
@@ -106,6 +106,9 @@ def add_about(filepath):
except Exception as e:
print(f"Error reading notebooks: {e}")
return
+
+ for cell in source_notebook.cells:
+ cell["id"] = f"about-{uuid.uuid4()}"
target_notebook.cells.extend(source_notebook.cells)
From 689a46f7f5c1b68720fc15401b24f9adbb9af8bd Mon Sep 17 00:00:00 2001
From: Beck <164545837+validbeck@users.noreply.github.com>
Date: Thu, 2 Jan 2025 12:06:50 -0800
Subject: [PATCH 20/38] It works, let's try it again
---
notebooks/templates/e2e_template.py | 12 +++++++++---
1 file changed, 9 insertions(+), 3 deletions(-)
diff --git a/notebooks/templates/e2e_template.py b/notebooks/templates/e2e_template.py
index 7bc1f8001..0b7f32543 100644
--- a/notebooks/templates/e2e_template.py
+++ b/notebooks/templates/e2e_template.py
@@ -111,7 +111,6 @@ def add_about(filepath):
cell["id"] = f"about-{uuid.uuid4()}"
target_notebook.cells.extend(source_notebook.cells)
-
target_notebook = ensure_ids(target_notebook)
try:
@@ -143,9 +142,11 @@ def add_install(filepath):
except Exception as e:
print(f"Error reading notebooks: {e}")
return
+
+ for cell in source_notebook.cells:
+ cell["id"] = f"install-{uuid.uuid4()}"
target_notebook.cells.extend(source_notebook.cells)
-
target_notebook = ensure_ids(target_notebook)
try:
@@ -177,9 +178,11 @@ def next_steps(filepath):
except Exception as e:
print(f"Error reading notebooks: {e}")
return
+
+ for cell in source_notebook.cells:
+ cell["id"] = f"next-{uuid.uuid4()}"
target_notebook.cells.extend(source_notebook.cells)
-
target_notebook = ensure_ids(target_notebook)
try:
@@ -211,6 +214,9 @@ def add_upgrade(filepath):
except Exception as e:
print(f"Error reading notebooks: {e}")
return
+
+ for cell in source_notebook.cells:
+ cell["id"] = f"upgrade-{uuid.uuid4()}"
target_notebook.cells.extend(source_notebook.cells)
target_notebook = ensure_ids(target_notebook)
From cb92bbcc75ed44fedd6babcade1898c8c5668a04 Mon Sep 17 00:00:00 2001
From: Beck <164545837+validbeck@users.noreply.github.com>
Date: Thu, 2 Jan 2025 12:11:01 -0800
Subject: [PATCH 21/38] Spiltting the templates into more cells
---
notebooks/templates/about-validmind.ipynb | 27 ++++++++++++++-----
.../install-initialize-validmind.ipynb | 11 +++++---
notebooks/templates/next-steps.ipynb | 18 ++++++++++---
3 files changed, 43 insertions(+), 13 deletions(-)
diff --git a/notebooks/templates/about-validmind.ipynb b/notebooks/templates/about-validmind.ipynb
index e2d202ffb..5aded4975 100644
--- a/notebooks/templates/about-validmind.ipynb
+++ b/notebooks/templates/about-validmind.ipynb
@@ -8,22 +8,37 @@
"\n",
"ValidMind is a suite of tools for managing model risk, including risk associated with AI and statistical models. \n",
"\n",
- "You use the ValidMind Library to automate documentation and validation tests, and then use the ValidMind Platform to collaborate on model documentation. Together, these products simplify model risk management, facilitate compliance with regulations and institutional standards, and enhance collaboration between yourself and model validators.\n",
- "\n",
+ "You use the ValidMind Library to automate documentation and validation tests, and then use the ValidMind Platform to collaborate on model documentation. Together, these products simplify model risk management, facilitate compliance with regulations and institutional standards, and enhance collaboration between yourself and model validators."
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
"### 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",
"\n",
- "If you encounter errors due to missing modules in your Python environment, install the modules with `pip install`, and then re-run the notebook. For more help, refer to [Installing Python Modules](https://docs.python.org/3/installing/index.html).\n",
- "\n",
+ "If you encounter errors due to missing modules in your Python environment, install the modules with `pip install`, and then re-run the notebook. For more help, refer to [Installing Python Modules](https://docs.python.org/3/installing/index.html)."
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
"### New to ValidMind?\n",
"\n",
"If you haven't already seen our [Get started with the ValidMind Library](https://docs.validmind.ai/guide/get-started-validmind-library.html), we recommend you explore the available resources for developers at some point. There, you can learn more about documenting models, find code samples, or read our developer reference.\n",
"\n",
"For access to all features available in this notebook, create a free ValidMind account.\n",
"
\n",
- "Signing up is FREE —
Register with ValidMind \n",
- "\n",
+ "Signing up is FREE — Register with ValidMind"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
"### 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",
diff --git a/notebooks/templates/install-initialize-validmind.ipynb b/notebooks/templates/install-initialize-validmind.ipynb
index 91b1495c8..a4c82764b 100644
--- a/notebooks/templates/install-initialize-validmind.ipynb
+++ b/notebooks/templates/install-initialize-validmind.ipynb
@@ -24,8 +24,13 @@
"source": [
"## 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.\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."
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
"### 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",
@@ -43,7 +48,7 @@
"\n",
"4. Go to **Getting Started** and click **Copy snippet to clipboard**.\n",
"\n",
- "Next, [load your model identifier credentials from an `.env` file](https://docs.validmind.ai/developer/model-documentation/store-credentials-in-env-file.html) or replace the placeholder with your own code snippet:\n"
+ "Next, [load your model identifier credentials from an `.env` file](https://docs.validmind.ai/developer/model-documentation/store-credentials-in-env-file.html) or replace the placeholder with your own code snippet:"
]
},
{
diff --git a/notebooks/templates/next-steps.ipynb b/notebooks/templates/next-steps.ipynb
index 4ca8fa187..e4086113b 100644
--- a/notebooks/templates/next-steps.ipynb
+++ b/notebooks/templates/next-steps.ipynb
@@ -6,16 +6,26 @@
"source": [
"## Next steps\n",
"\n",
- "You can look at the output produced by the ValidMind Library right in the notebook where you ran the code, as you would expect. But there is a better way: use the ValidMind Platform to work with your model documentation.\n",
- "\n",
+ "You can look at the output produced by the ValidMind Library right in the notebook where you ran the code, as you would expect. But there is a better way: use the ValidMind Platform to work with your model documentation."
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
"### Work with your model documentation\n",
"\n",
"1. From the **Model 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 mode, click **Documentation**.\n",
"\n",
- "What you see is the full draft of your model documentation in a more easily consumable version. From here, you can make qualitative edits to model documentation, view guidelines, collaborate with validators, and submit your model documentation for approval when it's ready. [Learn more ...](https://docs.validmind.ai/guide/working-with-model-documentation.html)\n",
- "\n",
+ "What you see is the full draft of your model documentation in a more easily consumable version. From here, you can make qualitative edits to model documentation, view guidelines, collaborate with validators, and submit your model documentation for approval when it's ready. [Learn more ...](https://docs.validmind.ai/guide/working-with-model-documentation.html)"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
"### Discover more learning resources\n",
"\n",
"We offer many interactive notebooks to help you document models:\n",
From 61538a74fa9639b8481c689adb1a926ec1864591 Mon Sep 17 00:00:00 2001
From: Beck <164545837+validbeck@users.noreply.github.com>
Date: Thu, 2 Jan 2025 12:12:24 -0800
Subject: [PATCH 22/38] Hm
---
.../install-initialize-validmind.ipynb | 22 ++++++++++++++-----
1 file changed, 16 insertions(+), 6 deletions(-)
diff --git a/notebooks/templates/install-initialize-validmind.ipynb b/notebooks/templates/install-initialize-validmind.ipynb
index a4c82764b..9a4fc6f72 100644
--- a/notebooks/templates/install-initialize-validmind.ipynb
+++ b/notebooks/templates/install-initialize-validmind.ipynb
@@ -39,13 +39,23 @@
"\n",
"3. Enter the model details and click **Continue**. ([Need more help?](https://docs.validmind.ai/guide/model-inventory/register-models-in-inventory.html))\n",
"\n",
- " For example, to register a model for use with this notebook, select:\n",
- "\n",
- " - Documentation template: `Template name here`\n",
- " - Use case: `Use case here`\n",
- "\n",
+ " For example, to register a model for use with this notebook, select:"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ " - Documentation template: `{template}`\n",
+ " - Use case: `{use-case}`"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
" You can fill in other options according to your preference.\n",
- "\n",
+ " \n",
"4. Go to **Getting Started** and click **Copy snippet to clipboard**.\n",
"\n",
"Next, [load your model identifier credentials from an `.env` file](https://docs.validmind.ai/developer/model-documentation/store-credentials-in-env-file.html) or replace the placeholder with your own code snippet:"
From 00313a73d5de647a7cbe31057769f6f5bcff8114 Mon Sep 17 00:00:00 2001
From: Beck <164545837+validbeck@users.noreply.github.com>
Date: Thu, 2 Jan 2025 12:18:18 -0800
Subject: [PATCH 23/38] Asking for template & use-case
---
notebooks/templates/e2e_template.py | 25 +++++++++++++++++++++++++
1 file changed, 25 insertions(+)
diff --git a/notebooks/templates/e2e_template.py b/notebooks/templates/e2e_template.py
index 0b7f32543..9351d66c5 100644
--- a/notebooks/templates/e2e_template.py
+++ b/notebooks/templates/e2e_template.py
@@ -120,6 +120,29 @@ def add_about(filepath):
except Exception as e:
print(f"Error appending notebooks: {e}")
+def replace_variables(filepath):
+ """Replaces target variables in the open file based on user input."""
+ try:
+ with open(filepath, "r") as file:
+ content = file.read()
+
+ # Locate and replace {template}
+ if "{template}" in content:
+ template_value = input("Enter a value to replace {template}: ").strip()
+ content = content.replace("{template}", template_value)
+
+ # Locate and replace {use-case}
+ if "{use-case}" in content:
+ use_case_value = input("Enter a value to replace {use-case}: ").strip()
+ content = content.replace("{use-case}", use_case_value)
+
+ with open(filepath, "w") as file:
+ file.write(content)
+
+ print(f"Replaced target variables in '{filepath}'")
+ except Exception as e:
+ print(f"Error replacing variables in file: {e}")
+
def add_install(filepath):
"""Appends the contents of 'install-initialize-validmind.ipynb' to the specified notebook if the user agrees."""
source_notebook_path = os.path.join(os.path.dirname(__file__), "install-initialize-validmind.ipynb")
@@ -156,6 +179,8 @@ def add_install(filepath):
except Exception as e:
print(f"Error appending notebooks: {e}")
+ replace_variables(filepath)
+
def next_steps(filepath):
"""Appends the contents of 'next-steps.ipynb' to the specified notebook if the user agrees."""
source_notebook_path = os.path.join(os.path.dirname(__file__), "next-steps.ipynb")
From 56bf981fc0d638d52b444985379542cb844ef6b6 Mon Sep 17 00:00:00 2001
From: Beck <164545837+validbeck@users.noreply.github.com>
Date: Thu, 2 Jan 2025 12:19:25 -0800
Subject: [PATCH 24/38] Whoo
---
notebooks/templates/e2e-notebook.ipynb | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/notebooks/templates/e2e-notebook.ipynb b/notebooks/templates/e2e-notebook.ipynb
index c35ef1caf..f3086b23a 100644
--- a/notebooks/templates/e2e-notebook.ipynb
+++ b/notebooks/templates/e2e-notebook.ipynb
@@ -254,7 +254,7 @@
"### Wrap it up \n",
"\n",
"- [ ] Review the generated notebook to confirm that everything you expect to be included is there.\n",
- "- [ ] If inserted, adjust the **Documentation template** and **Use case** under `Get your code snippet` from [`install-initialize-validmind.ipynb`](install-initialize-validmind.ipynb) to match your actual requirements.\n",
+ "- [ ] If inserted, confirm that the **Documentation template** and **Use case** under `Get your code snippet` from [`install-initialize-validmind.ipynb`](install-initialize-validmind.ipynb) matches your actual requirements.\n",
"- [ ] Go forth and complete that custom sample!"
]
}
From fec89f73f11a5426f22a589387225141a21d2a9f Mon Sep 17 00:00:00 2001
From: Beck <164545837+validbeck@users.noreply.github.com>
Date: Thu, 2 Jan 2025 12:20:45 -0800
Subject: [PATCH 25/38] Typo
---
notebooks/templates/next-steps.ipynb | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/notebooks/templates/next-steps.ipynb b/notebooks/templates/next-steps.ipynb
index e4086113b..b0d8de8de 100644
--- a/notebooks/templates/next-steps.ipynb
+++ b/notebooks/templates/next-steps.ipynb
@@ -17,7 +17,7 @@
"\n",
"1. From the **Model 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 mode, click **Documentation**.\n",
+ "2. In the left sidebar that appears for your model, click **Documentation**.\n",
"\n",
"What you see is the full draft of your model documentation in a more easily consumable version. From here, you can make qualitative edits to model documentation, view guidelines, collaborate with validators, and submit your model documentation for approval when it's ready. [Learn more ...](https://docs.validmind.ai/guide/working-with-model-documentation.html)"
]
From 8bbb37321ea0b601d72d0ba945cbdd2753be96ee Mon Sep 17 00:00:00 2001
From: Beck <164545837+validbeck@users.noreply.github.com>
Date: Thu, 2 Jan 2025 12:23:23 -0800
Subject: [PATCH 26/38] Tweak
---
notebooks/templates/e2e_template.py | 10 ++++++++--
1 file changed, 8 insertions(+), 2 deletions(-)
diff --git a/notebooks/templates/e2e_template.py b/notebooks/templates/e2e_template.py
index 9351d66c5..149bf5df3 100644
--- a/notebooks/templates/e2e_template.py
+++ b/notebooks/templates/e2e_template.py
@@ -129,12 +129,18 @@ def replace_variables(filepath):
# Locate and replace {template}
if "{template}" in content:
template_value = input("Enter a value to replace {template}: ").strip()
- content = content.replace("{template}", template_value)
+ if not template_value:
+ print("No value entered for {template}, skipping replacement")
+ else:
+ content = content.replace("{template}", template_value)
# Locate and replace {use-case}
if "{use-case}" in content:
use_case_value = input("Enter a value to replace {use-case}: ").strip()
- content = content.replace("{use-case}", use_case_value)
+ if not use_case_value:
+ print("No value entered for {use-case}, skipping replacement")
+ else:
+ content = content.replace("{use-case}", use_case_value)
with open(filepath, "w") as file:
file.write(content)
From 5c2d0dd43fbbdd46e6a0c28fcb9e5c1fd382bb97 Mon Sep 17 00:00:00 2001
From: Beck <164545837+validbeck@users.noreply.github.com>
Date: Thu, 2 Jan 2025 12:26:40 -0800
Subject: [PATCH 27/38] Almost theeeere
---
notebooks/templates/e2e_template.py | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/notebooks/templates/e2e_template.py b/notebooks/templates/e2e_template.py
index 149bf5df3..27f8106dd 100644
--- a/notebooks/templates/e2e_template.py
+++ b/notebooks/templates/e2e_template.py
@@ -126,6 +126,9 @@ def replace_variables(filepath):
with open(filepath, "r") as file:
content = file.read()
+ # Track if any replacements were made
+ replacements_made = False
+
# Locate and replace {template}
if "{template}" in content:
template_value = input("Enter a value to replace {template}: ").strip()
@@ -133,6 +136,7 @@ def replace_variables(filepath):
print("No value entered for {template}, skipping replacement")
else:
content = content.replace("{template}", template_value)
+ replacements_made = True
# Locate and replace {use-case}
if "{use-case}" in content:
@@ -141,11 +145,13 @@ def replace_variables(filepath):
print("No value entered for {use-case}, skipping replacement")
else:
content = content.replace("{use-case}", use_case_value)
+ replacements_made = True
with open(filepath, "w") as file:
file.write(content)
- print(f"Replaced target variables in '{filepath}'")
+ if replacements_made:
+ print(f"Replaced target variables in '{filepath}'")
except Exception as e:
print(f"Error replacing variables in file: {e}")
From 5cf43cc66d840fc172a43d02e448c38f878bb175 Mon Sep 17 00:00:00 2001
From: Beck <164545837+validbeck@users.noreply.github.com>
Date: Thu, 2 Jan 2025 12:33:41 -0800
Subject: [PATCH 28/38] Final? tweak
---
notebooks/templates/e2e_template.py | 2 ++
1 file changed, 2 insertions(+)
diff --git a/notebooks/templates/e2e_template.py b/notebooks/templates/e2e_template.py
index 27f8106dd..1a6dff2b3 100644
--- a/notebooks/templates/e2e_template.py
+++ b/notebooks/templates/e2e_template.py
@@ -136,6 +136,7 @@ def replace_variables(filepath):
print("No value entered for {template}, skipping replacement")
else:
content = content.replace("{template}", template_value)
+ print(f"Template: {template_value}")
replacements_made = True
# Locate and replace {use-case}
@@ -145,6 +146,7 @@ def replace_variables(filepath):
print("No value entered for {use-case}, skipping replacement")
else:
content = content.replace("{use-case}", use_case_value)
+ print(f"Use case: {use_case_value}")
replacements_made = True
with open(filepath, "w") as file:
From 8cf151e39b19469910c06c058fb0c09d5f4b0cd1 Mon Sep 17 00:00:00 2001
From: Beck <164545837+validbeck@users.noreply.github.com>
Date: Thu, 2 Jan 2025 12:35:31 -0800
Subject: [PATCH 29/38] I lied
---
notebooks/templates/e2e_template.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/notebooks/templates/e2e_template.py b/notebooks/templates/e2e_template.py
index 1a6dff2b3..c2a67d327 100644
--- a/notebooks/templates/e2e_template.py
+++ b/notebooks/templates/e2e_template.py
@@ -153,7 +153,7 @@ def replace_variables(filepath):
file.write(content)
if replacements_made:
- print(f"Replaced target variables in '{filepath}'")
+ print(f"Replaced template and use case variables in '{filepath}'")
except Exception as e:
print(f"Error replacing variables in file: {e}")
From 2254714faeeda1985e655e9b412168b52fee1fb1 Mon Sep 17 00:00:00 2001
From: Beck <164545837+validbeck@users.noreply.github.com>
Date: Thu, 2 Jan 2025 12:40:03 -0800
Subject: [PATCH 30/38] Wordiiiing
---
notebooks/templates/e2e-notebook.ipynb | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/notebooks/templates/e2e-notebook.ipynb b/notebooks/templates/e2e-notebook.ipynb
index f3086b23a..0aea82b80 100644
--- a/notebooks/templates/e2e-notebook.ipynb
+++ b/notebooks/templates/e2e-notebook.ipynb
@@ -149,7 +149,9 @@
"\n",
"### Insert installation instructions \n",
"\n",
- "Next, you'll be asked if you want to include the contents of [`install-initialize-validmind.ipynb`](install-initialize-validmind.ipynb). "
+ "Next, you'll be asked if you want to include the contents of [`install-initialize-validmind.ipynb`](install-initialize-validmind.ipynb). \n",
+ "\n",
+ "**You'll also be prompted to enter a `{template}` and a `{use-case}` here if you choose to include the installation instructions.**"
]
},
{
@@ -170,7 +172,7 @@
"\n",
"### Insert next steps \n",
"\n",
- "You'll also be asked if you want to include the contents of [`next-steps.ipynb`](next-steps.ipynb). "
+ "You'll then asked if you want to include the contents of [`next-steps.ipynb`](next-steps.ipynb). "
]
},
{
From 8b5902fa1709c555b5490c39db3c53adcf918bee Mon Sep 17 00:00:00 2001
From: Beck <164545837+validbeck@users.noreply.github.com>
Date: Thu, 2 Jan 2025 12:52:06 -0800
Subject: [PATCH 31/38] Trying something with template IDs
---
notebooks/templates/about-validmind.ipynb | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/notebooks/templates/about-validmind.ipynb b/notebooks/templates/about-validmind.ipynb
index 5aded4975..ace181c85 100644
--- a/notebooks/templates/about-validmind.ipynb
+++ b/notebooks/templates/about-validmind.ipynb
@@ -2,6 +2,7 @@
"cells": [
{
"cell_type": "markdown",
+ "id": "about-intro",
"metadata": {},
"source": [
"## About ValidMind\n",
@@ -13,6 +14,7 @@
},
{
"cell_type": "markdown",
+ "id": "about-begin",
"metadata": {},
"source": [
"### Before you begin\n",
@@ -24,6 +26,7 @@
},
{
"cell_type": "markdown",
+ "id": "about-signup",
"metadata": {},
"source": [
"### New to ValidMind?\n",
@@ -37,6 +40,7 @@
},
{
"cell_type": "markdown",
+ "id": "about-concepts",
"metadata": {},
"source": [
"### Key concepts\n",
From 26d9be13beae51f4a83f361c08385507c2db73d9 Mon Sep 17 00:00:00 2001
From: Beck <164545837+validbeck@users.noreply.github.com>
Date: Thu, 2 Jan 2025 12:53:52 -0800
Subject: [PATCH 32/38] Trying something with template IDs - p2
---
notebooks/templates/install-initialize-validmind.ipynb | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/notebooks/templates/install-initialize-validmind.ipynb b/notebooks/templates/install-initialize-validmind.ipynb
index 9a4fc6f72..9cf155995 100644
--- a/notebooks/templates/install-initialize-validmind.ipynb
+++ b/notebooks/templates/install-initialize-validmind.ipynb
@@ -2,6 +2,7 @@
"cells": [
{
"cell_type": "markdown",
+ "id": "install-library",
"metadata": {},
"source": [
"## Install the ValidMind Library\n",
@@ -11,6 +12,7 @@
},
{
"cell_type": "code",
+ "id": "install-python",
"execution_count": null,
"metadata": {},
"outputs": [],
@@ -20,6 +22,7 @@
},
{
"cell_type": "markdown",
+ "id": "install-initialize",
"metadata": {},
"source": [
"## Initialize the ValidMind Library\n",
@@ -29,6 +32,7 @@
},
{
"cell_type": "markdown",
+ "id": "install-snippet",
"metadata": {},
"source": [
"### Get your code snippet\n",
@@ -44,6 +48,7 @@
},
{
"cell_type": "markdown",
+ "id": "install-variables",
"metadata": {},
"source": [
" - Documentation template: `{template}`\n",
@@ -52,6 +57,7 @@
},
{
"cell_type": "markdown",
+ "id": "install-credentials",
"metadata": {},
"source": [
" You can fill in other options according to your preference.\n",
@@ -63,6 +69,7 @@
},
{
"cell_type": "code",
+ "id": "install-init",
"execution_count": null,
"metadata": {},
"outputs": [],
From a515637e9a3d6e93042494fa4ba0e00e4c8d3b03 Mon Sep 17 00:00:00 2001
From: Beck <164545837+validbeck@users.noreply.github.com>
Date: Thu, 2 Jan 2025 12:54:45 -0800
Subject: [PATCH 33/38] Trying something with template IDs - p3
---
notebooks/templates/next-steps.ipynb | 3 +++
1 file changed, 3 insertions(+)
diff --git a/notebooks/templates/next-steps.ipynb b/notebooks/templates/next-steps.ipynb
index b0d8de8de..655176ef5 100644
--- a/notebooks/templates/next-steps.ipynb
+++ b/notebooks/templates/next-steps.ipynb
@@ -2,6 +2,7 @@
"cells": [
{
"cell_type": "markdown",
+ "id": "next-steps",
"metadata": {},
"source": [
"## Next steps\n",
@@ -11,6 +12,7 @@
},
{
"cell_type": "markdown",
+ "id": "next-docs",
"metadata": {},
"source": [
"### Work with your model documentation\n",
@@ -24,6 +26,7 @@
},
{
"cell_type": "markdown",
+ "id": "next-resources",
"metadata": {},
"source": [
"### Discover more learning resources\n",
From 2ff225ce14aa02bd5a475765134d361e8431eac3 Mon Sep 17 00:00:00 2001
From: Beck <164545837+validbeck@users.noreply.github.com>
Date: Thu, 2 Jan 2025 12:55:35 -0800
Subject: [PATCH 34/38] Trying something with template IDs - p4
---
notebooks/templates/upgrade-validmind.ipynb | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/notebooks/templates/upgrade-validmind.ipynb b/notebooks/templates/upgrade-validmind.ipynb
index 6a630aa50..850282777 100644
--- a/notebooks/templates/upgrade-validmind.ipynb
+++ b/notebooks/templates/upgrade-validmind.ipynb
@@ -2,6 +2,7 @@
"cells": [
{
"cell_type": "markdown",
+ "id": "upgrade-vm",
"metadata": {},
"source": [
"## Upgrade ValidMind\n",
@@ -13,6 +14,7 @@
},
{
"cell_type": "code",
+ "id": "upgrade-show",
"execution_count": null,
"metadata": {
"vscode": {
@@ -26,6 +28,7 @@
},
{
"cell_type": "markdown",
+ "id": "upgrade-version",
"metadata": {},
"source": [
"If the version returned is lower than the version indicated in our [production open-source code](https://github.com/validmind/validmind-library/blob/prod/validmind/__version__.py), restart your notebook and run:\n",
@@ -37,6 +40,7 @@
},
{
"cell_type": "markdown",
+ "id": "upgrade-restart",
"metadata": {},
"source": [
"You may need to restart your kernel after running the upgrade package for changes to be applied."
From 25ca14464e90b3a90ea27345217ab3cf12dce95f Mon Sep 17 00:00:00 2001
From: Beck <164545837+validbeck@users.noreply.github.com>
Date: Thu, 2 Jan 2025 13:04:40 -0800
Subject: [PATCH 35/38] Grabbing original IDs
---
notebooks/templates/e2e_template.py | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/notebooks/templates/e2e_template.py b/notebooks/templates/e2e_template.py
index c2a67d327..3ecd6c0b1 100644
--- a/notebooks/templates/e2e_template.py
+++ b/notebooks/templates/e2e_template.py
@@ -108,7 +108,9 @@ def add_about(filepath):
return
for cell in source_notebook.cells:
- cell["id"] = f"about-{uuid.uuid4()}"
+ original_id = cell.get("id", f"cell-{uuid.uuid4()}")
+ new_id = f"{original_id}-{uuid.uuid4()}"
+ cell["id"] = new_id
target_notebook.cells.extend(source_notebook.cells)
target_notebook = ensure_ids(target_notebook)
From 17bc771ff177d5db7f26128f8432dc7513d1c0f3 Mon Sep 17 00:00:00 2001
From: Beck <164545837+validbeck@users.noreply.github.com>
Date: Thu, 2 Jan 2025 13:06:53 -0800
Subject: [PATCH 36/38] It workssss
---
notebooks/templates/e2e_template.py | 12 +++++++++---
1 file changed, 9 insertions(+), 3 deletions(-)
diff --git a/notebooks/templates/e2e_template.py b/notebooks/templates/e2e_template.py
index 3ecd6c0b1..3973ae3c1 100644
--- a/notebooks/templates/e2e_template.py
+++ b/notebooks/templates/e2e_template.py
@@ -183,7 +183,9 @@ def add_install(filepath):
return
for cell in source_notebook.cells:
- cell["id"] = f"install-{uuid.uuid4()}"
+ original_id = cell.get("id", f"cell-{uuid.uuid4()}")
+ new_id = f"{original_id}-{uuid.uuid4()}"
+ cell["id"] = new_id
target_notebook.cells.extend(source_notebook.cells)
target_notebook = ensure_ids(target_notebook)
@@ -221,7 +223,9 @@ def next_steps(filepath):
return
for cell in source_notebook.cells:
- cell["id"] = f"next-{uuid.uuid4()}"
+ original_id = cell.get("id", f"cell-{uuid.uuid4()}")
+ new_id = f"{original_id}-{uuid.uuid4()}"
+ cell["id"] = new_id
target_notebook.cells.extend(source_notebook.cells)
target_notebook = ensure_ids(target_notebook)
@@ -257,7 +261,9 @@ def add_upgrade(filepath):
return
for cell in source_notebook.cells:
- cell["id"] = f"upgrade-{uuid.uuid4()}"
+ original_id = cell.get("id", f"cell-{uuid.uuid4()}")
+ new_id = f"{original_id}-{uuid.uuid4()}"
+ cell["id"] = new_id
target_notebook.cells.extend(source_notebook.cells)
target_notebook = ensure_ids(target_notebook)
From dbd5f7385b50be0df8fa7261d5ac76c230021487 Mon Sep 17 00:00:00 2001
From: Beck <164545837+validbeck@users.noreply.github.com>
Date: Thu, 2 Jan 2025 15:23:05 -0800
Subject: [PATCH 37/38] Wording
---
notebooks/templates/README.md | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/notebooks/templates/README.md b/notebooks/templates/README.md
index 42dc5d518..70a46d4d7 100644
--- a/notebooks/templates/README.md
+++ b/notebooks/templates/README.md
@@ -2,7 +2,7 @@
Want to create some code samples for ValidMind? Our **[End-to-end notebook template generation](e2e-notebook.ipynb) notebook** will generate a new file with all the bits and pieces of a standard ValidMind notebook to get you started.
-The same functionality is also accesible [in our root folder Makefile](../../Makefile) as a command:
+The same functionality is also accesible [in our root directory Makefile](../../Makefile) as a command:
```bash
make notebook
From 0c5d316999c1ddcb46a75d06aaf9bf4e2f5ced5d Mon Sep 17 00:00:00 2001
From: Beck <164545837+validbeck@users.noreply.github.com>
Date: Fri, 3 Jan 2025 12:38:21 -0800
Subject: [PATCH 38/38] 2.7.3
---
pyproject.toml | 2 +-
validmind/__version__.py | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/pyproject.toml b/pyproject.toml
index 04c8d449e..2eb972312 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -10,7 +10,7 @@ description = "ValidMind Library"
license = "Commercial License"
name = "validmind"
readme = "README.pypi.md"
-version = "2.7.2"
+version = "2.7.3"
[tool.poetry.dependencies]
aiohttp = {extras = ["speedups"], version = "*"}
diff --git a/validmind/__version__.py b/validmind/__version__.py
index 7f9085047..573a7705c 100644
--- a/validmind/__version__.py
+++ b/validmind/__version__.py
@@ -1 +1 @@
-__version__ = "2.7.2"
+__version__ = "2.7.3"