Skip to content

Commit a49c62c

Browse files
committed
wip
1 parent 3fa3ecd commit a49c62c

File tree

6 files changed

+620
-42
lines changed

6 files changed

+620
-42
lines changed

01_dask.delayed.ipynb

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -251,11 +251,7 @@
251251
{
252252
"cell_type": "code",
253253
"execution_count": null,
254-
"metadata": {
255-
"jupyter": {
256-
"source_hidden": true
257-
}
258-
},
254+
"metadata": {},
259255
"outputs": [],
260256
"source": [
261257
"results = []\n",
@@ -343,11 +339,7 @@
343339
{
344340
"cell_type": "code",
345341
"execution_count": null,
346-
"metadata": {
347-
"jupyter": {
348-
"source_hidden": true
349-
}
350-
},
342+
"metadata": {},
351343
"outputs": [],
352344
"source": [
353345
"results = []\n",
@@ -649,11 +641,7 @@
649641
{
650642
"cell_type": "code",
651643
"execution_count": null,
652-
"metadata": {
653-
"jupyter": {
654-
"source_hidden": true
655-
}
656-
},
644+
"metadata": {},
657645
"outputs": [],
658646
"source": [
659647
"# This is just one possible solution, there are\n",
@@ -717,7 +705,7 @@
717705
"cell_type": "markdown",
718706
"metadata": {},
719707
"source": [
720-
"# Close the Client\n",
708+
"## Shutdown\n",
721709
"\n",
722710
"Before moving on to the next exercise, make sure to close your client or stop this kernel."
723711
]

01x_lazy.ipynb

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,12 @@
3535
"As Python programmers, you probably already perform certain *tricks* to enable computation of larger-than-memory datasets, parallel execution or delayed/background execution. Perhaps with this phrasing, it is not clear what we mean, but a few examples should make things clearer. The point of Dask is to make simple things easy and complex things possible!\n",
3636
"\n",
3737
"Aside from the [detailed introduction](http://dask.pydata.org/en/latest/), we can summarize the basics of Dask as follows:\n",
38+
"\n",
3839
"- process data that doesn't fit into memory by breaking it into blocks and specifying task chains\n",
3940
"- parallelize execution of tasks across cores and even nodes of a cluster\n",
40-
"- move computation to the data rather than the other way around, to minimize communication overheads\n",
41+
"- move computation to the data rather than the other way around, to minimize communication overhead\n",
4142
"\n",
42-
"All of this allows you to get the most out of your computation resources, but program in a way that is very familiar: for-loops to build basic tasks, Python iterators, and the Numpy (array) and Pandas (dataframe) functions for multi-dimensional or tabular data, respectively.\n",
43+
"All of this allows you to get the most out of your computation resources, but program in a way that is very familiar: for-loops to build basic tasks, Python iterators, and the NumPy (array) and Pandas (dataframe) functions for multi-dimensional or tabular data, respectively.\n",
4344
"\n",
4445
"The remainder of this notebook will take you through the first of these programming paradigms. This is more detail than some users will want, who can skip ahead to the iterator, array and dataframe sections; but there will be some data processing tasks that don't easily fit into those abstractions and need to fall back to the methods here.\n",
4546
"\n",
@@ -81,7 +82,7 @@
8182
"cell_type": "markdown",
8283
"metadata": {},
8384
"source": [
84-
"Here we have used the delayed annotation to show that we want these functions to operate lazily - to save the set of inputs and execute only on demand. `dask.delayed` is also a function which can do this, without the annotation, leaving the original function unchanged, e.g., \n",
85+
"Here we have used the delayed annotation to show that we want these functions to operate lazily to save the set of inputs and execute only on demand. `dask.delayed` is also a function which can do this, without the annotation, leaving the original function unchanged, e.g.,\n",
8586
"```python\n",
8687
" delayed_inc = delayed(inc)\n",
8788
"```"
@@ -146,7 +147,7 @@
146147
"\n",
147148
"By building a specification of the calculation we want to carry out before executing anything, we can pass the specification to an *execution engine* for evaluation. In the case of Dask, this execution engine could be running on many nodes of a cluster, so you have access to the full number of CPU cores and memory across all the machines. Dask will intelligently execute your calculation with care for minimizing the amount of data held in memory, while parallelizing over the tasks that make up a graph. Notice that in the animated diagram below, where four workers are processing the (simple) graph, execution progresses vertically up the branches first, so that intermediate results can be expunged before moving onto a new branch.\n",
148149
"\n",
149-
"With `delayed` and normal pythonic looped code, very complex graphs can be built up and passed on to Dask for execution. See a nice example of [simulated complex ETL](http://matthewrocklin.com/blog/work/2017/01/24/dask-custom) work flow.\n",
150+
"With `delayed` and normal pythonic looped code, very complex graphs can be built up and passed on to Dask for execution. See a nice example of [simulated complex ETL](https://blog.dask.org/2017/01/24/dask-custom) work flow.\n",
150151
"\n",
151152
"![this](images/grid_search_schedule.gif)"
152153
]
@@ -251,11 +252,7 @@
251252
{
252253
"cell_type": "code",
253254
"execution_count": null,
254-
"metadata": {
255-
"jupyter": {
256-
"source_hidden": true
257-
}
258-
},
255+
"metadata": {},
259256
"outputs": [],
260257
"source": [
261258
"## verbose version\n",

03_array.ipynb

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,8 @@
210210
"outputs": [],
211211
"source": [
212212
"import dask.array as da\n",
213-
"x = da.from_array(dset, chunks=(1000000,))"
213+
"x = da.from_array(dset, chunks=(1000000,))\n",
214+
"x"
214215
]
215216
},
216217
{
@@ -554,7 +555,7 @@
554555
"import matplotlib.pyplot as plt\n",
555556
"\n",
556557
"fig = plt.figure(figsize=(16, 8))\n",
557-
"plt.imshow(dsets[0][::4, ::4], cmap='RdBu_r')"
558+
"plt.imshow(dsets[0][::4, ::4], cmap='RdBu_r');"
558559
]
559560
},
560561
{
@@ -644,12 +645,16 @@
644645
{
645646
"cell_type": "code",
646647
"execution_count": null,
647-
"metadata": {},
648+
"metadata": {
649+
"jupyter": {
650+
"source_hidden": true
651+
}
652+
},
648653
"outputs": [],
649654
"source": [
650655
"result = x.mean(axis=0)\n",
651656
"fig = plt.figure(figsize=(16, 8))\n",
652-
"plt.imshow(result, cmap='RdBu_r')"
657+
"plt.imshow(result, cmap='RdBu_r');"
653658
]
654659
},
655660
{
@@ -669,12 +674,16 @@
669674
{
670675
"cell_type": "code",
671676
"execution_count": null,
672-
"metadata": {},
677+
"metadata": {
678+
"jupyter": {
679+
"source_hidden": true
680+
}
681+
},
673682
"outputs": [],
674683
"source": [
675684
"result = x[0] - x.mean(axis=0)\n",
676685
"fig = plt.figure(figsize=(16, 8))\n",
677-
"plt.imshow(result, cmap='RdBu_r')"
686+
"plt.imshow(result, cmap='RdBu_r');"
678687
]
679688
},
680689
{

05_distributed.ipynb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,8 @@
8080
"for sch in ['threading', 'processes', 'sync']:\n",
8181
" t0 = time.time()\n",
8282
" _ = largest_delay.compute(scheduler=sch)\n",
83-
" print(sch, time.time() - t0)"
83+
" t1 = time.time()\n",
84+
" print(f\"{sch:>10}, {t1 - t0:0.4f}\")"
8485
]
8586
},
8687
{

0 commit comments

Comments
 (0)