Skip to content

Commit

Permalink
dask example
Browse files Browse the repository at this point in the history
  • Loading branch information
hmeiland committed Jul 5, 2024
1 parent 5ddb317 commit aa5ddd2
Show file tree
Hide file tree
Showing 2 changed files with 168 additions and 0 deletions.
161 changes: 161 additions & 0 deletions examples/Dask/dask.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,161 @@
{
"cells": [
{
"cell_type": "code",
"source": [
"from dask.distributed import Client, LocalCluster, progress\n",
"client = Client(LocalCluster(ip='0.0.0.0', scheduler_port=12345, n_workers=0))\n",
"client"
],
"outputs": [],
"execution_count": null,
"metadata": {
"jupyter": {
"source_hidden": false,
"outputs_hidden": false
},
"nteract": {
"transient": {
"deleting": false
}
},
"gather": {
"logged": 1720186325924
}
}
},
{
"cell_type": "code",
"source": [
"import time\n",
"import random\n",
"\n",
"def inc(x):\n",
" time.sleep(random.random())\n",
" return x + 1\n",
"\n",
"def double(x):\n",
" time.sleep(random.random())\n",
" return 2 * x\n",
"\n",
"def add(x, y):\n",
" time.sleep(random.random())\n",
" return x + y\n",
" "
],
"outputs": [],
"execution_count": null,
"metadata": {
"gather": {
"logged": 1720186729193
}
}
},
{
"cell_type": "code",
"source": [
"zs = []"
],
"outputs": [],
"execution_count": null,
"metadata": {
"jupyter": {
"source_hidden": false,
"outputs_hidden": false
},
"nteract": {
"transient": {
"deleting": false
}
},
"gather": {
"logged": 1720186731185
}
}
},
{
"cell_type": "code",
"source": [
"%%time\n",
"\n",
"for i in range(1024):\n",
" x = client.submit(inc, i) # x = inc(i)\n",
" y = client.submit(double, x) # y = inc(x)\n",
" z = client.submit(add, x, y) # z = inc(y)\n",
" zs.append(z)"
],
"outputs": [],
"execution_count": null,
"metadata": {
"jupyter": {
"source_hidden": false,
"outputs_hidden": false
},
"nteract": {
"transient": {
"deleting": false
}
}
}
},
{
"cell_type": "code",
"source": [
"client.shutdown()"
],
"outputs": [],
"execution_count": null,
"metadata": {
"jupyter": {
"source_hidden": false,
"outputs_hidden": false
},
"nteract": {
"transient": {
"deleting": false
}
},
"gather": {
"logged": 1720187187366
}
}
}
],
"metadata": {
"kernelspec": {
"name": "python38-azureml",
"language": "python",
"display_name": "Python 3.8 - AzureML"
},
"language_info": {
"name": "python",
"version": "3.9.19",
"mimetype": "text/x-python",
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"pygments_lexer": "ipython3",
"nbconvert_exporter": "python",
"file_extension": ".py"
},
"microsoft": {
"ms_spell_check": {
"ms_spell_check_language": "en"
},
"host": {
"AzureML": {
"notebookHasBeenCompleted": true
}
}
},
"kernel_info": {
"name": "python38-azureml"
},
"nteract": {
"version": "nteract-front-end@1.0.0"
}
},
"nbformat": 4,
"nbformat_minor": 2
}
7 changes: 7 additions & 0 deletions examples/Dask/dask.job
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/bin/bash

conda init
source activate base
pip install dask==2023.2.0 distributed==2023.2.0
export PATH=$PATH:/home/azureuser/.local/bin
dask worker tcp://10.0.1.5:12345

0 comments on commit aa5ddd2

Please sign in to comment.