blob: e128cd596dd7db801146b6025ecbddbc0ae2f51d [file] [log] [blame]
{
"cells": [
{
"cell_type": "code",
"execution_count": null,
"id": "initial_id",
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"!pip install \"sf-hamilton[slack]\""
]
},
{
"cell_type": "code",
"outputs": [],
"source": [
"import pandas as pd\n",
"\n",
"from hamilton import driver\n",
"from hamilton.plugins.h_slack import SlackNotifier\n",
"\n",
"# load magic\n",
"%load_ext hamilton.plugins.jupyter_magic"
],
"metadata": {
"collapsed": false
},
"id": "e88039e484e64415"
},
{
"cell_type": "code",
"outputs": [],
"source": [
"%%cell_to_module -m example_module\n",
"def test_function() -> pd.DataFrame:\n",
" raise Exception(\"test exception\")\n",
" return pd.DataFrame({\"a\": [1, 2, 3], \"b\": [4, 5, 6]})"
],
"metadata": {
"collapsed": false
},
"id": "444cc24511d338a3"
},
{
"cell_type": "code",
"outputs": [],
"source": [
"# SLACK DETAILS FOR YOU TO FILL IN\n",
"api_key = \"YOUR_API_KEY\"\n",
"channel = \"YOUR_CHANNEL\""
],
"metadata": {
"collapsed": false
},
"id": "98b516f88f03981c"
},
{
"cell_type": "code",
"outputs": [],
"source": [
"dr = (\n",
" driver.Builder()\n",
" .with_modules(example_module)\n",
" .with_adapters(SlackNotifier(api_key=api_key, channel=channel))\n",
" .build()\n",
")\n",
"print(dr.execute([\"test_function\"]))"
],
"metadata": {
"collapsed": false
},
"id": "48fdfb26417eeb26"
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 2
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython2",
"version": "2.7.6"
}
},
"nbformat": 4,
"nbformat_minor": 5
}