Skip to content

Commit

Permalink
chore: pin binder version for users (#1607)
Browse files Browse the repository at this point in the history
* chore: pin binder compatible version

* fix dbfs/databricks case escapes in notebooks

Co-authored-by: Puneet Pruthi <[email protected]>
  • Loading branch information
ppruthi and Puneet Pruthi authored Aug 10, 2022
1 parent c7a61ec commit 93d7ccf
Show file tree
Hide file tree
Showing 9 changed files with 45 additions and 16 deletions.
1 change: 1 addition & 0 deletions notebooks/features/onnx/ONNX - Inference on Spark.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@
"from synapse.ml.core.platform import running_on_binder\n",
"\n",
"if running_on_binder():\n",
" !pip install lightgbm==3.2.1\n",
" from IPython import get_ipython\n",
"import lightgbm as lgb\n",
"from lightgbm import Booster, LGBMClassifier\n",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,12 @@
"metadata": {},
"outputs": [],
"source": [
"spark.sparkContext.setCheckpointDir(\"dbfs:/checkpoint_path/\")\n",
"from synapse.ml.core.platform import running_on_databricks\n",
"\n",
"if running_on_databricks():\n",
" spark.sparkContext.setCheckpointDir(\"dbfs:/checkpoint_path/\")\n",
"else:\n",
" spark.sparkContext.setCheckpointDir(\"/tmp/checkpoint_path/\")\n",
"\n",
"factory = DataFactory(\n",
" num_hr_users=25,\n",
Expand Down Expand Up @@ -445,7 +450,12 @@
"\n",
"p = plot(fig, output_type=\"div\")\n",
"\n",
"displayHTML(p)"
"if running_on_databricks():\n",
" displayHTML(p)\n",
"else:\n",
" import IPython\n",
"\n",
" IPython.display.HTML(p)"
]
},
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
"# Bootstrap Spark Session\n",
"spark = SparkSession.builder.getOrCreate()\n",
"\n",
"from synapse.ml.core.platform import running_on_synapse\n",
"from synapse.ml.core.platform import running_on_synapse, running_on_databricks\n",
"\n",
"if running_on_synapse():\n",
" from notebookutils.visualization import display"
Expand All @@ -71,9 +71,12 @@
"if running_on_synapse():\n",
" modelDir = \"abfss://[email protected]/models/\"\n",
" dataDir = \"./nltkdata\"\n",
"else:\n",
"elif running_on_databricks():\n",
" modelDir = \"dbfs:/models/\"\n",
" dataDir = \"/dbfs/nltkdata\"\n",
"else:\n",
" modelDir = \"/tmp/models/\"\n",
" dataDir = \"/tmp/nltkdata\"\n",
"\n",
"d = ModelDownloader(spark, modelDir)\n",
"modelSchema = d.downloadByName(modelName)\n",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
"# Bootstrap Spark Session\n",
"spark = SparkSession.builder.getOrCreate()\n",
"\n",
"from synapse.ml.core.platform import running_on_synapse\n",
"from synapse.ml.core.platform import running_on_synapse, running_on_databricks\n",
"\n",
"if running_on_synapse():\n",
" from notebookutils.visualization import display"
Expand Down Expand Up @@ -63,8 +63,10 @@
"modelName = \"ConvNet\"\n",
"if running_on_synapse():\n",
" modelDir = \"abfss://[email protected]/models/\"\n",
"elif running_on_databricks():\n",
" modelDir = \"dbfs:/models/\"\n",
"else:\n",
" modelDir = \"dbfs:/models/\""
" modelDir = \"/tmp/models/\""
]
},
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
"# Bootstrap Spark Session\n",
"spark = SparkSession.builder.getOrCreate()\n",
"\n",
"from synapse.ml.core.platform import running_on_synapse\n",
"from synapse.ml.core.platform import running_on_synapse, running_on_databricks\n",
"\n",
"if running_on_synapse():\n",
" from notebookutils.visualization import display"
Expand All @@ -38,8 +38,10 @@
"source": [
"if running_on_synapse():\n",
" modelDir = \"abfss://[email protected]/models/\"\n",
"else:\n",
"elif running_on_databricks():\n",
" modelDir = \"dbfs:/models/\"\n",
"else:\n",
" modelDir = \"/tmp/models/\"\n",
"\n",
"model = ModelDownloader(spark, modelDir).downloadByName(\"ResNet50\")"
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,15 @@
"# Bootstrap Spark Session\n",
"spark = SparkSession.builder.getOrCreate()\n",
"\n",
"from synapse.ml.core.platform import running_on_synapse\n",
"from synapse.ml.core.platform import running_on_synapse, running_on_databricks\n",
"\n",
"modelName = \"ConvNet\"\n",
"if running_on_synapse():\n",
" modelDir = \"abfss://[email protected]/models/\"\n",
"else:\n",
"elif running_on_databricks():\n",
" modelDir = \"dbfs:/models/\"\n",
"else:\n",
" modelDir = \"/tmp/models/\"\n",
"\n",
"d = ModelDownloader(spark, modelDir)\n",
"model = d.downloadByName(modelName)\n",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,12 +125,14 @@
"metadata": {},
"outputs": [],
"source": [
"from synapse.ml.core.platform import running_on_synapse\n",
"from synapse.ml.core.platform import *\n",
"\n",
"if running_on_synapse():\n",
" model_name = \"/models/flightDelayModel.mml\"\n",
"else:\n",
"elif running_on_databricks():\n",
" model_name = \"dbfs:/flightDelayModel.mml\"\n",
"else:\n",
" model_name = \"/tmp/flightDelayModel.mml\"\n",
"\n",
"model.write().overwrite().save(model_name)\n",
"flightDelayModel = TrainedRegressorModel.load(model_name)\n",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"source": [
"import os\n",
"from pyspark.sql import SparkSession\n",
"from synapse.ml.core.platform import running_on_synapse, find_secret\n",
"from synapse.ml.core.platform import *\n",
"\n",
"# Bootstrap Spark Session\n",
"spark = SparkSession.builder.getOrCreate()\n",
Expand Down Expand Up @@ -133,7 +133,12 @@
" header, tableHTML\n",
" )\n",
" try:\n",
" displayHTML(style + body)\n",
" if running_on_databricks():\n",
" displayHTML(style + body)\n",
" else:\n",
" import IPython\n",
"\n",
" IPython.display.HTML(style + body)\n",
" except:\n",
" pass"
],
Expand Down Expand Up @@ -232,8 +237,10 @@
" network = ModelDownloader(\n",
" spark, \"abfss://[email protected]/models/\"\n",
" ).downloadByName(\"ResNet50\")\n",
"else:\n",
"elif running_on_databricks():\n",
" network = ModelDownloader(spark, \"dbfs:/Models/\").downloadByName(\"ResNet50\")\n",
"else:\n",
" network = ModelDownloader(spark, \"/tmp/Models/\").downloadByName(\"ResNet50\")\n",
"\n",
"model = Pipeline(\n",
" stages=[\n",
Expand Down
2 changes: 1 addition & 1 deletion start
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
export OPENMPI_VERSION="3.1.2"
export SPARK_VERSION="3.2.2"
export HADOOP_VERSION="2.7"
export MMLSPARK_VERSION="0.10.0"
export SYNAPSEML_VERSION="0.10.0-26-c7a61ecd-SNAPSHOT" # Binder compatibility version

echo "Beginning Spark Session..."
exec "$@"

0 comments on commit 93d7ccf

Please sign in to comment.