Skip to content

Commit 3828a3d

Browse files
committed
Update to include background thread for production endpoint
1 parent 7a72e56 commit 3828a3d

File tree

1 file changed

+14
-7
lines changed

1 file changed

+14
-7
lines changed

build_pipeline/drift-detection.ipynb

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -487,8 +487,8 @@
487487
"\n",
488488
"\n",
489489
"dataset_location = get_latest_processed_data()\n",
490-
"S3Downloader().download(dataset_location, \"prerocessed\")\n",
491-
"df = pd.read_csv(\"prerocessed/validation.csv\", header=None)\n",
490+
"S3Downloader().download(dataset_location, \"preprocessed\")\n",
491+
"df = pd.read_csv(\"preprocessed/validation.csv\", header=None)\n",
492492
"\n",
493493
"# Changing the distribution of data to artificially cause an alarm\n",
494494
"df[1] = random.choices([1, 2, 3, 4, 5, 6], weights=[2, 1, 2, 5, 2, 1], k=df.shape[0])\n",
@@ -500,7 +500,7 @@
500500
"cell_type": "markdown",
501501
"metadata": {},
502502
"source": [
503-
"Then make a series of prediction requests with this data to cause an artificial model monitoring alarm to be triggered. This will take approx 30 seconds."
503+
"Then make a series of prediction requests in the background every 10 minutes with this data to cause an artificial model monitoring alarm to be triggered."
504504
]
505505
},
506506
{
@@ -509,10 +509,17 @@
509509
"metadata": {},
510510
"outputs": [],
511511
"source": [
512-
"%%time\n",
513-
"endpoint_requests = 1000\n",
514-
"for i in range(endpoint_requests):\n",
515-
" predictor.predict(data=tweaked_rows[i % len(tweaked_rows)])"
512+
"from threading import Thread\n",
513+
"\n",
514+
"\n",
515+
"def invoke_endpoint_forever():\n",
516+
" while True:\n",
517+
" for i in range(10000):\n",
518+
" predictor.predict(data=tweaked_rows[i % len(tweaked_rows)])\n",
519+
" time.sleep(10 * 60)\n",
520+
"\n",
521+
"\n",
522+
"Thread(target=invoke_endpoint_forever).start()"
516523
]
517524
},
518525
{

0 commit comments

Comments
 (0)