{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {
    "application/vnd.databricks.v1+cell": {
     "cellMetadata": {},
     "inputWidgets": {},
     "nuid": "0c93c5cf-e2bb-4886-846e-95c82d6596cc",
     "showTitle": false,
     "title": ""
    }
   },
   "source": [
    "![JohnSnowLabs](https://nlp.johnsnowlabs.com/assets/images/logo.png)\n",
    "\n",
    "# Parameterized Notebook example\n",
    "This notebook illustrates how you can parameterize a notebook submitted with `nlp.run_in_databricks()` , for more infos see [the documentation](https://nlp.johnsnowlabs.com/docs/en/jsl/databricks-utils)\n",
    "For more information about ipywidgets, see [the ipywidgets documentation](https://ipywidgets.readthedocs.io/en/7.7.0/index.html).\n",
    "## Requirements\n",
    "Databricks Runtime 11.0 or above and cluster created by nlp.install()\n",
    "\n",
    "\n",
    "```python\n",
    "dbutils.widgets.text(\"my_parameter\", \"my_default_value\")\n",
    "\n",
    "param_value = dbutils.widgets.get(\"my_parameter\")\n",
    "```"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "application/vnd.databricks.v1+cell": {
     "cellMetadata": {},
     "inputWidgets": {},
     "nuid": "0ac66245-8e8e-49ba-be10-c00b41f0ed3d",
     "showTitle": false,
     "title": ""
    },
    "pycharm": {
     "is_executing": true
    }
   },
   "outputs": [],
   "source": [
    "# parameterized_notebook_example\n",
    "from johnsnowlabs import nlp \n",
    "# define parameters for which pipeline to load and which text to predict on \n",
    "dbutils.widgets.text(\"model_name\", \"tokenize\")\n",
    "dbutils.widgets.text(\"input_text\", \"Hello World\")\n",
    "\n",
    "\n",
    "model_name = dbutils.widgets.get(\"model_name\")\n",
    "input_text = dbutils.widgets.get(\"input_text\")\n",
    "print(f\"Loading {model_name}\")\n",
    "\n",
    "model = nlp.load(model_name)\n",
    "model.predict(input_text)"
   ]
  },
  {
   "cell_type": "markdown",
   "source": [],
   "metadata": {
    "collapsed": false
   }
  }
 ],
 "metadata": {
  "application/vnd.databricks.v1+notebook": {
   "dashboards": [],
   "language": "python",
   "notebookMetadata": {
    "mostRecentlyExecutedCommandWithImplicitDF": {
     "commandId": 3174241471075860,
     "dataframes": [
      "_sqldf"
     ]
    },
    "pythonIndentUnit": 2
   },
   "notebookName": "ipywidgets",
   "widgets": {
    "database": {
     "currentValue": "customers_dev",
     "nuid": "2a670198-9bb6-42e8-8afa-174acfe607d9",
     "widgetInfo": {
      "widgetType": "dropdown",
      "defaultValue": "default",
      "label": null,
      "name": "database",
      "options": {
       "widgetType": "dropdown",
       "choices": [
        "ade",
        "default",
        "icd10",
        "jslonc",
        "marketplace_test",
        "ocr_sample_pdfs",
        "umls"
       ]
      }
     }
    },
    "state": {
     "currentValue": "CA",
     "nuid": "69e94065-8001-46c3-9643-bf3d50688904",
     "widgetInfo": {
      "widgetType": "dropdown",
      "defaultValue": "CA",
      "label": null,
      "name": "state",
      "options": {
       "widgetType": "dropdown",
       "choices": [
        "CA",
        "IL",
        "MI",
        "NY",
        "OR",
        "VA"
       ]
      }
     }
    },
    "table": {
     "currentValue": "",
     "nuid": "f16aa806-d585-468f-811e-a0d34215745f",
     "widgetInfo": {
      "widgetType": "text",
      "defaultValue": "",
      "label": null,
      "name": "table",
      "options": {
       "widgetType": "text",
       "validationRegex": null
      }
     }
    }
   }
  }
 },
 "nbformat": 4,
 "nbformat_minor": 0
}
