{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# 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": [
    "## 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",
    "<!-- vscode-jupyter-toc-config\n",
    "\tnumbering=false\n",
    "\tanchor=true\n",
    "\tflat=false\n",
    "\tminLevel=2\n",
    "\tmaxLevel=4\n",
    "\t/vscode-jupyter-toc-config -->\n",
    "<!-- THIS CELL WILL BE REPLACED ON TOC UPDATE. DO NOT WRITE YOUR TEXT IN THIS CELL -->"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "<a id='toc1_'></a>\n",
    "\n",
    "## Setting up "
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "<a id='toc1_1_'></a>\n",
    "\n",
    "### Import the notebook creation script \n",
    "\n",
    "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."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "import e2e_template as tm"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "<a id='toc1_2_'></a>\n",
    "\n",
    "### Designate the filename \n",
    "\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. "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "filepath = tm.create_notebook()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "<a id='toc1_3_'></a>\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.\n",
    "\n",
    "If you don't provide input, adding the title will be skipped."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "if filepath:\n",
    "    tm.set_title(filepath)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "<a id='toc2_'></a>\n",
    "\n",
    "## Single-sourcing from mini-templates "
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "<a id='toc2_1_'></a>\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). "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "if filepath:\n",
    "    tm.add_about(filepath)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "<a id='toc2_2_'></a>\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). \n",
    "\n",
    "**You'll also be prompted to enter a `{template}` and a `{use-case}` here if you choose to include the installation instructions.**"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "if filepath:\n",
    "    tm.add_install(filepath)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "<a id='toc2_3_'></a>\n",
    "\n",
    "### Insert next steps \n",
    "\n",
    "You'll then asked if you want to include the contents of [`next-steps.ipynb`](next-steps.ipynb). "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "if filepath:\n",
    "    tm.next_steps(filepath)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "<a id='toc2_4_'></a>\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). "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "if filepath:\n",
    "    tm.add_upgrade(filepath)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "<a id='toc3_'></a>\n",
    "\n",
    "## Next steps \n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "<a id='toc3_1_'></a>\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`. "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "%%bash\n",
    "cd ../../\n",
    "git status | grep -v 'notebooks/templates'"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "<div class=\"alert alert-block alert-info\" style=\"background-color: #B5B5B510; color: black; border: 1px solid #083E44; border-left-width: 5px; box-shadow: 2px 2px 4px rgba(0, 0, 0, 0.2);border-radius: 5px;\"><span style=\"color: #083E44;\"><b>On commiting files</b></span>\n",
    "<br></br>\n",
    "Make sure that when you commit your changes to remote, do NOT include the changes in the <code>~/notebooks/templates</code> folder as that would commit changed notebook with the output cells.</div>"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "\n",
    "<a id='toc3_2_'></a>\n",
    "\n",
    "### Wrap it up \n",
    "\n",
    "- [ ] Review the generated notebook to confirm that everything you expect to be included is there.\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!"
   ]
  }
 ],
 "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
}
