/usr/share/doc/python-distributed-doc/html/api.html is in python-distributed-doc 1.20.2+ds.1-2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 2023 2024 2025 2026 2027 2028 2029 2030 2031 2032 2033 2034 2035 2036 2037 2038 2039 2040 2041 2042 2043 2044 2045 2046 2047 2048 2049 2050 2051 2052 2053 2054 2055 2056 2057 2058 2059 2060 2061 2062 2063 2064 2065 2066 2067 2068 2069 2070 2071 2072 2073 2074 2075 2076 2077 2078 2079 2080 2081 2082 2083 2084 2085 2086 2087 2088 2089 2090 2091 2092 2093 2094 2095 2096 2097 2098 2099 2100 2101 2102 2103 2104 2105 2106 2107 2108 2109 2110 2111 2112 2113 2114 2115 2116 2117 2118 2119 2120 2121 2122 2123 2124 2125 2126 2127 2128 2129 2130 2131 2132 2133 2134 2135 2136 2137 2138 2139 2140 2141 2142 2143 2144 2145 2146 2147 2148 2149 2150 2151 2152 2153 2154 2155 2156 2157 2158 2159 2160 2161 2162 2163 2164 2165 2166 2167 2168 2169 2170 2171 2172 2173 2174 2175 2176 2177 2178 2179 2180 2181 2182 2183 2184 2185 2186 2187 2188 2189 2190 2191 2192 2193 2194 2195 2196 2197 2198 2199 2200 2201 2202 2203 2204 2205 2206 2207 2208 2209 2210 2211 2212 2213 2214 2215 2216 2217 2218 2219 2220 2221 2222 2223 2224 2225 2226 2227 2228 2229 2230 2231 2232 2233 2234 2235 2236 2237 2238 2239 2240 2241 2242 2243 2244 2245 2246 2247 2248 2249 2250 2251 2252 2253 2254 2255 2256 2257 2258 2259 2260 2261 2262 2263 2264 2265 2266 2267 2268 2269 2270 2271 2272 2273 2274 2275 2276 2277 2278 2279 2280 2281 2282 2283 2284 2285 2286 2287 2288 2289 2290 2291 2292 2293 2294 2295 2296 2297 2298 2299 2300 2301 2302 2303 2304 2305 2306 2307 2308 2309 2310 2311 2312 2313 2314 2315 2316 2317 2318 2319 2320 2321 2322 2323 2324 2325 2326 2327 2328 2329 2330 2331 2332 2333 2334 2335 2336 2337 2338 2339 2340 2341 2342 2343 2344 2345 2346 2347 2348 2349 2350 2351 2352 2353 2354 2355 2356 2357 2358 2359 2360 2361 2362 2363 2364 2365 2366 2367 2368 2369 2370 2371 2372 2373 2374 2375 2376 2377 2378 2379 2380 2381 2382 2383 2384 2385 2386 2387 2388 2389 2390 2391 2392 2393 2394 2395 2396 2397 2398 2399 2400 2401 2402 2403 2404 2405 2406 2407 2408 2409 2410 2411 2412 2413 2414 2415 2416 2417 2418 2419 2420 2421 2422 2423 2424 2425 2426 2427 2428 2429 2430 2431 2432 2433 2434 2435 2436 2437 2438 2439 2440 2441 2442 2443 2444 2445 2446 2447 2448 2449 2450 2451 2452 2453 2454 2455 2456 2457 2458 2459 2460 2461 2462 2463 2464 2465 2466 2467 2468 2469 2470 2471 2472 2473 2474 2475 2476 2477 2478 2479 2480 2481 2482 2483 2484 2485 2486 2487 2488 2489 2490 2491 2492 2493 2494 2495 2496 2497 2498 2499 2500 2501 2502 2503 2504 2505 2506 2507 2508 2509 2510 2511 2512 2513 2514 2515 2516 2517 2518 2519 2520 2521 2522 2523 2524 2525 2526 2527 2528 2529 2530 2531 2532 2533 2534 2535 2536 2537 2538 2539 2540 2541 2542 2543 2544 2545 2546 2547 2548 2549 2550 2551 2552 2553 2554 2555 2556 2557 2558 2559 2560 2561 2562 2563 2564 2565 2566 2567 2568 2569 2570 2571 2572 2573 2574 2575 2576 2577 2578 2579 2580 2581 2582 2583 2584 2585 2586 2587 2588 2589 2590 2591 2592 2593 2594 2595 2596 2597 2598 2599 2600 2601 2602 2603 2604 2605 2606 2607 2608 2609 2610 2611 2612 2613 2614 2615 2616 2617 2618 2619 2620 2621 2622 2623 2624 2625 2626 2627 2628 2629 2630 2631 2632 2633 2634 2635 2636 2637 2638 2639 2640 2641 2642 2643 2644 2645 2646 2647 2648 2649 2650 2651 2652 2653 2654 2655 2656 2657 2658 2659 2660 2661 2662 2663 2664 2665 2666 2667 2668 2669 2670 2671 2672 2673 2674 2675 2676 2677 2678 2679 2680 2681 2682 2683 2684 2685 2686 2687 2688 2689 2690 2691 2692 2693 2694 2695 2696 2697 2698 2699 2700 2701 2702 2703 2704 2705 2706 2707 2708 2709 2710 2711 2712 2713 2714 2715 2716 2717 2718 2719 2720 2721 2722 2723 2724 2725 2726 2727 2728 2729 2730 2731 2732 2733 2734 2735 2736 2737 2738 2739 2740 2741 2742 2743 2744 2745 2746 2747 2748 2749 2750 2751 2752 2753 2754 2755 2756 2757 2758 2759 2760 2761 2762 2763 2764 2765 2766 2767 2768 2769 2770 2771 2772 2773 2774 2775 2776 2777 2778 2779 2780 2781 2782 2783 2784 2785 2786 2787 2788 2789 2790 2791 2792 2793 2794 2795 2796 2797 2798 2799 2800 2801 2802 2803 2804 2805 2806 2807 2808 2809 2810 2811 2812 2813 2814 2815 2816 2817 2818 2819 2820 2821 2822 2823 2824 2825 2826 2827 2828 2829 2830 2831 2832 2833 2834 2835 2836 2837 2838 2839 2840 2841 2842 2843 2844 2845 2846 2847 2848 2849 2850 2851 2852 2853 2854 2855 2856 2857 2858 2859 2860 2861 2862 2863 2864 2865 2866 2867 2868 2869 2870 2871 2872 2873 2874 2875 2876 2877 2878 2879 2880 2881 2882 2883 2884 2885 2886 2887 2888 2889 2890 2891 2892 2893 2894 2895 2896 2897 2898 2899 2900 2901 2902 2903 2904 2905 2906 2907 2908 2909 | <!DOCTYPE html>
<!--[if IE 8]><html class="no-js lt-ie9" lang="en" > <![endif]-->
<!--[if gt IE 8]><!--> <html class="no-js" lang="en" > <!--<![endif]-->
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>API — Dask.distributed 0+unknown documentation</title>
<link rel="stylesheet" href="_static/css/theme.css" type="text/css" />
<link rel="index" title="Index"
href="genindex.html"/>
<link rel="search" title="Search" href="search.html"/>
<link rel="top" title="Dask.distributed 0+unknown documentation" href="index.html"/>
<link rel="next" title="Frequently Asked Questions" href="faq.html"/>
<link rel="prev" title="Client" href="client.html"/>
<script src="_static/js/modernizr.min.js"></script>
</head>
<body class="wy-body-for-nav" role="document">
<div class="wy-grid-for-nav">
<nav data-toggle="wy-nav-shift" class="wy-nav-side">
<div class="wy-side-scroll">
<div class="wy-side-nav-search">
<a href="index.html" class="icon icon-home"> Dask.distributed
</a>
<div class="version">
0+unknown
</div>
<div role="search">
<form id="rtd-search-form" class="wy-form" action="search.html" method="get">
<input type="text" name="q" placeholder="Search docs" />
<input type="hidden" name="check_keywords" value="yes" />
<input type="hidden" name="area" value="default" />
</form>
</div>
</div>
<div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="main navigation">
<p class="caption"><span class="caption-text">Getting Started</span></p>
<ul class="current">
<li class="toctree-l1"><a class="reference internal" href="install.html">Install Dask.Distributed</a></li>
<li class="toctree-l1"><a class="reference internal" href="quickstart.html">Quickstart</a></li>
<li class="toctree-l1"><a class="reference internal" href="setup.html">Setup Network</a></li>
<li class="toctree-l1"><a class="reference internal" href="client.html">Client</a></li>
<li class="toctree-l1 current"><a class="current reference internal" href="#">API</a><ul>
<li class="toctree-l2"><a class="reference internal" href="#asynchronous-methods">Asynchronous methods</a></li>
<li class="toctree-l2"><a class="reference internal" href="#client">Client</a></li>
<li class="toctree-l2"><a class="reference internal" href="#future">Future</a></li>
<li class="toctree-l2"><a class="reference internal" href="#other">Other</a></li>
<li class="toctree-l2"><a class="reference internal" href="#asyncio-client">Asyncio Client</a></li>
<li class="toctree-l2"><a class="reference internal" href="#adaptive">Adaptive</a></li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="faq.html">Frequently Asked Questions</a></li>
</ul>
<p class="caption"><span class="caption-text">Build Understanding</span></p>
<ul>
<li class="toctree-l1"><a class="reference internal" href="diagnosing-performance.html">Diagnosing Performance</a></li>
<li class="toctree-l1"><a class="reference internal" href="efficiency.html">Efficiency</a></li>
<li class="toctree-l1"><a class="reference internal" href="limitations.html">Limitations</a></li>
<li class="toctree-l1"><a class="reference internal" href="locality.html">Data Locality</a></li>
<li class="toctree-l1"><a class="reference internal" href="manage-computation.html">Managing Computation</a></li>
<li class="toctree-l1"><a class="reference internal" href="memory.html">Managing Memory</a></li>
<li class="toctree-l1"><a class="reference internal" href="related-work.html">Related Work</a></li>
<li class="toctree-l1"><a class="reference internal" href="resilience.html">Resilience</a></li>
<li class="toctree-l1"><a class="reference internal" href="scheduling-policies.html">Scheduling Policies</a></li>
<li class="toctree-l1"><a class="reference internal" href="scheduling-state.html">Scheduling State</a></li>
<li class="toctree-l1"><a class="reference internal" href="worker.html">Worker</a></li>
<li class="toctree-l1"><a class="reference internal" href="work-stealing.html">Work Stealing</a></li>
</ul>
<p class="caption"><span class="caption-text">Additional Features</span></p>
<ul>
<li class="toctree-l1"><a class="reference internal" href="adaptive.html">Adaptive Deployments</a></li>
<li class="toctree-l1"><a class="reference internal" href="asynchronous.html">Asynchronous Operation</a></li>
<li class="toctree-l1"><a class="reference internal" href="configuration.html">Configuration</a></li>
<li class="toctree-l1"><a class="reference internal" href="ec2.html">EC2 Startup Script</a></li>
<li class="toctree-l1"><a class="reference internal" href="local-cluster.html">Local Cluster</a></li>
<li class="toctree-l1"><a class="reference internal" href="ipython.html">IPython Integration</a></li>
<li class="toctree-l1"><a class="reference internal" href="joblib.html">Joblib Integration</a></li>
<li class="toctree-l1"><a class="reference internal" href="publish.html">Publish Datasets</a></li>
<li class="toctree-l1"><a class="reference internal" href="queues.html">Data Streams with Queues</a></li>
<li class="toctree-l1"><a class="reference internal" href="resources.html">Worker Resources</a></li>
<li class="toctree-l1"><a class="reference internal" href="submitting-applications.html">Submitting Applications</a></li>
<li class="toctree-l1"><a class="reference internal" href="task-launch.html">Launch Tasks from Tasks</a></li>
<li class="toctree-l1"><a class="reference internal" href="tls.html">TLS/SSL</a></li>
<li class="toctree-l1"><a class="reference internal" href="web.html">Web Interface</a></li>
</ul>
<p class="caption"><span class="caption-text">Developer Documentation</span></p>
<ul>
<li class="toctree-l1"><a class="reference internal" href="changelog.html">Changelog</a></li>
<li class="toctree-l1"><a class="reference internal" href="communications.html">Communications</a></li>
<li class="toctree-l1"><a class="reference internal" href="develop.html">Development Guidelines</a></li>
<li class="toctree-l1"><a class="reference internal" href="foundations.html">Foundations</a></li>
<li class="toctree-l1"><a class="reference internal" href="journey.html">Journey of a Task</a></li>
<li class="toctree-l1"><a class="reference internal" href="protocol.html">Protocol</a></li>
<li class="toctree-l1"><a class="reference internal" href="serialization.html">Custom Serialization</a></li>
<li class="toctree-l1"><a class="reference internal" href="plugins.html">Scheduler Plugins</a></li>
</ul>
</div>
</div>
</nav>
<section data-toggle="wy-nav-shift" class="wy-nav-content-wrap">
<nav class="wy-nav-top" role="navigation" aria-label="top navigation">
<i data-toggle="wy-nav-top" class="fa fa-bars"></i>
<a href="index.html">Dask.distributed</a>
</nav>
<div class="wy-nav-content">
<div class="rst-content">
<div role="navigation" aria-label="breadcrumbs navigation">
<ul class="wy-breadcrumbs">
<li><a href="index.html">Docs</a> »</li>
<li>API</li>
<li class="wy-breadcrumbs-aside">
<a href="_sources/api.rst.txt" rel="nofollow"> View page source</a>
</li>
</ul>
<hr/>
</div>
<div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article">
<div itemprop="articleBody">
<div class="section" id="api">
<span id="id1"></span><h1>API<a class="headerlink" href="#api" title="Permalink to this headline">¶</a></h1>
<p><strong>Client</strong></p>
<table border="1" class="longtable docutils">
<colgroup>
<col width="10%" />
<col width="90%" />
</colgroup>
<tbody valign="top">
<tr class="row-odd"><td><a class="reference internal" href="#distributed.client.Client" title="distributed.client.Client"><code class="xref py py-obj docutils literal"><span class="pre">Client</span></code></a>([address, loop, timeout, …])</td>
<td>Connect to and drive computation on a distributed Dask cluster</td>
</tr>
<tr class="row-even"><td><a class="reference internal" href="#distributed.client.Client.call_stack" title="distributed.client.Client.call_stack"><code class="xref py py-obj docutils literal"><span class="pre">Client.call_stack</span></code></a>([futures, keys])</td>
<td>The actively running call stack of all relevant keys</td>
</tr>
<tr class="row-odd"><td><a class="reference internal" href="#distributed.client.Client.cancel" title="distributed.client.Client.cancel"><code class="xref py py-obj docutils literal"><span class="pre">Client.cancel</span></code></a>(futures[, asynchronous, force])</td>
<td>Cancel running futures</td>
</tr>
<tr class="row-even"><td><a class="reference internal" href="#distributed.client.Client.close" title="distributed.client.Client.close"><code class="xref py py-obj docutils literal"><span class="pre">Client.close</span></code></a>([timeout])</td>
<td>Close this client</td>
</tr>
<tr class="row-odd"><td><a class="reference internal" href="#distributed.client.Client.compute" title="distributed.client.Client.compute"><code class="xref py py-obj docutils literal"><span class="pre">Client.compute</span></code></a>(collections[, sync, …])</td>
<td>Compute dask collections on cluster</td>
</tr>
<tr class="row-even"><td><a class="reference internal" href="#distributed.client.Client.gather" title="distributed.client.Client.gather"><code class="xref py py-obj docutils literal"><span class="pre">Client.gather</span></code></a>(futures[, errors, maxsize, …])</td>
<td>Gather futures from distributed memory</td>
</tr>
<tr class="row-odd"><td><a class="reference internal" href="#distributed.client.Client.get" title="distributed.client.Client.get"><code class="xref py py-obj docutils literal"><span class="pre">Client.get</span></code></a>(dsk, keys[, restrictions, …])</td>
<td>Compute dask graph</td>
</tr>
<tr class="row-even"><td><a class="reference internal" href="#distributed.client.Client.get_dataset" title="distributed.client.Client.get_dataset"><code class="xref py py-obj docutils literal"><span class="pre">Client.get_dataset</span></code></a>(name, **kwargs)</td>
<td>Get named dataset from the scheduler</td>
</tr>
<tr class="row-odd"><td><a class="reference internal" href="#distributed.client.Client.get_executor" title="distributed.client.Client.get_executor"><code class="xref py py-obj docutils literal"><span class="pre">Client.get_executor</span></code></a>(**kwargs)</td>
<td>Return a concurrent.futures Executor for submitting tasks on this Client.</td>
</tr>
<tr class="row-even"><td><a class="reference internal" href="#distributed.client.Client.get_metadata" title="distributed.client.Client.get_metadata"><code class="xref py py-obj docutils literal"><span class="pre">Client.get_metadata</span></code></a>(keys[, default])</td>
<td>Get arbitrary metadata from scheduler</td>
</tr>
<tr class="row-odd"><td><a class="reference internal" href="#distributed.client.Client.get_scheduler_logs" title="distributed.client.Client.get_scheduler_logs"><code class="xref py py-obj docutils literal"><span class="pre">Client.get_scheduler_logs</span></code></a>([n])</td>
<td>Get logs from scheduler</td>
</tr>
<tr class="row-even"><td><a class="reference internal" href="#distributed.client.Client.get_worker_logs" title="distributed.client.Client.get_worker_logs"><code class="xref py py-obj docutils literal"><span class="pre">Client.get_worker_logs</span></code></a>([n, workers])</td>
<td>Get logs from workers</td>
</tr>
<tr class="row-odd"><td><a class="reference internal" href="#distributed.client.Client.has_what" title="distributed.client.Client.has_what"><code class="xref py py-obj docutils literal"><span class="pre">Client.has_what</span></code></a>([workers])</td>
<td>Which keys are held by which workers</td>
</tr>
<tr class="row-even"><td><a class="reference internal" href="#distributed.client.Client.list_datasets" title="distributed.client.Client.list_datasets"><code class="xref py py-obj docutils literal"><span class="pre">Client.list_datasets</span></code></a>(**kwargs)</td>
<td>List named datasets available on the scheduler</td>
</tr>
<tr class="row-odd"><td><a class="reference internal" href="#distributed.client.Client.map" title="distributed.client.Client.map"><code class="xref py py-obj docutils literal"><span class="pre">Client.map</span></code></a>(func, *iterables, **kwargs)</td>
<td>Map a function on a sequence of arguments</td>
</tr>
<tr class="row-even"><td><a class="reference internal" href="#distributed.client.Client.ncores" title="distributed.client.Client.ncores"><code class="xref py py-obj docutils literal"><span class="pre">Client.ncores</span></code></a>([workers])</td>
<td>The number of threads/cores available on each worker node</td>
</tr>
<tr class="row-odd"><td><a class="reference internal" href="#distributed.client.Client.persist" title="distributed.client.Client.persist"><code class="xref py py-obj docutils literal"><span class="pre">Client.persist</span></code></a>(collections[, …])</td>
<td>Persist dask collections on cluster</td>
</tr>
<tr class="row-even"><td><a class="reference internal" href="#distributed.client.Client.publish_dataset" title="distributed.client.Client.publish_dataset"><code class="xref py py-obj docutils literal"><span class="pre">Client.publish_dataset</span></code></a>(**kwargs)</td>
<td>Publish named datasets to scheduler</td>
</tr>
<tr class="row-odd"><td><a class="reference internal" href="#distributed.client.Client.profile" title="distributed.client.Client.profile"><code class="xref py py-obj docutils literal"><span class="pre">Client.profile</span></code></a>([key, start, stop, workers, …])</td>
<td>Collect statistical profiling information about recent work</td>
</tr>
<tr class="row-even"><td><a class="reference internal" href="#distributed.client.Client.rebalance" title="distributed.client.Client.rebalance"><code class="xref py py-obj docutils literal"><span class="pre">Client.rebalance</span></code></a>([futures, workers])</td>
<td>Rebalance data within network</td>
</tr>
<tr class="row-odd"><td><a class="reference internal" href="#distributed.client.Client.replicate" title="distributed.client.Client.replicate"><code class="xref py py-obj docutils literal"><span class="pre">Client.replicate</span></code></a>(futures[, n, workers, …])</td>
<td>Set replication of futures within network</td>
</tr>
<tr class="row-even"><td><a class="reference internal" href="#distributed.client.Client.restart" title="distributed.client.Client.restart"><code class="xref py py-obj docutils literal"><span class="pre">Client.restart</span></code></a>(**kwargs)</td>
<td>Restart the distributed network</td>
</tr>
<tr class="row-odd"><td><a class="reference internal" href="#distributed.client.Client.run" title="distributed.client.Client.run"><code class="xref py py-obj docutils literal"><span class="pre">Client.run</span></code></a>(function, *args, **kwargs)</td>
<td>Run a function on all workers outside of task scheduling system</td>
</tr>
<tr class="row-even"><td><a class="reference internal" href="#distributed.client.Client.run_on_scheduler" title="distributed.client.Client.run_on_scheduler"><code class="xref py py-obj docutils literal"><span class="pre">Client.run_on_scheduler</span></code></a>(function, *args, …)</td>
<td>Run a function on the scheduler process</td>
</tr>
<tr class="row-odd"><td><a class="reference internal" href="#distributed.client.Client.scatter" title="distributed.client.Client.scatter"><code class="xref py py-obj docutils literal"><span class="pre">Client.scatter</span></code></a>(data[, workers, broadcast, …])</td>
<td>Scatter data into distributed memory</td>
</tr>
<tr class="row-even"><td><a class="reference internal" href="#distributed.client.Client.scheduler_info" title="distributed.client.Client.scheduler_info"><code class="xref py py-obj docutils literal"><span class="pre">Client.scheduler_info</span></code></a>(**kwargs)</td>
<td>Basic information about the workers in the cluster</td>
</tr>
<tr class="row-odd"><td><a class="reference internal" href="#distributed.client.Client.set_metadata" title="distributed.client.Client.set_metadata"><code class="xref py py-obj docutils literal"><span class="pre">Client.set_metadata</span></code></a>(key, value)</td>
<td>Set arbitrary metadata in the scheduler</td>
</tr>
<tr class="row-even"><td><a class="reference internal" href="#distributed.client.Client.start_ipython_workers" title="distributed.client.Client.start_ipython_workers"><code class="xref py py-obj docutils literal"><span class="pre">Client.start_ipython_workers</span></code></a>([workers, …])</td>
<td>Start IPython kernels on workers</td>
</tr>
<tr class="row-odd"><td><a class="reference internal" href="#distributed.client.Client.start_ipython_scheduler" title="distributed.client.Client.start_ipython_scheduler"><code class="xref py py-obj docutils literal"><span class="pre">Client.start_ipython_scheduler</span></code></a>([magic_name, …])</td>
<td>Start IPython kernel on the scheduler</td>
</tr>
<tr class="row-even"><td><a class="reference internal" href="#distributed.client.Client.submit" title="distributed.client.Client.submit"><code class="xref py py-obj docutils literal"><span class="pre">Client.submit</span></code></a>(func, *args, **kwargs)</td>
<td>Submit a function application to the scheduler</td>
</tr>
<tr class="row-odd"><td><a class="reference internal" href="#distributed.client.Client.unpublish_dataset" title="distributed.client.Client.unpublish_dataset"><code class="xref py py-obj docutils literal"><span class="pre">Client.unpublish_dataset</span></code></a>(name, **kwargs)</td>
<td>Remove named datasets from scheduler</td>
</tr>
<tr class="row-even"><td><a class="reference internal" href="#distributed.client.Client.upload_file" title="distributed.client.Client.upload_file"><code class="xref py py-obj docutils literal"><span class="pre">Client.upload_file</span></code></a>(filename, **kwargs)</td>
<td>Upload local package to workers</td>
</tr>
<tr class="row-odd"><td><a class="reference internal" href="#distributed.client.Client.who_has" title="distributed.client.Client.who_has"><code class="xref py py-obj docutils literal"><span class="pre">Client.who_has</span></code></a>([futures])</td>
<td>The workers storing each future’s data</td>
</tr>
</tbody>
</table>
<table border="1" class="longtable docutils">
<colgroup>
<col width="10%" />
<col width="90%" />
</colgroup>
<tbody valign="top">
<tr class="row-odd"><td><a class="reference internal" href="#distributed.worker_client" title="distributed.worker_client"><code class="xref py py-obj docutils literal"><span class="pre">worker_client</span></code></a>([timeout, separate_thread])</td>
<td>Get client for this thread</td>
</tr>
<tr class="row-even"><td><a class="reference internal" href="#distributed.get_worker" title="distributed.get_worker"><code class="xref py py-obj docutils literal"><span class="pre">get_worker</span></code></a>()</td>
<td>Get the worker currently running this task</td>
</tr>
<tr class="row-odd"><td><a class="reference internal" href="#distributed.get_client" title="distributed.get_client"><code class="xref py py-obj docutils literal"><span class="pre">get_client</span></code></a>([address, timeout])</td>
<td>Get a client while within a task</td>
</tr>
<tr class="row-even"><td><a class="reference internal" href="#distributed.secede" title="distributed.secede"><code class="xref py py-obj docutils literal"><span class="pre">secede</span></code></a>()</td>
<td>Have this task secede from the worker’s thread pool</td>
</tr>
<tr class="row-odd"><td><a class="reference internal" href="#distributed.rejoin" title="distributed.rejoin"><code class="xref py py-obj docutils literal"><span class="pre">rejoin</span></code></a>()</td>
<td>Have this thread rejoin the ThreadPoolExecutor</td>
</tr>
<tr class="row-even"><td><code class="xref py py-obj docutils literal"><span class="pre">Reschedule</span></code></td>
<td>Reschedule this task</td>
</tr>
</tbody>
</table>
<table border="1" class="longtable docutils">
<colgroup>
<col width="10%" />
<col width="90%" />
</colgroup>
<tbody valign="top">
<tr class="row-odd"><td><a class="reference internal" href="#distributed.recreate_exceptions.ReplayExceptionClient.get_futures_error" title="distributed.recreate_exceptions.ReplayExceptionClient.get_futures_error"><code class="xref py py-obj docutils literal"><span class="pre">ReplayExceptionClient.get_futures_error</span></code></a>(future)</td>
<td>Ask the scheduler details of the sub-task of the given failed future</td>
</tr>
<tr class="row-even"><td><a class="reference internal" href="#distributed.recreate_exceptions.ReplayExceptionClient.recreate_error_locally" title="distributed.recreate_exceptions.ReplayExceptionClient.recreate_error_locally"><code class="xref py py-obj docutils literal"><span class="pre">ReplayExceptionClient.recreate_error_locally</span></code></a>(future)</td>
<td>For a failed calculation, perform the blamed task locally for debugging.</td>
</tr>
</tbody>
</table>
<p><strong>Future</strong></p>
<table border="1" class="longtable docutils">
<colgroup>
<col width="10%" />
<col width="90%" />
</colgroup>
<tbody valign="top">
<tr class="row-odd"><td><a class="reference internal" href="#distributed.client.Future" title="distributed.client.Future"><code class="xref py py-obj docutils literal"><span class="pre">Future</span></code></a>(key[, client, inform, state])</td>
<td>A remotely running computation</td>
</tr>
<tr class="row-even"><td><a class="reference internal" href="#distributed.client.Future.add_done_callback" title="distributed.client.Future.add_done_callback"><code class="xref py py-obj docutils literal"><span class="pre">Future.add_done_callback</span></code></a>(fn)</td>
<td>Call callback on future when callback has finished</td>
</tr>
<tr class="row-odd"><td><a class="reference internal" href="#distributed.client.Future.cancel" title="distributed.client.Future.cancel"><code class="xref py py-obj docutils literal"><span class="pre">Future.cancel</span></code></a>(**kwargs)</td>
<td>Cancel request to run this future</td>
</tr>
<tr class="row-even"><td><a class="reference internal" href="#distributed.client.Future.cancelled" title="distributed.client.Future.cancelled"><code class="xref py py-obj docutils literal"><span class="pre">Future.cancelled</span></code></a>()</td>
<td>Returns True if the future has been cancelled</td>
</tr>
<tr class="row-odd"><td><a class="reference internal" href="#distributed.client.Future.done" title="distributed.client.Future.done"><code class="xref py py-obj docutils literal"><span class="pre">Future.done</span></code></a>()</td>
<td>Is the computation complete?</td>
</tr>
<tr class="row-even"><td><a class="reference internal" href="#distributed.client.Future.exception" title="distributed.client.Future.exception"><code class="xref py py-obj docutils literal"><span class="pre">Future.exception</span></code></a>([timeout])</td>
<td>Return the exception of a failed task</td>
</tr>
<tr class="row-odd"><td><a class="reference internal" href="#distributed.client.Future.result" title="distributed.client.Future.result"><code class="xref py py-obj docutils literal"><span class="pre">Future.result</span></code></a>([timeout])</td>
<td>Wait until computation completes, gather result to local process.</td>
</tr>
<tr class="row-even"><td><a class="reference internal" href="#distributed.client.Future.traceback" title="distributed.client.Future.traceback"><code class="xref py py-obj docutils literal"><span class="pre">Future.traceback</span></code></a>([timeout])</td>
<td>Return the traceback of a failed task</td>
</tr>
</tbody>
</table>
<p><strong>Client Coordination</strong></p>
<table border="1" class="longtable docutils">
<colgroup>
<col width="10%" />
<col width="90%" />
</colgroup>
<tbody valign="top">
<tr class="row-odd"><td><code class="xref py py-obj docutils literal"><span class="pre">Lock</span></code>([name, client])</td>
<td>Distributed Centralized Lock</td>
</tr>
</tbody>
</table>
<table border="1" class="longtable docutils">
<colgroup>
<col width="10%" />
<col width="90%" />
</colgroup>
<tbody valign="top">
<tr class="row-odd"><td><a class="reference internal" href="#distributed.Queue" title="distributed.Queue"><code class="xref py py-obj docutils literal"><span class="pre">Queue</span></code></a>([name, client, maxsize])</td>
<td>Distributed Queue</td>
</tr>
</tbody>
</table>
<table border="1" class="longtable docutils">
<colgroup>
<col width="10%" />
<col width="90%" />
</colgroup>
<tbody valign="top">
<tr class="row-odd"><td><a class="reference internal" href="#distributed.Variable" title="distributed.Variable"><code class="xref py py-obj docutils literal"><span class="pre">Variable</span></code></a>([name, client, maxsize])</td>
<td>Distributed Global Variable</td>
</tr>
</tbody>
</table>
<p><strong>Other</strong></p>
<table border="1" class="longtable docutils">
<colgroup>
<col width="10%" />
<col width="90%" />
</colgroup>
<tbody valign="top">
<tr class="row-odd"><td><code class="xref py py-obj docutils literal"><span class="pre">as_completed</span></code>([futures, loop, with_results])</td>
<td>Return futures in the order in which they complete</td>
</tr>
<tr class="row-even"><td><a class="reference internal" href="#distributed.diagnostics.progress" title="distributed.diagnostics.progress"><code class="xref py py-obj docutils literal"><span class="pre">distributed.diagnostics.progress</span></code></a>(*futures, …)</td>
<td>Track progress of futures</td>
</tr>
<tr class="row-odd"><td><code class="xref py py-obj docutils literal"><span class="pre">wait</span></code>(fs[, timeout, return_when])</td>
<td>Wait until all futures are complete</td>
</tr>
<tr class="row-even"><td><code class="xref py py-obj docutils literal"><span class="pre">fire_and_forget</span></code>(obj)</td>
<td>Run tasks at least once, even if we release the futures</td>
</tr>
</tbody>
</table>
<div class="section" id="asynchronous-methods">
<h2>Asynchronous methods<a class="headerlink" href="#asynchronous-methods" title="Permalink to this headline">¶</a></h2>
<p>Most methods and functions can be used equally well within a blocking or
asynchronous environment using Tornado coroutines. If used within a Tornado
IOLoop then you should yield or await otherwise blocking operations
appropriately.</p>
<p>You must tell the client that you intend to use it within an asynchronous
environment by passing the <code class="docutils literal"><span class="pre">asynchronous=True</span></code> keyword</p>
<div class="highlight-python"><div class="highlight"><pre><span></span><span class="c1"># blocking</span>
<span class="n">client</span> <span class="o">=</span> <span class="n">Client</span><span class="p">()</span>
<span class="n">future</span> <span class="o">=</span> <span class="n">client</span><span class="o">.</span><span class="n">submit</span><span class="p">(</span><span class="n">func</span><span class="p">,</span> <span class="o">*</span><span class="n">args</span><span class="p">)</span> <span class="c1"># immediate, no blocking/async difference</span>
<span class="n">result</span> <span class="o">=</span> <span class="n">client</span><span class="o">.</span><span class="n">gather</span><span class="p">(</span><span class="n">future</span><span class="p">)</span> <span class="c1"># blocking</span>
<span class="c1"># asynchronous Python 2/3</span>
<span class="n">client</span> <span class="o">=</span> <span class="k">yield</span> <span class="n">Client</span><span class="p">(</span><span class="n">asynchronous</span><span class="o">=</span><span class="bp">True</span><span class="p">)</span>
<span class="n">future</span> <span class="o">=</span> <span class="n">client</span><span class="o">.</span><span class="n">submit</span><span class="p">(</span><span class="n">func</span><span class="p">,</span> <span class="o">*</span><span class="n">args</span><span class="p">)</span> <span class="c1"># immediate, no blocking/async difference</span>
<span class="n">result</span> <span class="o">=</span> <span class="k">yield</span> <span class="n">client</span><span class="o">.</span><span class="n">gather</span><span class="p">(</span><span class="n">future</span><span class="p">)</span> <span class="c1"># non-blocking/asynchronous</span>
<span class="c1"># asynchronous Python 3</span>
<span class="n">client</span> <span class="o">=</span> <span class="n">await</span> <span class="n">Client</span><span class="p">(</span><span class="n">asynchronous</span><span class="o">=</span><span class="bp">True</span><span class="p">)</span>
<span class="n">future</span> <span class="o">=</span> <span class="n">client</span><span class="o">.</span><span class="n">submit</span><span class="p">(</span><span class="n">func</span><span class="p">,</span> <span class="o">*</span><span class="n">args</span><span class="p">)</span> <span class="c1"># immediate, no blocking/async difference</span>
<span class="n">result</span> <span class="o">=</span> <span class="n">await</span> <span class="n">client</span><span class="o">.</span><span class="n">gather</span><span class="p">(</span><span class="n">future</span><span class="p">)</span> <span class="c1"># non-blocking/asynchronous</span>
</pre></div>
</div>
<p>The asynchronous variants must be run within a Tornado coroutine. See the
<a class="reference internal" href="asynchronous.html"><span class="doc">Asynchronous</span></a> documentation for more information.</p>
</div>
<div class="section" id="client">
<h2>Client<a class="headerlink" href="#client" title="Permalink to this headline">¶</a></h2>
<dl class="class">
<dt id="distributed.client.Client">
<em class="property">class </em><code class="descclassname">distributed.client.</code><code class="descname">Client</code><span class="sig-paren">(</span><em>address=None</em>, <em>loop=None</em>, <em>timeout=5</em>, <em>set_as_default=True</em>, <em>scheduler_file=None</em>, <em>security=None</em>, <em>asynchronous=False</em>, <em>name=None</em>, <em>**kwargs</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/distributed/client.html#Client"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#distributed.client.Client" title="Permalink to this definition">¶</a></dt>
<dd><p>Connect to and drive computation on a distributed Dask cluster</p>
<p>The Client connects users to a dask.distributed compute cluster. It
provides an asynchronous user interface around functions and futures. This
class resembles executors in <code class="docutils literal"><span class="pre">concurrent.futures</span></code> but also allows
<code class="docutils literal"><span class="pre">Future</span></code> objects within <code class="docutils literal"><span class="pre">submit/map</span></code> calls.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><p class="first"><strong>address: string, or Cluster</strong></p>
<blockquote>
<div><p>This can be the address of a <code class="docutils literal"><span class="pre">Scheduler</span></code> server like a string
<code class="docutils literal"><span class="pre">'127.0.0.1:8786'</span></code> or a cluster object like <code class="docutils literal"><span class="pre">LocalCluster()</span></code></p>
</div></blockquote>
<p><strong>timeout: int</strong></p>
<blockquote>
<div><p>Timeout duration for initial connection to the scheduler</p>
</div></blockquote>
<p><strong>set_as_default: bool (True)</strong></p>
<blockquote>
<div><p>Claim this scheduler as the global dask scheduler</p>
</div></blockquote>
<p><strong>scheduler_file: string (optional)</strong></p>
<blockquote>
<div><p>Path to a file with scheduler information if available</p>
</div></blockquote>
<p><strong>security: (optional)</strong></p>
<blockquote>
<div><p>Optional security information</p>
</div></blockquote>
<p><strong>asynchronous: bool (False by default)</strong></p>
<blockquote>
<div><p>Set to True if this client will be used within a Tornado event loop</p>
</div></blockquote>
<p><strong>name: string (optional)</strong></p>
<blockquote class="last">
<div><p>Gives the client a name that will be included in logs generated on
the scheduler for matters relating to this client</p>
</div></blockquote>
</td>
</tr>
</tbody>
</table>
<div class="admonition seealso">
<p class="first admonition-title">See also</p>
<dl class="last docutils">
<dt><a class="reference internal" href="scheduling-state.html#distributed.scheduler.Scheduler" title="distributed.scheduler.Scheduler"><code class="xref py py-obj docutils literal"><span class="pre">distributed.scheduler.Scheduler</span></code></a></dt>
<dd>Internal scheduler</dd>
</dl>
</div>
<p class="rubric">Examples</p>
<p>Provide cluster’s scheduler node address on initialization:</p>
<div class="highlight-default"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">client</span> <span class="o">=</span> <span class="n">Client</span><span class="p">(</span><span class="s1">'127.0.0.1:8786'</span><span class="p">)</span>
</pre></div>
</div>
<p>Use <code class="docutils literal"><span class="pre">submit</span></code> method to send individual computations to the cluster</p>
<div class="highlight-default"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">a</span> <span class="o">=</span> <span class="n">client</span><span class="o">.</span><span class="n">submit</span><span class="p">(</span><span class="n">add</span><span class="p">,</span> <span class="mi">1</span><span class="p">,</span> <span class="mi">2</span><span class="p">)</span>
<span class="gp">>>> </span><span class="n">b</span> <span class="o">=</span> <span class="n">client</span><span class="o">.</span><span class="n">submit</span><span class="p">(</span><span class="n">add</span><span class="p">,</span> <span class="mi">10</span><span class="p">,</span> <span class="mi">20</span><span class="p">)</span>
</pre></div>
</div>
<p>Continue using submit or map on results to build up larger computations</p>
<div class="highlight-default"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">c</span> <span class="o">=</span> <span class="n">client</span><span class="o">.</span><span class="n">submit</span><span class="p">(</span><span class="n">add</span><span class="p">,</span> <span class="n">a</span><span class="p">,</span> <span class="n">b</span><span class="p">)</span>
</pre></div>
</div>
<p>Gather results with the <code class="docutils literal"><span class="pre">gather</span></code> method.</p>
<div class="highlight-default"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">client</span><span class="o">.</span><span class="n">gather</span><span class="p">(</span><span class="n">c</span><span class="p">)</span>
<span class="go">33</span>
</pre></div>
</div>
<dl class="attribute">
<dt id="distributed.client.Client.asynchronous">
<code class="descname">asynchronous</code><a class="headerlink" href="#distributed.client.Client.asynchronous" title="Permalink to this definition">¶</a></dt>
<dd><p>Are we running in the event loop?</p>
<p>This is true if the user signaled that we might be when creating the
client as in the following:</p>
<div class="highlight-default"><div class="highlight"><pre><span></span><span class="n">client</span> <span class="o">=</span> <span class="n">Client</span><span class="p">(</span><span class="n">asynchronous</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span>
</pre></div>
</div>
<p>However, we override this expectation if we can definitively tell that
we are running from a thread that is not the event loop. This is
common when calling get_client() from within a worker task. Even
though the client was originally created in asynchronous mode we may
find ourselves in contexts when it is better to operate synchronously.</p>
</dd></dl>
<dl class="method">
<dt id="distributed.client.Client.call_stack">
<code class="descname">call_stack</code><span class="sig-paren">(</span><em>futures=None</em>, <em>keys=None</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/distributed/client.html#Client.call_stack"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#distributed.client.Client.call_stack" title="Permalink to this definition">¶</a></dt>
<dd><p>The actively running call stack of all relevant keys</p>
<p>You can specify data of interest either by providing futures or
collections in the <code class="docutils literal"><span class="pre">futures=</span></code> keyword or a list of explicit keys in
the <code class="docutils literal"><span class="pre">keys=</span></code> keyword. If neither are provided then all call stacks
will be returned.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><p class="first"><strong>futures: list (optional)</strong></p>
<blockquote>
<div><p>List of futures, defaults to all data</p>
</div></blockquote>
<p><strong>keys: list (optional)</strong></p>
<blockquote class="last">
<div><p>List of key names, defaults to all data</p>
</div></blockquote>
</td>
</tr>
</tbody>
</table>
<p class="rubric">Examples</p>
<div class="highlight-default"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">df</span> <span class="o">=</span> <span class="n">dd</span><span class="o">.</span><span class="n">read_parquet</span><span class="p">(</span><span class="o">...</span><span class="p">)</span><span class="o">.</span><span class="n">persist</span><span class="p">()</span>
<span class="gp">>>> </span><span class="n">client</span><span class="o">.</span><span class="n">call_stack</span><span class="p">(</span><span class="n">df</span><span class="p">)</span> <span class="c1"># call on collections</span>
</pre></div>
</div>
<div class="highlight-default"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">client</span><span class="o">.</span><span class="n">call_stack</span><span class="p">()</span> <span class="c1"># Or call with no arguments for all activity </span>
</pre></div>
</div>
</dd></dl>
<dl class="method">
<dt id="distributed.client.Client.cancel">
<code class="descname">cancel</code><span class="sig-paren">(</span><em>futures</em>, <em>asynchronous=None</em>, <em>force=False</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/distributed/client.html#Client.cancel"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#distributed.client.Client.cancel" title="Permalink to this definition">¶</a></dt>
<dd><p>Cancel running futures</p>
<p>This stops future tasks from being scheduled if they have not yet run
and deletes them if they have already run. After calling, this result
and all dependent results will no longer be accessible</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><p class="first"><strong>futures: list of Futures</strong></p>
<p><strong>force: boolean (False)</strong></p>
<blockquote class="last">
<div><p>Cancel this future even if other clients desire it</p>
</div></blockquote>
</td>
</tr>
</tbody>
</table>
</dd></dl>
<dl class="method">
<dt id="distributed.client.Client.close">
<code class="descname">close</code><span class="sig-paren">(</span><em>timeout=10</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/distributed/client.html#Client.close"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#distributed.client.Client.close" title="Permalink to this definition">¶</a></dt>
<dd><p>Close this client</p>
<p>Clients will also close automatically when your Python session ends</p>
<p>If you started a client without arguments like <code class="docutils literal"><span class="pre">Client()</span></code> then this
will also close the local cluster that was started at the same time.</p>
<div class="admonition seealso">
<p class="first admonition-title">See also</p>
<p class="last"><a class="reference internal" href="#distributed.client.Client.restart" title="distributed.client.Client.restart"><code class="xref py py-obj docutils literal"><span class="pre">Client.restart</span></code></a></p>
</div>
</dd></dl>
<dl class="method">
<dt id="distributed.client.Client.compute">
<code class="descname">compute</code><span class="sig-paren">(</span><em>collections</em>, <em>sync=False</em>, <em>optimize_graph=True</em>, <em>workers=None</em>, <em>allow_other_workers=False</em>, <em>resources=None</em>, <em>retries=0</em>, <em>**kwargs</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/distributed/client.html#Client.compute"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#distributed.client.Client.compute" title="Permalink to this definition">¶</a></dt>
<dd><p>Compute dask collections on cluster</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><p class="first"><strong>collections: iterable of dask objects or single dask object</strong></p>
<blockquote>
<div><p>Collections like dask.array or dataframe or dask.value objects</p>
</div></blockquote>
<p><strong>sync: bool (optional)</strong></p>
<blockquote>
<div><p>Returns Futures if False (default) or concrete values if True</p>
</div></blockquote>
<p><strong>optimize_graph: bool</strong></p>
<blockquote>
<div><p>Whether or not to optimize the underlying graphs</p>
</div></blockquote>
<p><strong>workers: str, list, dict</strong></p>
<blockquote>
<div><p>Which workers can run which parts of the computation
If a string a list then the output collections will run on the listed</p>
<blockquote>
<div><p>workers, but other sub-computations can run anywhere</p>
</div></blockquote>
<dl class="docutils">
<dt>If a dict then keys should be (tuples of) collections and values</dt>
<dd><p class="first last">should be addresses or lists.</p>
</dd>
</dl>
</div></blockquote>
<p><strong>allow_other_workers: bool, list</strong></p>
<blockquote>
<div><p>If True then all restrictions in workers= are considered loose
If a list then only the keys for the listed collections are loose</p>
</div></blockquote>
<p><strong>retries: int (default to 0)</strong></p>
<blockquote>
<div><p>Number of allowed automatic retries if computing a result fails</p>
</div></blockquote>
<p><strong>**kwargs:</strong></p>
<blockquote>
<div><p>Options to pass to the graph optimize calls</p>
</div></blockquote>
</td>
</tr>
<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first last">List of Futures if input is a sequence, or a single future otherwise</p>
</td>
</tr>
</tbody>
</table>
<div class="admonition seealso">
<p class="first admonition-title">See also</p>
<dl class="last docutils">
<dt><a class="reference internal" href="#distributed.client.Client.get" title="distributed.client.Client.get"><code class="xref py py-obj docutils literal"><span class="pre">Client.get</span></code></a></dt>
<dd>Normal synchronous dask.get function</dd>
</dl>
</div>
<p class="rubric">Examples</p>
<div class="highlight-default"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="kn">from</span> <span class="nn">dask</span> <span class="k">import</span> <span class="n">delayed</span>
<span class="gp">>>> </span><span class="kn">from</span> <span class="nn">operator</span> <span class="k">import</span> <span class="n">add</span>
<span class="gp">>>> </span><span class="n">x</span> <span class="o">=</span> <span class="n">delayed</span><span class="p">(</span><span class="n">add</span><span class="p">)(</span><span class="mi">1</span><span class="p">,</span> <span class="mi">2</span><span class="p">)</span>
<span class="gp">>>> </span><span class="n">y</span> <span class="o">=</span> <span class="n">delayed</span><span class="p">(</span><span class="n">add</span><span class="p">)(</span><span class="n">x</span><span class="p">,</span> <span class="n">x</span><span class="p">)</span>
<span class="gp">>>> </span><span class="n">xx</span><span class="p">,</span> <span class="n">yy</span> <span class="o">=</span> <span class="n">client</span><span class="o">.</span><span class="n">compute</span><span class="p">([</span><span class="n">x</span><span class="p">,</span> <span class="n">y</span><span class="p">])</span>
<span class="gp">>>> </span><span class="n">xx</span>
<span class="go"><Future: status: finished, key: add-8f6e709446674bad78ea8aeecfee188e></span>
<span class="gp">>>> </span><span class="n">xx</span><span class="o">.</span><span class="n">result</span><span class="p">()</span>
<span class="go">3</span>
<span class="gp">>>> </span><span class="n">yy</span><span class="o">.</span><span class="n">result</span><span class="p">()</span>
<span class="go">6</span>
</pre></div>
</div>
<p>Also support single arguments</p>
<div class="highlight-default"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">xx</span> <span class="o">=</span> <span class="n">client</span><span class="o">.</span><span class="n">compute</span><span class="p">(</span><span class="n">x</span><span class="p">)</span>
</pre></div>
</div>
</dd></dl>
<dl class="classmethod">
<dt id="distributed.client.Client.current">
<em class="property">classmethod </em><code class="descname">current</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference internal" href="_modules/distributed/client.html#Client.current"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#distributed.client.Client.current" title="Permalink to this definition">¶</a></dt>
<dd><p>Return global client if one exists, otherwise raise ValueError</p>
</dd></dl>
<dl class="method">
<dt id="distributed.client.Client.gather">
<code class="descname">gather</code><span class="sig-paren">(</span><em>futures</em>, <em>errors='raise'</em>, <em>maxsize=0</em>, <em>direct=None</em>, <em>asynchronous=None</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/distributed/client.html#Client.gather"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#distributed.client.Client.gather" title="Permalink to this definition">¶</a></dt>
<dd><p>Gather futures from distributed memory</p>
<p>Accepts a future, nested container of futures, iterator, or queue.
The return type will match the input type.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><p class="first"><strong>futures: Collection of futures</strong></p>
<blockquote>
<div><p>This can be a possibly nested collection of Future objects.
Collections can be lists, sets, iterators, queues or dictionaries</p>
</div></blockquote>
<p><strong>errors: string</strong></p>
<blockquote>
<div><p>Either ‘raise’ or ‘skip’ if we should raise if a future has erred
or skip its inclusion in the output collection</p>
</div></blockquote>
<p><strong>maxsize: int</strong></p>
<blockquote>
<div><p>If the input is a queue then this produces an output queue with a
maximum size.</p>
</div></blockquote>
</td>
</tr>
<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first">results: a collection of the same type as the input, but now with</p>
<p class="last">gathered results rather than futures</p>
</td>
</tr>
</tbody>
</table>
<div class="admonition seealso">
<p class="first admonition-title">See also</p>
<dl class="last docutils">
<dt><a class="reference internal" href="#distributed.client.Client.scatter" title="distributed.client.Client.scatter"><code class="xref py py-obj docutils literal"><span class="pre">Client.scatter</span></code></a></dt>
<dd>Send data out to cluster</dd>
</dl>
</div>
<p class="rubric">Examples</p>
<div class="highlight-default"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="kn">from</span> <span class="nn">operator</span> <span class="k">import</span> <span class="n">add</span>
<span class="gp">>>> </span><span class="n">c</span> <span class="o">=</span> <span class="n">Client</span><span class="p">(</span><span class="s1">'127.0.0.1:8787'</span><span class="p">)</span>
<span class="gp">>>> </span><span class="n">x</span> <span class="o">=</span> <span class="n">c</span><span class="o">.</span><span class="n">submit</span><span class="p">(</span><span class="n">add</span><span class="p">,</span> <span class="mi">1</span><span class="p">,</span> <span class="mi">2</span><span class="p">)</span>
<span class="gp">>>> </span><span class="n">c</span><span class="o">.</span><span class="n">gather</span><span class="p">(</span><span class="n">x</span><span class="p">)</span>
<span class="go">3</span>
<span class="gp">>>> </span><span class="n">c</span><span class="o">.</span><span class="n">gather</span><span class="p">([</span><span class="n">x</span><span class="p">,</span> <span class="p">[</span><span class="n">x</span><span class="p">],</span> <span class="n">x</span><span class="p">])</span> <span class="c1"># support lists and dicts </span>
<span class="go">[3, [3], 3]</span>
</pre></div>
</div>
<div class="highlight-default"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">seq</span> <span class="o">=</span> <span class="n">c</span><span class="o">.</span><span class="n">gather</span><span class="p">(</span><span class="nb">iter</span><span class="p">([</span><span class="n">x</span><span class="p">,</span> <span class="n">x</span><span class="p">]))</span> <span class="c1"># support iterators </span>
<span class="gp">>>> </span><span class="nb">next</span><span class="p">(</span><span class="n">seq</span><span class="p">)</span>
<span class="go">3</span>
</pre></div>
</div>
</dd></dl>
<dl class="method">
<dt id="distributed.client.Client.get">
<code class="descname">get</code><span class="sig-paren">(</span><em>dsk</em>, <em>keys</em>, <em>restrictions=None</em>, <em>loose_restrictions=None</em>, <em>resources=None</em>, <em>sync=True</em>, <em>asynchronous=None</em>, <em>**kwargs</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/distributed/client.html#Client.get"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#distributed.client.Client.get" title="Permalink to this definition">¶</a></dt>
<dd><p>Compute dask graph</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><p class="first"><strong>dsk: dict</strong></p>
<p><strong>keys: object, or nested lists of objects</strong></p>
<p><strong>restrictions: dict (optional)</strong></p>
<blockquote>
<div><p>A mapping of {key: {set of worker hostnames}} that restricts where
jobs can take place</p>
</div></blockquote>
<p><strong>sync: bool (optional)</strong></p>
<blockquote class="last">
<div><p>Returns Futures if False or concrete values if True (default).</p>
</div></blockquote>
</td>
</tr>
</tbody>
</table>
<div class="admonition seealso">
<p class="first admonition-title">See also</p>
<dl class="last docutils">
<dt><a class="reference internal" href="#distributed.client.Client.compute" title="distributed.client.Client.compute"><code class="xref py py-obj docutils literal"><span class="pre">Client.compute</span></code></a></dt>
<dd>Compute asynchronous collections</dd>
</dl>
</div>
<p class="rubric">Examples</p>
<div class="highlight-default"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="kn">from</span> <span class="nn">operator</span> <span class="k">import</span> <span class="n">add</span>
<span class="gp">>>> </span><span class="n">c</span> <span class="o">=</span> <span class="n">Client</span><span class="p">(</span><span class="s1">'127.0.0.1:8787'</span><span class="p">)</span>
<span class="gp">>>> </span><span class="n">c</span><span class="o">.</span><span class="n">get</span><span class="p">({</span><span class="s1">'x'</span><span class="p">:</span> <span class="p">(</span><span class="n">add</span><span class="p">,</span> <span class="mi">1</span><span class="p">,</span> <span class="mi">2</span><span class="p">)},</span> <span class="s1">'x'</span><span class="p">)</span>
<span class="go">3</span>
</pre></div>
</div>
</dd></dl>
<dl class="method">
<dt id="distributed.client.Client.get_dataset">
<code class="descname">get_dataset</code><span class="sig-paren">(</span><em>name</em>, <em>**kwargs</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/distributed/client.html#Client.get_dataset"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#distributed.client.Client.get_dataset" title="Permalink to this definition">¶</a></dt>
<dd><p>Get named dataset from the scheduler</p>
<div class="admonition seealso">
<p class="first admonition-title">See also</p>
<p class="last"><a class="reference internal" href="#distributed.client.Client.publish_dataset" title="distributed.client.Client.publish_dataset"><code class="xref py py-obj docutils literal"><span class="pre">Client.publish_dataset</span></code></a>, <a class="reference internal" href="#distributed.client.Client.list_datasets" title="distributed.client.Client.list_datasets"><code class="xref py py-obj docutils literal"><span class="pre">Client.list_datasets</span></code></a></p>
</div>
</dd></dl>
<dl class="method">
<dt id="distributed.client.Client.get_executor">
<code class="descname">get_executor</code><span class="sig-paren">(</span><em>**kwargs</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/distributed/client.html#Client.get_executor"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#distributed.client.Client.get_executor" title="Permalink to this definition">¶</a></dt>
<dd><p>Return a concurrent.futures Executor for submitting tasks
on this Client.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><p class="first"><strong>**kwargs:</strong></p>
<blockquote>
<div><p>Any submit()- or map()- compatible arguments, such as
<cite>workers</cite> or <cite>resources</cite>.</p>
</div></blockquote>
</td>
</tr>
<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first">An Executor object that’s fully compatible with the concurrent.futures</p>
<p class="last">API.</p>
</td>
</tr>
</tbody>
</table>
</dd></dl>
<dl class="method">
<dt id="distributed.client.Client.get_metadata">
<code class="descname">get_metadata</code><span class="sig-paren">(</span><em>keys</em>, <em>default='__no_default__'</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/distributed/client.html#Client.get_metadata"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#distributed.client.Client.get_metadata" title="Permalink to this definition">¶</a></dt>
<dd><p>Get arbitrary metadata from scheduler</p>
<p>See set_metadata for the full docstring with examples</p>
<div class="admonition seealso">
<p class="first admonition-title">See also</p>
<p class="last"><a class="reference internal" href="#distributed.client.Client.set_metadata" title="distributed.client.Client.set_metadata"><code class="xref py py-obj docutils literal"><span class="pre">Client.set_metadata</span></code></a></p>
</div>
</dd></dl>
<dl class="classmethod">
<dt id="distributed.client.Client.get_restrictions">
<em class="property">classmethod </em><code class="descname">get_restrictions</code><span class="sig-paren">(</span><em>collections</em>, <em>workers</em>, <em>allow_other_workers</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/distributed/client.html#Client.get_restrictions"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#distributed.client.Client.get_restrictions" title="Permalink to this definition">¶</a></dt>
<dd><p>Get restrictions from inputs to compute/persist</p>
</dd></dl>
<dl class="method">
<dt id="distributed.client.Client.get_scheduler_logs">
<code class="descname">get_scheduler_logs</code><span class="sig-paren">(</span><em>n=None</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/distributed/client.html#Client.get_scheduler_logs"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#distributed.client.Client.get_scheduler_logs" title="Permalink to this definition">¶</a></dt>
<dd><p>Get logs from scheduler</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><p class="first"><strong>n: int</strong></p>
<blockquote>
<div><p>Number of logs to retrive. Maxes out at 10000 by default,
confiruable in config.yaml::log-length</p>
</div></blockquote>
</td>
</tr>
<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first last">Logs in reversed order (newest first)</p>
</td>
</tr>
</tbody>
</table>
</dd></dl>
<dl class="method">
<dt id="distributed.client.Client.get_versions">
<code class="descname">get_versions</code><span class="sig-paren">(</span><em>check=False</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/distributed/client.html#Client.get_versions"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#distributed.client.Client.get_versions" title="Permalink to this definition">¶</a></dt>
<dd><p>Return version info for the scheduler, all workers and myself</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><p class="first"><strong>check</strong> : boolean, default False</p>
<blockquote class="last">
<div><p>raise ValueError if all required & optional packages
do not match</p>
</div></blockquote>
</td>
</tr>
</tbody>
</table>
<p class="rubric">Examples</p>
<div class="highlight-default"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">c</span><span class="o">.</span><span class="n">get_versions</span><span class="p">()</span>
</pre></div>
</div>
</dd></dl>
<dl class="method">
<dt id="distributed.client.Client.get_worker_logs">
<code class="descname">get_worker_logs</code><span class="sig-paren">(</span><em>n=None</em>, <em>workers=None</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/distributed/client.html#Client.get_worker_logs"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#distributed.client.Client.get_worker_logs" title="Permalink to this definition">¶</a></dt>
<dd><p>Get logs from workers</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><p class="first"><strong>n: int</strong></p>
<blockquote>
<div><p>Number of logs to retrive. Maxes out at 10000 by default,
confiruable in config.yaml::log-length</p>
</div></blockquote>
<p><strong>workers: iterable</strong></p>
<blockquote>
<div><p>List of worker addresses to retrive. Gets all workers by default.</p>
</div></blockquote>
</td>
</tr>
<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first">Dictionary mapping worker address to logs.</p>
<p class="last">Logs are returned in reversed order (newest first)</p>
</td>
</tr>
</tbody>
</table>
</dd></dl>
<dl class="method">
<dt id="distributed.client.Client.has_what">
<code class="descname">has_what</code><span class="sig-paren">(</span><em>workers=None</em>, <em>**kwargs</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/distributed/client.html#Client.has_what"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#distributed.client.Client.has_what" title="Permalink to this definition">¶</a></dt>
<dd><p>Which keys are held by which workers</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><p class="first"><strong>workers: list (optional)</strong></p>
<blockquote class="last">
<div><p>A list of worker addresses, defaults to all</p>
</div></blockquote>
</td>
</tr>
</tbody>
</table>
<div class="admonition seealso">
<p class="first admonition-title">See also</p>
<p class="last"><a class="reference internal" href="#distributed.client.Client.who_has" title="distributed.client.Client.who_has"><code class="xref py py-obj docutils literal"><span class="pre">Client.who_has</span></code></a>, <a class="reference internal" href="#distributed.client.Client.ncores" title="distributed.client.Client.ncores"><code class="xref py py-obj docutils literal"><span class="pre">Client.ncores</span></code></a></p>
</div>
<p class="rubric">Examples</p>
<div class="highlight-default"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">x</span><span class="p">,</span> <span class="n">y</span><span class="p">,</span> <span class="n">z</span> <span class="o">=</span> <span class="n">c</span><span class="o">.</span><span class="n">map</span><span class="p">(</span><span class="n">inc</span><span class="p">,</span> <span class="p">[</span><span class="mi">1</span><span class="p">,</span> <span class="mi">2</span><span class="p">,</span> <span class="mi">3</span><span class="p">])</span>
<span class="gp">>>> </span><span class="n">wait</span><span class="p">([</span><span class="n">x</span><span class="p">,</span> <span class="n">y</span><span class="p">,</span> <span class="n">z</span><span class="p">])</span>
<span class="gp">>>> </span><span class="n">c</span><span class="o">.</span><span class="n">has_what</span><span class="p">()</span>
<span class="go">{'192.168.1.141:46784': ['inc-1c8dd6be1c21646c71f76c16d09304ea',</span>
<span class="go"> 'inc-fd65c238a7ea60f6a01bf4c8a5fcf44b',</span>
<span class="go"> 'inc-1e297fc27658d7b67b3a758f16bcf47a']}</span>
</pre></div>
</div>
</dd></dl>
<dl class="method">
<dt id="distributed.client.Client.list_datasets">
<code class="descname">list_datasets</code><span class="sig-paren">(</span><em>**kwargs</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/distributed/client.html#Client.list_datasets"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#distributed.client.Client.list_datasets" title="Permalink to this definition">¶</a></dt>
<dd><p>List named datasets available on the scheduler</p>
<div class="admonition seealso">
<p class="first admonition-title">See also</p>
<p class="last"><a class="reference internal" href="#distributed.client.Client.publish_dataset" title="distributed.client.Client.publish_dataset"><code class="xref py py-obj docutils literal"><span class="pre">Client.publish_dataset</span></code></a>, <a class="reference internal" href="#distributed.client.Client.get_dataset" title="distributed.client.Client.get_dataset"><code class="xref py py-obj docutils literal"><span class="pre">Client.get_dataset</span></code></a></p>
</div>
</dd></dl>
<dl class="method">
<dt id="distributed.client.Client.map">
<code class="descname">map</code><span class="sig-paren">(</span><em>func</em>, <em>*iterables</em>, <em>**kwargs</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/distributed/client.html#Client.map"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#distributed.client.Client.map" title="Permalink to this definition">¶</a></dt>
<dd><p>Map a function on a sequence of arguments</p>
<p>Arguments can be normal objects or Futures</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><p class="first"><strong>func: callable</strong></p>
<p><strong>iterables: Iterables, Iterators, or Queues</strong></p>
<p><strong>key: str, list</strong></p>
<blockquote>
<div><p>Prefix for task names if string. Explicit names if list.</p>
</div></blockquote>
<p><strong>pure: bool (defaults to True)</strong></p>
<blockquote>
<div><p>Whether or not the function is pure. Set <code class="docutils literal"><span class="pre">pure=False</span></code> for
impure functions like <code class="docutils literal"><span class="pre">np.random.random</span></code>.</p>
</div></blockquote>
<p><strong>workers: set, iterable of sets</strong></p>
<blockquote>
<div><p>A set of worker hostnames on which computations may be performed.
Leave empty to default to all workers (common case)</p>
</div></blockquote>
<p><strong>retries: int (default to 0)</strong></p>
<blockquote>
<div><p>Number of allowed automatic retries if a task fails</p>
</div></blockquote>
</td>
</tr>
<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first">List, iterator, or Queue of futures, depending on the type of the</p>
<p class="last">inputs.</p>
</td>
</tr>
</tbody>
</table>
<div class="admonition seealso">
<p class="first admonition-title">See also</p>
<dl class="last docutils">
<dt><a class="reference internal" href="#distributed.client.Client.submit" title="distributed.client.Client.submit"><code class="xref py py-obj docutils literal"><span class="pre">Client.submit</span></code></a></dt>
<dd>Submit a single function</dd>
</dl>
</div>
<p class="rubric">Examples</p>
<div class="highlight-default"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">L</span> <span class="o">=</span> <span class="n">client</span><span class="o">.</span><span class="n">map</span><span class="p">(</span><span class="n">func</span><span class="p">,</span> <span class="n">sequence</span><span class="p">)</span>
</pre></div>
</div>
</dd></dl>
<dl class="method">
<dt id="distributed.client.Client.nbytes">
<code class="descname">nbytes</code><span class="sig-paren">(</span><em>keys=None</em>, <em>summary=True</em>, <em>**kwargs</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/distributed/client.html#Client.nbytes"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#distributed.client.Client.nbytes" title="Permalink to this definition">¶</a></dt>
<dd><p>The bytes taken up by each key on the cluster</p>
<p>This is as measured by <code class="docutils literal"><span class="pre">sys.getsizeof</span></code> which may not accurately
reflect the true cost.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><p class="first"><strong>keys: list (optional)</strong></p>
<blockquote>
<div><p>A list of keys, defaults to all keys</p>
</div></blockquote>
<p><strong>summary: boolean, (optional)</strong></p>
<blockquote class="last">
<div><p>Summarize keys into key types</p>
</div></blockquote>
</td>
</tr>
</tbody>
</table>
<div class="admonition seealso">
<p class="first admonition-title">See also</p>
<p class="last"><a class="reference internal" href="#distributed.client.Client.who_has" title="distributed.client.Client.who_has"><code class="xref py py-obj docutils literal"><span class="pre">Client.who_has</span></code></a></p>
</div>
<p class="rubric">Examples</p>
<div class="highlight-default"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">x</span><span class="p">,</span> <span class="n">y</span><span class="p">,</span> <span class="n">z</span> <span class="o">=</span> <span class="n">c</span><span class="o">.</span><span class="n">map</span><span class="p">(</span><span class="n">inc</span><span class="p">,</span> <span class="p">[</span><span class="mi">1</span><span class="p">,</span> <span class="mi">2</span><span class="p">,</span> <span class="mi">3</span><span class="p">])</span>
<span class="gp">>>> </span><span class="n">c</span><span class="o">.</span><span class="n">nbytes</span><span class="p">(</span><span class="n">summary</span><span class="o">=</span><span class="kc">False</span><span class="p">)</span>
<span class="go">{'inc-1c8dd6be1c21646c71f76c16d09304ea': 28,</span>
<span class="go"> 'inc-1e297fc27658d7b67b3a758f16bcf47a': 28,</span>
<span class="go"> 'inc-fd65c238a7ea60f6a01bf4c8a5fcf44b': 28}</span>
</pre></div>
</div>
<div class="highlight-default"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">c</span><span class="o">.</span><span class="n">nbytes</span><span class="p">(</span><span class="n">summary</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span>
<span class="go">{'inc': 84}</span>
</pre></div>
</div>
</dd></dl>
<dl class="method">
<dt id="distributed.client.Client.ncores">
<code class="descname">ncores</code><span class="sig-paren">(</span><em>workers=None</em>, <em>**kwargs</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/distributed/client.html#Client.ncores"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#distributed.client.Client.ncores" title="Permalink to this definition">¶</a></dt>
<dd><p>The number of threads/cores available on each worker node</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><p class="first"><strong>workers: list (optional)</strong></p>
<blockquote class="last">
<div><p>A list of workers that we care about specifically.
Leave empty to receive information about all workers.</p>
</div></blockquote>
</td>
</tr>
</tbody>
</table>
<div class="admonition seealso">
<p class="first admonition-title">See also</p>
<p class="last"><a class="reference internal" href="#distributed.client.Client.who_has" title="distributed.client.Client.who_has"><code class="xref py py-obj docutils literal"><span class="pre">Client.who_has</span></code></a>, <a class="reference internal" href="#distributed.client.Client.has_what" title="distributed.client.Client.has_what"><code class="xref py py-obj docutils literal"><span class="pre">Client.has_what</span></code></a></p>
</div>
<p class="rubric">Examples</p>
<div class="highlight-default"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">c</span><span class="o">.</span><span class="n">ncores</span><span class="p">()</span>
<span class="go">{'192.168.1.141:46784': 8,</span>
<span class="go"> '192.167.1.142:47548': 8,</span>
<span class="go"> '192.167.1.143:47329': 8,</span>
<span class="go"> '192.167.1.144:37297': 8}</span>
</pre></div>
</div>
</dd></dl>
<dl class="method">
<dt id="distributed.client.Client.normalize_collection">
<code class="descname">normalize_collection</code><span class="sig-paren">(</span><em>collection</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/distributed/client.html#Client.normalize_collection"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#distributed.client.Client.normalize_collection" title="Permalink to this definition">¶</a></dt>
<dd><p>Replace collection’s tasks by already existing futures if they exist</p>
<p>This normalizes the tasks within a collections task graph against the
known futures within the scheduler. It returns a copy of the
collection with a task graph that includes the overlapping futures.</p>
<div class="admonition seealso">
<p class="first admonition-title">See also</p>
<dl class="last docutils">
<dt><a class="reference internal" href="#distributed.client.Client.persist" title="distributed.client.Client.persist"><code class="xref py py-obj docutils literal"><span class="pre">Client.persist</span></code></a></dt>
<dd>trigger computation of collection’s tasks</dd>
</dl>
</div>
<p class="rubric">Examples</p>
<div class="highlight-default"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="nb">len</span><span class="p">(</span><span class="n">x</span><span class="o">.</span><span class="n">__dask_graph__</span><span class="p">())</span> <span class="c1"># x is a dask collection with 100 tasks </span>
<span class="go">100</span>
<span class="gp">>>> </span><span class="nb">set</span><span class="p">(</span><span class="n">client</span><span class="o">.</span><span class="n">futures</span><span class="p">)</span><span class="o">.</span><span class="n">intersection</span><span class="p">(</span><span class="n">x</span><span class="o">.</span><span class="n">__dask_graph__</span><span class="p">())</span> <span class="c1"># some overlap exists </span>
<span class="go">10</span>
</pre></div>
</div>
<div class="highlight-default"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">x</span> <span class="o">=</span> <span class="n">client</span><span class="o">.</span><span class="n">normalize_collection</span><span class="p">(</span><span class="n">x</span><span class="p">)</span>
<span class="gp">>>> </span><span class="nb">len</span><span class="p">(</span><span class="n">x</span><span class="o">.</span><span class="n">__dask_graph__</span><span class="p">())</span> <span class="c1"># smaller computational graph </span>
<span class="go">20</span>
</pre></div>
</div>
</dd></dl>
<dl class="method">
<dt id="distributed.client.Client.persist">
<code class="descname">persist</code><span class="sig-paren">(</span><em>collections</em>, <em>optimize_graph=True</em>, <em>workers=None</em>, <em>allow_other_workers=None</em>, <em>resources=None</em>, <em>retries=None</em>, <em>**kwargs</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/distributed/client.html#Client.persist"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#distributed.client.Client.persist" title="Permalink to this definition">¶</a></dt>
<dd><p>Persist dask collections on cluster</p>
<p>Starts computation of the collection on the cluster in the background.
Provides a new dask collection that is semantically identical to the
previous one, but now based off of futures currently in execution.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><p class="first"><strong>collections: sequence or single dask object</strong></p>
<blockquote>
<div><p>Collections like dask.array or dataframe or dask.value objects</p>
</div></blockquote>
<p><strong>optimize_graph: bool</strong></p>
<blockquote>
<div><p>Whether or not to optimize the underlying graphs</p>
</div></blockquote>
<p><strong>workers: str, list, dict</strong></p>
<blockquote>
<div><p>Which workers can run which parts of the computation
If a string a list then the output collections will run on the listed</p>
<blockquote>
<div><p>workers, but other sub-computations can run anywhere</p>
</div></blockquote>
<dl class="docutils">
<dt>If a dict then keys should be (tuples of) collections and values</dt>
<dd><p class="first last">should be addresses or lists.</p>
</dd>
</dl>
</div></blockquote>
<p><strong>allow_other_workers: bool, list</strong></p>
<blockquote>
<div><p>If True then all restrictions in workers= are considered loose
If a list then only the keys for the listed collections are loose</p>
</div></blockquote>
<p><strong>retries: int (default to 0)</strong></p>
<blockquote>
<div><p>Number of allowed automatic retries if computing a result fails</p>
</div></blockquote>
<p><strong>kwargs:</strong></p>
<blockquote>
<div><p>Options to pass to the graph optimize calls</p>
</div></blockquote>
</td>
</tr>
<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first last">List of collections, or single collection, depending on type of input.</p>
</td>
</tr>
</tbody>
</table>
<div class="admonition seealso">
<p class="first admonition-title">See also</p>
<p class="last"><a class="reference internal" href="#distributed.client.Client.compute" title="distributed.client.Client.compute"><code class="xref py py-obj docutils literal"><span class="pre">Client.compute</span></code></a></p>
</div>
<p class="rubric">Examples</p>
<div class="highlight-default"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">xx</span> <span class="o">=</span> <span class="n">client</span><span class="o">.</span><span class="n">persist</span><span class="p">(</span><span class="n">x</span><span class="p">)</span>
<span class="gp">>>> </span><span class="n">xx</span><span class="p">,</span> <span class="n">yy</span> <span class="o">=</span> <span class="n">client</span><span class="o">.</span><span class="n">persist</span><span class="p">([</span><span class="n">x</span><span class="p">,</span> <span class="n">y</span><span class="p">])</span>
</pre></div>
</div>
</dd></dl>
<dl class="method">
<dt id="distributed.client.Client.processing">
<code class="descname">processing</code><span class="sig-paren">(</span><em>workers=None</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/distributed/client.html#Client.processing"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#distributed.client.Client.processing" title="Permalink to this definition">¶</a></dt>
<dd><p>The tasks currently running on each worker</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><p class="first"><strong>workers: list (optional)</strong></p>
<blockquote class="last">
<div><p>A list of worker addresses, defaults to all</p>
</div></blockquote>
</td>
</tr>
</tbody>
</table>
<div class="admonition seealso">
<p class="first admonition-title">See also</p>
<p class="last"><a class="reference internal" href="#distributed.client.Client.stacks" title="distributed.client.Client.stacks"><code class="xref py py-obj docutils literal"><span class="pre">Client.stacks</span></code></a>, <a class="reference internal" href="#distributed.client.Client.who_has" title="distributed.client.Client.who_has"><code class="xref py py-obj docutils literal"><span class="pre">Client.who_has</span></code></a>, <a class="reference internal" href="#distributed.client.Client.has_what" title="distributed.client.Client.has_what"><code class="xref py py-obj docutils literal"><span class="pre">Client.has_what</span></code></a>, <a class="reference internal" href="#distributed.client.Client.ncores" title="distributed.client.Client.ncores"><code class="xref py py-obj docutils literal"><span class="pre">Client.ncores</span></code></a></p>
</div>
<p class="rubric">Examples</p>
<div class="highlight-default"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">x</span><span class="p">,</span> <span class="n">y</span><span class="p">,</span> <span class="n">z</span> <span class="o">=</span> <span class="n">c</span><span class="o">.</span><span class="n">map</span><span class="p">(</span><span class="n">inc</span><span class="p">,</span> <span class="p">[</span><span class="mi">1</span><span class="p">,</span> <span class="mi">2</span><span class="p">,</span> <span class="mi">3</span><span class="p">])</span>
<span class="gp">>>> </span><span class="n">c</span><span class="o">.</span><span class="n">processing</span><span class="p">()</span>
<span class="go">{'192.168.1.141:46784': ['inc-1c8dd6be1c21646c71f76c16d09304ea',</span>
<span class="go"> 'inc-fd65c238a7ea60f6a01bf4c8a5fcf44b',</span>
<span class="go"> 'inc-1e297fc27658d7b67b3a758f16bcf47a']}</span>
</pre></div>
</div>
</dd></dl>
<dl class="method">
<dt id="distributed.client.Client.profile">
<code class="descname">profile</code><span class="sig-paren">(</span><em>key=None</em>, <em>start=None</em>, <em>stop=None</em>, <em>workers=None</em>, <em>merge_workers=True</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/distributed/client.html#Client.profile"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#distributed.client.Client.profile" title="Permalink to this definition">¶</a></dt>
<dd><p>Collect statistical profiling information about recent work</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><p class="first"><strong>key: str</strong></p>
<blockquote>
<div><p>Key prefix to select, this is typically a function name like ‘inc’
Leave as None to collect all data</p>
</div></blockquote>
<p><strong>start: time</strong></p>
<p><strong>stop: time</strong></p>
<p><strong>workers: list</strong></p>
<blockquote class="last">
<div><p>List of workers to restrict profile information</p>
</div></blockquote>
</td>
</tr>
</tbody>
</table>
<p class="rubric">Examples</p>
<div class="highlight-default"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">client</span><span class="o">.</span><span class="n">profile</span><span class="p">()</span> <span class="c1"># call on collections</span>
</pre></div>
</div>
</dd></dl>
<dl class="method">
<dt id="distributed.client.Client.publish_dataset">
<code class="descname">publish_dataset</code><span class="sig-paren">(</span><em>**kwargs</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/distributed/client.html#Client.publish_dataset"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#distributed.client.Client.publish_dataset" title="Permalink to this definition">¶</a></dt>
<dd><p>Publish named datasets to scheduler</p>
<p>This stores a named reference to a dask collection or list of futures
on the scheduler. These references are available to other Clients
which can download the collection or futures with <code class="docutils literal"><span class="pre">get_dataset</span></code>.</p>
<p>Datasets are not immediately computed. You may wish to call
<code class="docutils literal"><span class="pre">Client.persist</span></code> prior to publishing a dataset.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><p class="first"><strong>kwargs: dict</strong></p>
<blockquote>
<div><p>named collections to publish on the scheduler</p>
</div></blockquote>
</td>
</tr>
<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first last">None</p>
</td>
</tr>
</tbody>
</table>
<div class="admonition seealso">
<p class="first admonition-title">See also</p>
<p class="last"><a class="reference internal" href="#distributed.client.Client.list_datasets" title="distributed.client.Client.list_datasets"><code class="xref py py-obj docutils literal"><span class="pre">Client.list_datasets</span></code></a>, <a class="reference internal" href="#distributed.client.Client.get_dataset" title="distributed.client.Client.get_dataset"><code class="xref py py-obj docutils literal"><span class="pre">Client.get_dataset</span></code></a>, <a class="reference internal" href="#distributed.client.Client.unpublish_dataset" title="distributed.client.Client.unpublish_dataset"><code class="xref py py-obj docutils literal"><span class="pre">Client.unpublish_dataset</span></code></a>, <a class="reference internal" href="#distributed.client.Client.persist" title="distributed.client.Client.persist"><code class="xref py py-obj docutils literal"><span class="pre">Client.persist</span></code></a></p>
</div>
<p class="rubric">Examples</p>
<p>Publishing client:</p>
<div class="highlight-default"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">df</span> <span class="o">=</span> <span class="n">dd</span><span class="o">.</span><span class="n">read_csv</span><span class="p">(</span><span class="s1">'s3://...'</span><span class="p">)</span>
<span class="gp">>>> </span><span class="n">df</span> <span class="o">=</span> <span class="n">c</span><span class="o">.</span><span class="n">persist</span><span class="p">(</span><span class="n">df</span><span class="p">)</span>
<span class="gp">>>> </span><span class="n">c</span><span class="o">.</span><span class="n">publish_dataset</span><span class="p">(</span><span class="n">my_dataset</span><span class="o">=</span><span class="n">df</span><span class="p">)</span>
</pre></div>
</div>
<p>Receiving client:</p>
<div class="highlight-default"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">c</span><span class="o">.</span><span class="n">list_datasets</span><span class="p">()</span>
<span class="go">['my_dataset']</span>
<span class="gp">>>> </span><span class="n">df2</span> <span class="o">=</span> <span class="n">c</span><span class="o">.</span><span class="n">get_dataset</span><span class="p">(</span><span class="s1">'my_dataset'</span><span class="p">)</span>
</pre></div>
</div>
</dd></dl>
<dl class="method">
<dt id="distributed.client.Client.rebalance">
<code class="descname">rebalance</code><span class="sig-paren">(</span><em>futures=None</em>, <em>workers=None</em>, <em>**kwargs</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/distributed/client.html#Client.rebalance"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#distributed.client.Client.rebalance" title="Permalink to this definition">¶</a></dt>
<dd><p>Rebalance data within network</p>
<p>Move data between workers to roughly balance memory burden. This
either affects a subset of the keys/workers or the entire network,
depending on keyword arguments.</p>
<p>This operation is generally not well tested against normal operation of
the scheduler. It it not recommended to use it while waiting on
computations.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><p class="first"><strong>futures: list, optional</strong></p>
<blockquote>
<div><p>A list of futures to balance, defaults all data</p>
</div></blockquote>
<p><strong>workers: list, optional</strong></p>
<blockquote class="last">
<div><p>A list of workers on which to balance, defaults to all workers</p>
</div></blockquote>
</td>
</tr>
</tbody>
</table>
</dd></dl>
<dl class="method">
<dt id="distributed.client.Client.replicate">
<code class="descname">replicate</code><span class="sig-paren">(</span><em>futures</em>, <em>n=None</em>, <em>workers=None</em>, <em>branching_factor=2</em>, <em>**kwargs</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/distributed/client.html#Client.replicate"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#distributed.client.Client.replicate" title="Permalink to this definition">¶</a></dt>
<dd><p>Set replication of futures within network</p>
<p>Copy data onto many workers. This helps to broadcast frequently
accessed data and it helps to improve resilience.</p>
<p>This performs a tree copy of the data throughout the network
individually on each piece of data. This operation blocks until
complete. It does not guarantee replication of data to future workers.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><p class="first"><strong>futures: list of futures</strong></p>
<blockquote>
<div><p>Futures we wish to replicate</p>
</div></blockquote>
<p><strong>n: int, optional</strong></p>
<blockquote>
<div><p>Number of processes on the cluster on which to replicate the data.
Defaults to all.</p>
</div></blockquote>
<p><strong>workers: list of worker addresses</strong></p>
<blockquote>
<div><p>Workers on which we want to restrict the replication.
Defaults to all.</p>
</div></blockquote>
<p><strong>branching_factor: int, optional</strong></p>
<blockquote class="last">
<div><p>The number of workers that can copy data in each generation</p>
</div></blockquote>
</td>
</tr>
</tbody>
</table>
<div class="admonition seealso">
<p class="first admonition-title">See also</p>
<p class="last"><a class="reference internal" href="#distributed.client.Client.rebalance" title="distributed.client.Client.rebalance"><code class="xref py py-obj docutils literal"><span class="pre">Client.rebalance</span></code></a></p>
</div>
<p class="rubric">Examples</p>
<div class="highlight-default"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">x</span> <span class="o">=</span> <span class="n">c</span><span class="o">.</span><span class="n">submit</span><span class="p">(</span><span class="n">func</span><span class="p">,</span> <span class="o">*</span><span class="n">args</span><span class="p">)</span>
<span class="gp">>>> </span><span class="n">c</span><span class="o">.</span><span class="n">replicate</span><span class="p">([</span><span class="n">x</span><span class="p">])</span> <span class="c1"># send to all workers </span>
<span class="gp">>>> </span><span class="n">c</span><span class="o">.</span><span class="n">replicate</span><span class="p">([</span><span class="n">x</span><span class="p">],</span> <span class="n">n</span><span class="o">=</span><span class="mi">3</span><span class="p">)</span> <span class="c1"># send to three workers </span>
<span class="gp">>>> </span><span class="n">c</span><span class="o">.</span><span class="n">replicate</span><span class="p">([</span><span class="n">x</span><span class="p">],</span> <span class="n">workers</span><span class="o">=</span><span class="p">[</span><span class="s1">'alice'</span><span class="p">,</span> <span class="s1">'bob'</span><span class="p">])</span> <span class="c1"># send to specific </span>
<span class="gp">>>> </span><span class="n">c</span><span class="o">.</span><span class="n">replicate</span><span class="p">([</span><span class="n">x</span><span class="p">],</span> <span class="n">n</span><span class="o">=</span><span class="mi">1</span><span class="p">,</span> <span class="n">workers</span><span class="o">=</span><span class="p">[</span><span class="s1">'alice'</span><span class="p">,</span> <span class="s1">'bob'</span><span class="p">])</span> <span class="c1"># send to one of specific workers </span>
<span class="gp">>>> </span><span class="n">c</span><span class="o">.</span><span class="n">replicate</span><span class="p">([</span><span class="n">x</span><span class="p">],</span> <span class="n">n</span><span class="o">=</span><span class="mi">1</span><span class="p">)</span> <span class="c1"># reduce replications </span>
</pre></div>
</div>
</dd></dl>
<dl class="method">
<dt id="distributed.client.Client.restart">
<code class="descname">restart</code><span class="sig-paren">(</span><em>**kwargs</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/distributed/client.html#Client.restart"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#distributed.client.Client.restart" title="Permalink to this definition">¶</a></dt>
<dd><p>Restart the distributed network</p>
<p>This kills all active work, deletes all data on the network, and
restarts the worker processes.</p>
</dd></dl>
<dl class="method">
<dt id="distributed.client.Client.run">
<code class="descname">run</code><span class="sig-paren">(</span><em>function</em>, <em>*args</em>, <em>**kwargs</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/distributed/client.html#Client.run"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#distributed.client.Client.run" title="Permalink to this definition">¶</a></dt>
<dd><p>Run a function on all workers outside of task scheduling system</p>
<p>This calls a function on all currently known workers immediately,
blocks until those results come back, and returns the results
asynchronously as a dictionary keyed by worker address. This method
if generally used for side effects, such and collecting diagnostic
information or installing libraries.</p>
<p>If your function takes an input argument named <code class="docutils literal"><span class="pre">dask_worker</span></code> then
that variable will be populated with the worker itself.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><p class="first"><strong>function: callable</strong></p>
<p><strong>*args: arguments for remote function</strong></p>
<p><strong>**kwargs: keyword arguments for remote function</strong></p>
<p><strong>workers: list</strong></p>
<blockquote class="last">
<div><p>Workers on which to run the function. Defaults to all known workers.</p>
</div></blockquote>
</td>
</tr>
</tbody>
</table>
<p class="rubric">Examples</p>
<div class="highlight-default"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">c</span><span class="o">.</span><span class="n">run</span><span class="p">(</span><span class="n">os</span><span class="o">.</span><span class="n">getpid</span><span class="p">)</span>
<span class="go">{'192.168.0.100:9000': 1234,</span>
<span class="go"> '192.168.0.101:9000': 4321,</span>
<span class="go"> '192.168.0.102:9000': 5555}</span>
</pre></div>
</div>
<p>Restrict computation to particular workers with the <code class="docutils literal"><span class="pre">workers=</span></code>
keyword argument.</p>
<div class="highlight-default"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">c</span><span class="o">.</span><span class="n">run</span><span class="p">(</span><span class="n">os</span><span class="o">.</span><span class="n">getpid</span><span class="p">,</span> <span class="n">workers</span><span class="o">=</span><span class="p">[</span><span class="s1">'192.168.0.100:9000'</span><span class="p">,</span>
<span class="gp">... </span> <span class="s1">'192.168.0.101:9000'</span><span class="p">])</span>
<span class="go">{'192.168.0.100:9000': 1234,</span>
<span class="go"> '192.168.0.101:9000': 4321}</span>
</pre></div>
</div>
<div class="highlight-default"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="k">def</span> <span class="nf">get_status</span><span class="p">(</span><span class="n">dask_worker</span><span class="p">):</span>
<span class="gp">... </span> <span class="k">return</span> <span class="n">dask_worker</span><span class="o">.</span><span class="n">status</span>
</pre></div>
</div>
<div class="highlight-default"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">c</span><span class="o">.</span><span class="n">run</span><span class="p">(</span><span class="n">get_hostname</span><span class="p">)</span>
<span class="go">{'192.168.0.100:9000': 'running',</span>
<span class="go"> '192.168.0.101:9000': 'running}</span>
</pre></div>
</div>
</dd></dl>
<dl class="method">
<dt id="distributed.client.Client.run_coroutine">
<code class="descname">run_coroutine</code><span class="sig-paren">(</span><em>function</em>, <em>*args</em>, <em>**kwargs</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/distributed/client.html#Client.run_coroutine"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#distributed.client.Client.run_coroutine" title="Permalink to this definition">¶</a></dt>
<dd><p>Spawn a coroutine on all workers.</p>
<p>This spaws a coroutine on all currently known workers and then waits
for the coroutine on each worker. The coroutines’ results are returned
as a dictionary keyed by worker address.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><p class="first"><strong>function: a coroutine function</strong></p>
<blockquote>
<div><dl class="docutils">
<dt>(typically a function wrapped in gen.coroutine or</dt>
<dd><p class="first last">a Python 3.5+ async function)</p>
</dd>
</dl>
</div></blockquote>
<p><strong>*args: arguments for remote function</strong></p>
<p><strong>**kwargs: keyword arguments for remote function</strong></p>
<p><strong>wait: boolean (default True)</strong></p>
<blockquote>
<div><p>Whether to wait for coroutines to end.</p>
</div></blockquote>
<p><strong>workers: list</strong></p>
<blockquote class="last">
<div><p>Workers on which to run the function. Defaults to all known workers.</p>
</div></blockquote>
</td>
</tr>
</tbody>
</table>
</dd></dl>
<dl class="method">
<dt id="distributed.client.Client.run_on_scheduler">
<code class="descname">run_on_scheduler</code><span class="sig-paren">(</span><em>function</em>, <em>*args</em>, <em>**kwargs</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/distributed/client.html#Client.run_on_scheduler"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#distributed.client.Client.run_on_scheduler" title="Permalink to this definition">¶</a></dt>
<dd><p>Run a function on the scheduler process</p>
<p>This is typically used for live debugging. The function should take a
keyword argument <code class="docutils literal"><span class="pre">dask_scheduler=</span></code>, which will be given the scheduler
object itself.</p>
<div class="admonition seealso">
<p class="first admonition-title">See also</p>
<dl class="last docutils">
<dt><a class="reference internal" href="#distributed.client.Client.run" title="distributed.client.Client.run"><code class="xref py py-obj docutils literal"><span class="pre">Client.run</span></code></a></dt>
<dd>Run a function on all workers</dd>
<dt><a class="reference internal" href="#distributed.client.Client.start_ipython_scheduler" title="distributed.client.Client.start_ipython_scheduler"><code class="xref py py-obj docutils literal"><span class="pre">Client.start_ipython_scheduler</span></code></a></dt>
<dd>Start an IPython session on scheduler</dd>
</dl>
</div>
<p class="rubric">Examples</p>
<div class="highlight-default"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="k">def</span> <span class="nf">get_number_of_tasks</span><span class="p">(</span><span class="n">dask_scheduler</span><span class="o">=</span><span class="kc">None</span><span class="p">):</span>
<span class="gp">... </span> <span class="k">return</span> <span class="nb">len</span><span class="p">(</span><span class="n">dask_scheduler</span><span class="o">.</span><span class="n">task_state</span><span class="p">)</span>
</pre></div>
</div>
<div class="highlight-default"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">client</span><span class="o">.</span><span class="n">run_on_scheduler</span><span class="p">(</span><span class="n">get_number_of_tasks</span><span class="p">)</span>
<span class="go">100</span>
</pre></div>
</div>
</dd></dl>
<dl class="method">
<dt id="distributed.client.Client.scatter">
<code class="descname">scatter</code><span class="sig-paren">(</span><em>data</em>, <em>workers=None</em>, <em>broadcast=False</em>, <em>direct=None</em>, <em>hash=True</em>, <em>maxsize=0</em>, <em>timeout=3</em>, <em>asynchronous=None</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/distributed/client.html#Client.scatter"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#distributed.client.Client.scatter" title="Permalink to this definition">¶</a></dt>
<dd><p>Scatter data into distributed memory</p>
<p>This moves data from the local client process into the workers of the
distributed scheduler. Note that it is often better to submit jobs to
your workers to have them load the data rather than loading data
locally and then scattering it out to them.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><p class="first"><strong>data: list, iterator, dict, Queue, or object</strong></p>
<blockquote>
<div><p>Data to scatter out to workers. Output type matches input type.</p>
</div></blockquote>
<p><strong>workers: list of tuples (optional)</strong></p>
<blockquote>
<div><p>Optionally constrain locations of data.
Specify workers as hostname/port pairs, e.g. <code class="docutils literal"><span class="pre">('127.0.0.1',</span> <span class="pre">8787)</span></code>.</p>
</div></blockquote>
<p><strong>broadcast: bool (defaults to False)</strong></p>
<blockquote>
<div><p>Whether to send each data element to all workers.
By default we round-robin based on number of cores.</p>
</div></blockquote>
<p><strong>direct: bool (defaults to automatically check)</strong></p>
<blockquote>
<div><p>Send data directly to workers, bypassing the central scheduler
This avoids burdening the scheduler but assumes that the client is
able to talk directly with the workers.</p>
</div></blockquote>
<p><strong>maxsize: int (optional)</strong></p>
<blockquote>
<div><p>Maximum size of queue if using queues, 0 implies infinite</p>
</div></blockquote>
<p><strong>hash: bool (optional)</strong></p>
<blockquote>
<div><p>Whether or not to hash data to determine key.
If False then this uses a random key</p>
</div></blockquote>
</td>
</tr>
<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first last">List, dict, iterator, or queue of futures matching the type of input.</p>
</td>
</tr>
</tbody>
</table>
<div class="admonition seealso">
<p class="first admonition-title">See also</p>
<dl class="last docutils">
<dt><a class="reference internal" href="#distributed.client.Client.gather" title="distributed.client.Client.gather"><code class="xref py py-obj docutils literal"><span class="pre">Client.gather</span></code></a></dt>
<dd>Gather data back to local process</dd>
</dl>
</div>
<p class="rubric">Examples</p>
<div class="highlight-default"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">c</span> <span class="o">=</span> <span class="n">Client</span><span class="p">(</span><span class="s1">'127.0.0.1:8787'</span><span class="p">)</span>
<span class="gp">>>> </span><span class="n">c</span><span class="o">.</span><span class="n">scatter</span><span class="p">(</span><span class="mi">1</span><span class="p">)</span>
<span class="go"><Future: status: finished, key: c0a8a20f903a4915b94db8de3ea63195></span>
</pre></div>
</div>
<div class="highlight-default"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">c</span><span class="o">.</span><span class="n">scatter</span><span class="p">([</span><span class="mi">1</span><span class="p">,</span> <span class="mi">2</span><span class="p">,</span> <span class="mi">3</span><span class="p">])</span>
<span class="go">[<Future: status: finished, key: c0a8a20f903a4915b94db8de3ea63195>,</span>
<span class="go"> <Future: status: finished, key: 58e78e1b34eb49a68c65b54815d1b158>,</span>
<span class="go"> <Future: status: finished, key: d3395e15f605bc35ab1bac6341a285e2>]</span>
</pre></div>
</div>
<div class="highlight-default"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">c</span><span class="o">.</span><span class="n">scatter</span><span class="p">({</span><span class="s1">'x'</span><span class="p">:</span> <span class="mi">1</span><span class="p">,</span> <span class="s1">'y'</span><span class="p">:</span> <span class="mi">2</span><span class="p">,</span> <span class="s1">'z'</span><span class="p">:</span> <span class="mi">3</span><span class="p">})</span>
<span class="go">{'x': <Future: status: finished, key: x>,</span>
<span class="go"> 'y': <Future: status: finished, key: y>,</span>
<span class="go"> 'z': <Future: status: finished, key: z>}</span>
</pre></div>
</div>
<p>Constrain location of data to subset of workers</p>
<div class="highlight-default"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">c</span><span class="o">.</span><span class="n">scatter</span><span class="p">([</span><span class="mi">1</span><span class="p">,</span> <span class="mi">2</span><span class="p">,</span> <span class="mi">3</span><span class="p">],</span> <span class="n">workers</span><span class="o">=</span><span class="p">[(</span><span class="s1">'hostname'</span><span class="p">,</span> <span class="mi">8788</span><span class="p">)])</span>
</pre></div>
</div>
<p>Handle streaming sequences of data with iterators or queues</p>
<div class="highlight-default"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">seq</span> <span class="o">=</span> <span class="n">c</span><span class="o">.</span><span class="n">scatter</span><span class="p">(</span><span class="nb">iter</span><span class="p">([</span><span class="mi">1</span><span class="p">,</span> <span class="mi">2</span><span class="p">,</span> <span class="mi">3</span><span class="p">]))</span>
<span class="gp">>>> </span><span class="nb">next</span><span class="p">(</span><span class="n">seq</span><span class="p">)</span>
<span class="go"><Future: status: finished, key: c0a8a20f903a4915b94db8de3ea63195>,</span>
</pre></div>
</div>
<p>Broadcast data to all workers</p>
<div class="highlight-default"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="p">[</span><span class="n">future</span><span class="p">]</span> <span class="o">=</span> <span class="n">c</span><span class="o">.</span><span class="n">scatter</span><span class="p">([</span><span class="n">element</span><span class="p">],</span> <span class="n">broadcast</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span>
</pre></div>
</div>
</dd></dl>
<dl class="method">
<dt id="distributed.client.Client.scheduler_info">
<code class="descname">scheduler_info</code><span class="sig-paren">(</span><em>**kwargs</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/distributed/client.html#Client.scheduler_info"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#distributed.client.Client.scheduler_info" title="Permalink to this definition">¶</a></dt>
<dd><p>Basic information about the workers in the cluster</p>
<p class="rubric">Examples</p>
<div class="highlight-default"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">c</span><span class="o">.</span><span class="n">scheduler_info</span><span class="p">()</span>
<span class="go">{'id': '2de2b6da-69ee-11e6-ab6a-e82aea155996',</span>
<span class="go"> 'services': {},</span>
<span class="go"> 'type': 'Scheduler',</span>
<span class="go"> 'workers': {'127.0.0.1:40575': {'active': 0,</span>
<span class="go"> 'last-seen': 1472038237.4845693,</span>
<span class="go"> 'name': '127.0.0.1:40575',</span>
<span class="go"> 'services': {},</span>
<span class="go"> 'stored': 0,</span>
<span class="go"> 'time-delay': 0.0061032772064208984}}}</span>
</pre></div>
</div>
</dd></dl>
<dl class="method">
<dt id="distributed.client.Client.set_metadata">
<code class="descname">set_metadata</code><span class="sig-paren">(</span><em>key</em>, <em>value</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/distributed/client.html#Client.set_metadata"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#distributed.client.Client.set_metadata" title="Permalink to this definition">¶</a></dt>
<dd><p>Set arbitrary metadata in the scheduler</p>
<p>This allows you to store small amounts of data on the central scheduler
process for administrative purposes. Data should be msgpack
serializable (ints, strings, lists, dicts)</p>
<p>If the key corresponds to a task then that key will be cleaned up when
the task is forgotten by the scheduler.</p>
<p>If the key is a list then it will be assumed that you want to index
into a nested dictionary structure using those keys. For example if
you call the following:</p>
<div class="highlight-default"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">client</span><span class="o">.</span><span class="n">set_metadata</span><span class="p">([</span><span class="s1">'a'</span><span class="p">,</span> <span class="s1">'b'</span><span class="p">,</span> <span class="s1">'c'</span><span class="p">],</span> <span class="mi">123</span><span class="p">)</span>
</pre></div>
</div>
<p>Then this is the same as setting</p>
<div class="highlight-default"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">scheduler</span><span class="o">.</span><span class="n">task_metadata</span><span class="p">[</span><span class="s1">'a'</span><span class="p">][</span><span class="s1">'b'</span><span class="p">][</span><span class="s1">'c'</span><span class="p">]</span> <span class="o">=</span> <span class="mi">123</span>
</pre></div>
</div>
<p>The lower level dictionaries will be created on demand.</p>
<div class="admonition seealso">
<p class="first admonition-title">See also</p>
<p class="last"><a class="reference internal" href="#distributed.client.Client.get_metadata" title="distributed.client.Client.get_metadata"><code class="xref py py-obj docutils literal"><span class="pre">get_metadata</span></code></a></p>
</div>
<p class="rubric">Examples</p>
<div class="highlight-default"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">client</span><span class="o">.</span><span class="n">set_metadata</span><span class="p">(</span><span class="s1">'x'</span><span class="p">,</span> <span class="mi">123</span><span class="p">)</span>
<span class="gp">>>> </span><span class="n">client</span><span class="o">.</span><span class="n">get_metadata</span><span class="p">(</span><span class="s1">'x'</span><span class="p">)</span>
<span class="go">123</span>
</pre></div>
</div>
<div class="highlight-default"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">client</span><span class="o">.</span><span class="n">set_metadata</span><span class="p">([</span><span class="s1">'x'</span><span class="p">,</span> <span class="s1">'y'</span><span class="p">],</span> <span class="mi">123</span><span class="p">)</span>
<span class="gp">>>> </span><span class="n">client</span><span class="o">.</span><span class="n">get_metadata</span><span class="p">(</span><span class="s1">'x'</span><span class="p">)</span>
<span class="go">{'y': 123}</span>
</pre></div>
</div>
<div class="highlight-default"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">client</span><span class="o">.</span><span class="n">set_metadata</span><span class="p">([</span><span class="s1">'x'</span><span class="p">,</span> <span class="s1">'w'</span><span class="p">,</span> <span class="s1">'z'</span><span class="p">],</span> <span class="mi">456</span><span class="p">)</span>
<span class="gp">>>> </span><span class="n">client</span><span class="o">.</span><span class="n">get_metadata</span><span class="p">(</span><span class="s1">'x'</span><span class="p">)</span>
<span class="go">{'y': 123, 'w': {'z': 456}}</span>
</pre></div>
</div>
<div class="highlight-default"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">client</span><span class="o">.</span><span class="n">get_metadata</span><span class="p">([</span><span class="s1">'x'</span><span class="p">,</span> <span class="s1">'w'</span><span class="p">])</span>
<span class="go">{'z': 456}</span>
</pre></div>
</div>
</dd></dl>
<dl class="method">
<dt id="distributed.client.Client.shutdown">
<code class="descname">shutdown</code><span class="sig-paren">(</span><em>timeout=10</em><span class="sig-paren">)</span><a class="headerlink" href="#distributed.client.Client.shutdown" title="Permalink to this definition">¶</a></dt>
<dd><p>Close this client</p>
<p>Clients will also close automatically when your Python session ends</p>
<p>If you started a client without arguments like <code class="docutils literal"><span class="pre">Client()</span></code> then this
will also close the local cluster that was started at the same time.</p>
<div class="admonition seealso">
<p class="first admonition-title">See also</p>
<p class="last"><a class="reference internal" href="#distributed.client.Client.restart" title="distributed.client.Client.restart"><code class="xref py py-obj docutils literal"><span class="pre">Client.restart</span></code></a></p>
</div>
</dd></dl>
<dl class="method">
<dt id="distributed.client.Client.stacks">
<code class="descname">stacks</code><span class="sig-paren">(</span><em>workers=None</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/distributed/client.html#Client.stacks"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#distributed.client.Client.stacks" title="Permalink to this definition">¶</a></dt>
<dd><p>The task queues on each worker</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><p class="first"><strong>workers: list (optional)</strong></p>
<blockquote class="last">
<div><p>A list of worker addresses, defaults to all</p>
</div></blockquote>
</td>
</tr>
</tbody>
</table>
<div class="admonition seealso">
<p class="first admonition-title">See also</p>
<p class="last"><a class="reference internal" href="#distributed.client.Client.processing" title="distributed.client.Client.processing"><code class="xref py py-obj docutils literal"><span class="pre">Client.processing</span></code></a>, <a class="reference internal" href="#distributed.client.Client.who_has" title="distributed.client.Client.who_has"><code class="xref py py-obj docutils literal"><span class="pre">Client.who_has</span></code></a>, <a class="reference internal" href="#distributed.client.Client.has_what" title="distributed.client.Client.has_what"><code class="xref py py-obj docutils literal"><span class="pre">Client.has_what</span></code></a>, <a class="reference internal" href="#distributed.client.Client.ncores" title="distributed.client.Client.ncores"><code class="xref py py-obj docutils literal"><span class="pre">Client.ncores</span></code></a></p>
</div>
<p class="rubric">Examples</p>
<div class="highlight-default"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">x</span><span class="p">,</span> <span class="n">y</span><span class="p">,</span> <span class="n">z</span> <span class="o">=</span> <span class="n">c</span><span class="o">.</span><span class="n">map</span><span class="p">(</span><span class="n">inc</span><span class="p">,</span> <span class="p">[</span><span class="mi">1</span><span class="p">,</span> <span class="mi">2</span><span class="p">,</span> <span class="mi">3</span><span class="p">])</span>
<span class="gp">>>> </span><span class="n">c</span><span class="o">.</span><span class="n">stacks</span><span class="p">()</span>
<span class="go">{'192.168.1.141:46784': ['inc-1c8dd6be1c21646c71f76c16d09304ea',</span>
<span class="go"> 'inc-fd65c238a7ea60f6a01bf4c8a5fcf44b',</span>
<span class="go"> 'inc-1e297fc27658d7b67b3a758f16bcf47a']}</span>
</pre></div>
</div>
</dd></dl>
<dl class="method">
<dt id="distributed.client.Client.start">
<code class="descname">start</code><span class="sig-paren">(</span><em>**kwargs</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/distributed/client.html#Client.start"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#distributed.client.Client.start" title="Permalink to this definition">¶</a></dt>
<dd><p>Start scheduler running in separate thread</p>
</dd></dl>
<dl class="method">
<dt id="distributed.client.Client.start_ipython_scheduler">
<code class="descname">start_ipython_scheduler</code><span class="sig-paren">(</span><em>magic_name='scheduler_if_ipython'</em>, <em>qtconsole=False</em>, <em>qtconsole_args=None</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/distributed/client.html#Client.start_ipython_scheduler"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#distributed.client.Client.start_ipython_scheduler" title="Permalink to this definition">¶</a></dt>
<dd><p>Start IPython kernel on the scheduler</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><p class="first"><strong>magic_name: str or None (optional)</strong></p>
<blockquote>
<div><p>If defined, register IPython magic with this name for
executing code on the scheduler.
If not defined, register %scheduler magic if IPython is running.</p>
</div></blockquote>
<p><strong>qtconsole: bool (optional)</strong></p>
<blockquote>
<div><p>If True, launch a Jupyter QtConsole connected to the worker(s).</p>
</div></blockquote>
<p><strong>qtconsole_args: list(str) (optional)</strong></p>
<blockquote>
<div><p>Additional arguments to pass to the qtconsole on startup.</p>
</div></blockquote>
</td>
</tr>
<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first">connection_info: dict</p>
<blockquote class="last">
<div><p>connection_info dict containing info necessary
to connect Jupyter clients to the scheduler.</p>
</div></blockquote>
</td>
</tr>
</tbody>
</table>
<div class="admonition seealso">
<p class="first admonition-title">See also</p>
<dl class="last docutils">
<dt><a class="reference internal" href="#distributed.client.Client.start_ipython_workers" title="distributed.client.Client.start_ipython_workers"><code class="xref py py-obj docutils literal"><span class="pre">Client.start_ipython_workers</span></code></a></dt>
<dd>Start IPython on the workers</dd>
</dl>
</div>
<p class="rubric">Examples</p>
<div class="highlight-default"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">c</span><span class="o">.</span><span class="n">start_ipython_scheduler</span><span class="p">()</span>
<span class="gp">>>> </span><span class="o">%</span><span class="n">scheduler</span> <span class="n">scheduler</span><span class="o">.</span><span class="n">processing</span>
<span class="go">{'127.0.0.1:3595': {'inc-1', 'inc-2'},</span>
<span class="go"> '127.0.0.1:53589': {'inc-2', 'add-5'}}</span>
</pre></div>
</div>
<div class="highlight-default"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">c</span><span class="o">.</span><span class="n">start_ipython_scheduler</span><span class="p">(</span><span class="n">qtconsole</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span>
</pre></div>
</div>
</dd></dl>
<dl class="method">
<dt id="distributed.client.Client.start_ipython_workers">
<code class="descname">start_ipython_workers</code><span class="sig-paren">(</span><em>workers=None</em>, <em>magic_names=False</em>, <em>qtconsole=False</em>, <em>qtconsole_args=None</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/distributed/client.html#Client.start_ipython_workers"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#distributed.client.Client.start_ipython_workers" title="Permalink to this definition">¶</a></dt>
<dd><p>Start IPython kernels on workers</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><p class="first"><strong>workers: list (optional)</strong></p>
<blockquote>
<div><p>A list of worker addresses, defaults to all</p>
</div></blockquote>
<p><strong>magic_names: str or list(str) (optional)</strong></p>
<blockquote>
<div><p>If defined, register IPython magics with these names for
executing code on the workers. If string has asterix then expand
asterix into 0, 1, …, n for n workers</p>
</div></blockquote>
<p><strong>qtconsole: bool (optional)</strong></p>
<blockquote>
<div><p>If True, launch a Jupyter QtConsole connected to the worker(s).</p>
</div></blockquote>
<p><strong>qtconsole_args: list(str) (optional)</strong></p>
<blockquote>
<div><p>Additional arguments to pass to the qtconsole on startup.</p>
</div></blockquote>
</td>
</tr>
<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first">iter_connection_info: list</p>
<blockquote class="last">
<div><p>List of connection_info dicts containing info necessary
to connect Jupyter clients to the workers.</p>
</div></blockquote>
</td>
</tr>
</tbody>
</table>
<div class="admonition seealso">
<p class="first admonition-title">See also</p>
<dl class="last docutils">
<dt><a class="reference internal" href="#distributed.client.Client.start_ipython_scheduler" title="distributed.client.Client.start_ipython_scheduler"><code class="xref py py-obj docutils literal"><span class="pre">Client.start_ipython_scheduler</span></code></a></dt>
<dd>start ipython on the scheduler</dd>
</dl>
</div>
<p class="rubric">Examples</p>
<div class="highlight-default"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">info</span> <span class="o">=</span> <span class="n">c</span><span class="o">.</span><span class="n">start_ipython_workers</span><span class="p">()</span>
<span class="gp">>>> </span><span class="o">%</span><span class="n">remote</span> <span class="n">info</span><span class="p">[</span><span class="s1">'192.168.1.101:5752'</span><span class="p">]</span> <span class="n">worker</span><span class="o">.</span><span class="n">data</span>
<span class="go">{'x': 1, 'y': 100}</span>
</pre></div>
</div>
<div class="highlight-default"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">c</span><span class="o">.</span><span class="n">start_ipython_workers</span><span class="p">(</span><span class="s1">'192.168.1.101:5752'</span><span class="p">,</span> <span class="n">magic_names</span><span class="o">=</span><span class="s1">'w'</span><span class="p">)</span>
<span class="gp">>>> </span><span class="o">%</span><span class="n">w</span> <span class="n">worker</span><span class="o">.</span><span class="n">data</span>
<span class="go">{'x': 1, 'y': 100}</span>
</pre></div>
</div>
<div class="highlight-default"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">c</span><span class="o">.</span><span class="n">start_ipython_workers</span><span class="p">(</span><span class="s1">'192.168.1.101:5752'</span><span class="p">,</span> <span class="n">qtconsole</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span>
</pre></div>
</div>
<p>Add asterix * in magic names to add one magic per worker</p>
<div class="highlight-default"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">c</span><span class="o">.</span><span class="n">start_ipython_workers</span><span class="p">(</span><span class="n">magic_names</span><span class="o">=</span><span class="s1">'w_*'</span><span class="p">)</span>
<span class="gp">>>> </span><span class="o">%</span><span class="n">w_0</span> <span class="n">worker</span><span class="o">.</span><span class="n">data</span>
<span class="go">{'x': 1, 'y': 100}</span>
<span class="gp">>>> </span><span class="o">%</span><span class="n">w_1</span> <span class="n">worker</span><span class="o">.</span><span class="n">data</span>
<span class="go">{'z': 5}</span>
</pre></div>
</div>
</dd></dl>
<dl class="method">
<dt id="distributed.client.Client.submit">
<code class="descname">submit</code><span class="sig-paren">(</span><em>func</em>, <em>*args</em>, <em>**kwargs</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/distributed/client.html#Client.submit"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#distributed.client.Client.submit" title="Permalink to this definition">¶</a></dt>
<dd><p>Submit a function application to the scheduler</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><p class="first"><strong>func: callable</strong></p>
<p><strong>*args:</strong></p>
<p><strong>**kwargs:</strong></p>
<p><strong>pure: bool (defaults to True)</strong></p>
<blockquote>
<div><p>Whether or not the function is pure. Set <code class="docutils literal"><span class="pre">pure=False</span></code> for
impure functions like <code class="docutils literal"><span class="pre">np.random.random</span></code>.</p>
</div></blockquote>
<p><strong>workers: set, iterable of sets</strong></p>
<blockquote>
<div><p>A set of worker hostnames on which computations may be performed.
Leave empty to default to all workers (common case)</p>
</div></blockquote>
<p><strong>key: str</strong></p>
<blockquote>
<div><p>Unique identifier for the task. Defaults to function-name and hash</p>
</div></blockquote>
<p><strong>allow_other_workers: bool (defaults to False)</strong></p>
<blockquote>
<div><p>Used with <cite>workers</cite>. Inidicates whether or not the computations
may be performed on workers that are not in the <cite>workers</cite> set(s).</p>
</div></blockquote>
<p><strong>retries: int (default to 0)</strong></p>
<blockquote>
<div><p>Number of allowed automatic retries if the task fails</p>
</div></blockquote>
</td>
</tr>
<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first last">Future</p>
</td>
</tr>
</tbody>
</table>
<div class="admonition seealso">
<p class="first admonition-title">See also</p>
<dl class="last docutils">
<dt><a class="reference internal" href="#distributed.client.Client.map" title="distributed.client.Client.map"><code class="xref py py-obj docutils literal"><span class="pre">Client.map</span></code></a></dt>
<dd>Submit on many arguments at once</dd>
</dl>
</div>
<p class="rubric">Examples</p>
<div class="highlight-default"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">c</span> <span class="o">=</span> <span class="n">client</span><span class="o">.</span><span class="n">submit</span><span class="p">(</span><span class="n">add</span><span class="p">,</span> <span class="n">a</span><span class="p">,</span> <span class="n">b</span><span class="p">)</span>
</pre></div>
</div>
</dd></dl>
<dl class="method">
<dt id="distributed.client.Client.unpublish_dataset">
<code class="descname">unpublish_dataset</code><span class="sig-paren">(</span><em>name</em>, <em>**kwargs</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/distributed/client.html#Client.unpublish_dataset"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#distributed.client.Client.unpublish_dataset" title="Permalink to this definition">¶</a></dt>
<dd><p>Remove named datasets from scheduler</p>
<div class="admonition seealso">
<p class="first admonition-title">See also</p>
<p class="last"><a class="reference internal" href="#distributed.client.Client.publish_dataset" title="distributed.client.Client.publish_dataset"><code class="xref py py-obj docutils literal"><span class="pre">Client.publish_dataset</span></code></a></p>
</div>
<p class="rubric">Examples</p>
<div class="highlight-default"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">c</span><span class="o">.</span><span class="n">list_datasets</span><span class="p">()</span>
<span class="go">['my_dataset']</span>
<span class="gp">>>> </span><span class="n">c</span><span class="o">.</span><span class="n">unpublish_datasets</span><span class="p">(</span><span class="s1">'my_dataset'</span><span class="p">)</span>
<span class="gp">>>> </span><span class="n">c</span><span class="o">.</span><span class="n">list_datasets</span><span class="p">()</span>
<span class="go">[]</span>
</pre></div>
</div>
</dd></dl>
<dl class="method">
<dt id="distributed.client.Client.upload_file">
<code class="descname">upload_file</code><span class="sig-paren">(</span><em>filename</em>, <em>**kwargs</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/distributed/client.html#Client.upload_file"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#distributed.client.Client.upload_file" title="Permalink to this definition">¶</a></dt>
<dd><p>Upload local package to workers</p>
<p>This sends a local file up to all worker nodes. This file is placed
into a temporary directory on Python’s system path so any .py, .pyc, .egg
or .zip files will be importable.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><p class="first"><strong>filename: string</strong></p>
<blockquote class="last">
<div><p>Filename of .py, .pyc, .egg or .zip file to send to workers</p>
</div></blockquote>
</td>
</tr>
</tbody>
</table>
<p class="rubric">Examples</p>
<div class="highlight-default"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">client</span><span class="o">.</span><span class="n">upload_file</span><span class="p">(</span><span class="s1">'mylibrary.egg'</span><span class="p">)</span>
<span class="gp">>>> </span><span class="kn">from</span> <span class="nn">mylibrary</span> <span class="k">import</span> <span class="n">myfunc</span>
<span class="gp">>>> </span><span class="n">L</span> <span class="o">=</span> <span class="n">c</span><span class="o">.</span><span class="n">map</span><span class="p">(</span><span class="n">myfunc</span><span class="p">,</span> <span class="n">seq</span><span class="p">)</span>
</pre></div>
</div>
</dd></dl>
<dl class="method">
<dt id="distributed.client.Client.who_has">
<code class="descname">who_has</code><span class="sig-paren">(</span><em>futures=None</em>, <em>**kwargs</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/distributed/client.html#Client.who_has"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#distributed.client.Client.who_has" title="Permalink to this definition">¶</a></dt>
<dd><p>The workers storing each future’s data</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><p class="first"><strong>futures: list (optional)</strong></p>
<blockquote class="last">
<div><p>A list of futures, defaults to all data</p>
</div></blockquote>
</td>
</tr>
</tbody>
</table>
<div class="admonition seealso">
<p class="first admonition-title">See also</p>
<p class="last"><a class="reference internal" href="#distributed.client.Client.has_what" title="distributed.client.Client.has_what"><code class="xref py py-obj docutils literal"><span class="pre">Client.has_what</span></code></a>, <a class="reference internal" href="#distributed.client.Client.ncores" title="distributed.client.Client.ncores"><code class="xref py py-obj docutils literal"><span class="pre">Client.ncores</span></code></a></p>
</div>
<p class="rubric">Examples</p>
<div class="highlight-default"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">x</span><span class="p">,</span> <span class="n">y</span><span class="p">,</span> <span class="n">z</span> <span class="o">=</span> <span class="n">c</span><span class="o">.</span><span class="n">map</span><span class="p">(</span><span class="n">inc</span><span class="p">,</span> <span class="p">[</span><span class="mi">1</span><span class="p">,</span> <span class="mi">2</span><span class="p">,</span> <span class="mi">3</span><span class="p">])</span>
<span class="gp">>>> </span><span class="n">wait</span><span class="p">([</span><span class="n">x</span><span class="p">,</span> <span class="n">y</span><span class="p">,</span> <span class="n">z</span><span class="p">])</span>
<span class="gp">>>> </span><span class="n">c</span><span class="o">.</span><span class="n">who_has</span><span class="p">()</span>
<span class="go">{'inc-1c8dd6be1c21646c71f76c16d09304ea': ['192.168.1.141:46784'],</span>
<span class="go"> 'inc-1e297fc27658d7b67b3a758f16bcf47a': ['192.168.1.141:46784'],</span>
<span class="go"> 'inc-fd65c238a7ea60f6a01bf4c8a5fcf44b': ['192.168.1.141:46784']}</span>
</pre></div>
</div>
<div class="highlight-default"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">c</span><span class="o">.</span><span class="n">who_has</span><span class="p">([</span><span class="n">x</span><span class="p">,</span> <span class="n">y</span><span class="p">])</span>
<span class="go">{'inc-1c8dd6be1c21646c71f76c16d09304ea': ['192.168.1.141:46784'],</span>
<span class="go"> 'inc-1e297fc27658d7b67b3a758f16bcf47a': ['192.168.1.141:46784']}</span>
</pre></div>
</div>
</dd></dl>
</dd></dl>
<dl class="class">
<dt id="distributed.recreate_exceptions.ReplayExceptionClient">
<em class="property">class </em><code class="descclassname">distributed.recreate_exceptions.</code><code class="descname">ReplayExceptionClient</code><span class="sig-paren">(</span><em>client</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/distributed/recreate_exceptions.html#ReplayExceptionClient"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#distributed.recreate_exceptions.ReplayExceptionClient" title="Permalink to this definition">¶</a></dt>
<dd><p>A plugin for the client allowing replay of remote exceptions locally</p>
<p>Adds the following methods (and their async variants)to the given client:</p>
<ul class="simple">
<li><code class="docutils literal"><span class="pre">recreate_error_locally</span></code>: main user method</li>
<li><dl class="first docutils">
<dt><code class="docutils literal"><span class="pre">get_futures_error</span></code>: gets the task, its details and dependencies,</dt>
<dd>responsible for failure of the given future.</dd>
</dl>
</li>
</ul>
<dl class="method">
<dt id="distributed.recreate_exceptions.ReplayExceptionClient.get_futures_error">
<code class="descname">get_futures_error</code><span class="sig-paren">(</span><em>future</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/distributed/recreate_exceptions.html#ReplayExceptionClient.get_futures_error"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#distributed.recreate_exceptions.ReplayExceptionClient.get_futures_error" title="Permalink to this definition">¶</a></dt>
<dd><p>Ask the scheduler details of the sub-task of the given failed future</p>
<p>When a future evaluates to a status of “error”, i.e., an exception
was raised in a task within its graph, we an get information from
the scheduler. This function gets the details of the specific task
that raised the exception and led to the error, but does not fetch
data from the cluster or execute the function.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><p class="first"><strong>future</strong> : future that failed, having <code class="docutils literal"><span class="pre">status=="error"</span></code>, typically</p>
<blockquote>
<div><p>after an attempt to <code class="docutils literal"><span class="pre">gather()</span></code> shows a stack-stace.</p>
</div></blockquote>
</td>
</tr>
<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first">Tuple:</p>
<ul class="last simple">
<li>the function that raised an exception</li>
<li>argument list (a tuple), may include values and keys</li>
<li>keyword arguments (a dictionary), may include values and keys</li>
<li>list of keys that the function requires to be fetched to run</li>
</ul>
</td>
</tr>
</tbody>
</table>
<div class="admonition seealso">
<p class="first admonition-title">See also</p>
<p class="last"><a class="reference internal" href="#distributed.recreate_exceptions.ReplayExceptionClient.recreate_error_locally" title="distributed.recreate_exceptions.ReplayExceptionClient.recreate_error_locally"><code class="xref py py-obj docutils literal"><span class="pre">ReplayExceptionClient.recreate_error_locally</span></code></a></p>
</div>
</dd></dl>
<dl class="method">
<dt id="distributed.recreate_exceptions.ReplayExceptionClient.recreate_error_locally">
<code class="descname">recreate_error_locally</code><span class="sig-paren">(</span><em>future</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/distributed/recreate_exceptions.html#ReplayExceptionClient.recreate_error_locally"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#distributed.recreate_exceptions.ReplayExceptionClient.recreate_error_locally" title="Permalink to this definition">¶</a></dt>
<dd><p>For a failed calculation, perform the blamed task locally for debugging.</p>
<p>This operation should be performed after a future (result of <code class="docutils literal"><span class="pre">gather</span></code>,
<code class="docutils literal"><span class="pre">compute</span></code>, etc) comes back with a status of “error”, if the stack-
trace is not informative enough to diagnose the problem. The specific
task (part of the graph pointing to the future) responsible for the
error will be fetched from the scheduler, together with the values of
its inputs. The function will then be executed, so that <code class="docutils literal"><span class="pre">pdb</span></code> can
be used for debugging.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><p class="first"><strong>future</strong> : future or collection that failed</p>
<blockquote>
<div><p>The same thing as was given to <code class="docutils literal"><span class="pre">gather</span></code>, but came back with
an exception/stack-trace. Can also be a (persisted) dask collection
containing any errored futures.</p>
</div></blockquote>
</td>
</tr>
<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first">Nothing; the function runs and should raise an exception, allowing</p>
<p class="last">the debugger to run.</p>
</td>
</tr>
</tbody>
</table>
<p class="rubric">Examples</p>
<div class="highlight-default"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">future</span> <span class="o">=</span> <span class="n">c</span><span class="o">.</span><span class="n">submit</span><span class="p">(</span><span class="n">div</span><span class="p">,</span> <span class="mi">1</span><span class="p">,</span> <span class="mi">0</span><span class="p">)</span>
<span class="gp">>>> </span><span class="n">future</span><span class="o">.</span><span class="n">status</span>
<span class="go">'error'</span>
<span class="gp">>>> </span><span class="n">c</span><span class="o">.</span><span class="n">recreate_error_locally</span><span class="p">(</span><span class="n">future</span><span class="p">)</span>
<span class="go">ZeroDivisionError: division by zero</span>
</pre></div>
</div>
<p>If you’re in IPython you might take this opportunity to use pdb</p>
<div class="highlight-default"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="o">%</span><span class="n">pdb</span>
<span class="go">Automatic pdb calling has been turned ON</span>
</pre></div>
</div>
<div class="highlight-default"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">c</span><span class="o">.</span><span class="n">recreate_error_locally</span><span class="p">(</span><span class="n">future</span><span class="p">)</span>
<span class="go">ZeroDivisionError: division by zero</span>
<span class="go"> 1 def div(x, y):</span>
<span class="go">----> 2 return x / y</span>
<span class="go">ipdb></span>
</pre></div>
</div>
</dd></dl>
</dd></dl>
</div>
<div class="section" id="future">
<h2>Future<a class="headerlink" href="#future" title="Permalink to this headline">¶</a></h2>
<dl class="class">
<dt id="distributed.client.Future">
<em class="property">class </em><code class="descclassname">distributed.client.</code><code class="descname">Future</code><span class="sig-paren">(</span><em>key</em>, <em>client=None</em>, <em>inform=True</em>, <em>state=None</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/distributed/client.html#Future"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#distributed.client.Future" title="Permalink to this definition">¶</a></dt>
<dd><p>A remotely running computation</p>
<p>A Future is a local proxy to a result running on a remote worker. A user
manages future objects in the local Python process to determine what
happens in the larger cluster.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><p class="first"><strong>key: str, or tuple</strong></p>
<blockquote>
<div><p>Key of remote data to which this future refers</p>
</div></blockquote>
<p><strong>client: Client</strong></p>
<blockquote>
<div><p>Client that should own this future. Defaults to _get_global_client()</p>
</div></blockquote>
<p><strong>inform: bool</strong></p>
<blockquote class="last">
<div><p>Do we inform the scheduler that we need an update on this future</p>
</div></blockquote>
</td>
</tr>
</tbody>
</table>
<div class="admonition seealso">
<p class="first admonition-title">See also</p>
<dl class="last docutils">
<dt><a class="reference internal" href="#distributed.client.Client" title="distributed.client.Client"><code class="xref py py-obj docutils literal"><span class="pre">Client</span></code></a></dt>
<dd>Creates futures</dd>
</dl>
</div>
<p class="rubric">Examples</p>
<p>Futures typically emerge from Client computations</p>
<div class="highlight-default"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">my_future</span> <span class="o">=</span> <span class="n">client</span><span class="o">.</span><span class="n">submit</span><span class="p">(</span><span class="n">add</span><span class="p">,</span> <span class="mi">1</span><span class="p">,</span> <span class="mi">2</span><span class="p">)</span>
</pre></div>
</div>
<p>We can track the progress and results of a future</p>
<div class="highlight-default"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">my_future</span>
<span class="go"><Future: status: finished, key: add-8f6e709446674bad78ea8aeecfee188e></span>
</pre></div>
</div>
<p>We can get the result or the exception and traceback from the future</p>
<div class="highlight-default"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">my_future</span><span class="o">.</span><span class="n">result</span><span class="p">()</span>
</pre></div>
</div>
<dl class="method">
<dt id="distributed.client.Future.add_done_callback">
<code class="descname">add_done_callback</code><span class="sig-paren">(</span><em>fn</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/distributed/client.html#Future.add_done_callback"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#distributed.client.Future.add_done_callback" title="Permalink to this definition">¶</a></dt>
<dd><p>Call callback on future when callback has finished</p>
<p>The callback <code class="docutils literal"><span class="pre">fn</span></code> should take the future as its only argument. This
will be called regardless of if the future completes successfully,
errs, or is cancelled</p>
<p>The callback is executed in a separate thread.</p>
</dd></dl>
<dl class="method">
<dt id="distributed.client.Future.cancel">
<code class="descname">cancel</code><span class="sig-paren">(</span><em>**kwargs</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/distributed/client.html#Future.cancel"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#distributed.client.Future.cancel" title="Permalink to this definition">¶</a></dt>
<dd><p>Cancel request to run this future</p>
<div class="admonition seealso">
<p class="first admonition-title">See also</p>
<p class="last"><a class="reference internal" href="#distributed.client.Client.cancel" title="distributed.client.Client.cancel"><code class="xref py py-obj docutils literal"><span class="pre">Client.cancel</span></code></a></p>
</div>
</dd></dl>
<dl class="method">
<dt id="distributed.client.Future.cancelled">
<code class="descname">cancelled</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference internal" href="_modules/distributed/client.html#Future.cancelled"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#distributed.client.Future.cancelled" title="Permalink to this definition">¶</a></dt>
<dd><p>Returns True if the future has been cancelled</p>
</dd></dl>
<dl class="method">
<dt id="distributed.client.Future.done">
<code class="descname">done</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference internal" href="_modules/distributed/client.html#Future.done"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#distributed.client.Future.done" title="Permalink to this definition">¶</a></dt>
<dd><p>Is the computation complete?</p>
</dd></dl>
<dl class="method">
<dt id="distributed.client.Future.exception">
<code class="descname">exception</code><span class="sig-paren">(</span><em>timeout=None</em>, <em>**kwargs</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/distributed/client.html#Future.exception"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#distributed.client.Future.exception" title="Permalink to this definition">¶</a></dt>
<dd><p>Return the exception of a failed task</p>
<p>If <em>timeout</em> seconds are elapsed before returning, a TimeoutError
is raised.</p>
<div class="admonition seealso">
<p class="first admonition-title">See also</p>
<p class="last"><a class="reference internal" href="#distributed.client.Future.traceback" title="distributed.client.Future.traceback"><code class="xref py py-obj docutils literal"><span class="pre">Future.traceback</span></code></a></p>
</div>
</dd></dl>
<dl class="method">
<dt id="distributed.client.Future.result">
<code class="descname">result</code><span class="sig-paren">(</span><em>timeout=None</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/distributed/client.html#Future.result"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#distributed.client.Future.result" title="Permalink to this definition">¶</a></dt>
<dd><p>Wait until computation completes, gather result to local process.</p>
<p>If <em>timeout</em> seconds are elapsed before returning, a TimeoutError
is raised.</p>
</dd></dl>
<dl class="method">
<dt id="distributed.client.Future.traceback">
<code class="descname">traceback</code><span class="sig-paren">(</span><em>timeout=None</em>, <em>**kwargs</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/distributed/client.html#Future.traceback"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#distributed.client.Future.traceback" title="Permalink to this definition">¶</a></dt>
<dd><p>Return the traceback of a failed task</p>
<p>This returns a traceback object. You can inspect this object using the
<code class="docutils literal"><span class="pre">traceback</span></code> module. Alternatively if you call <code class="docutils literal"><span class="pre">future.result()</span></code>
this traceback will accompany the raised exception.</p>
<p>If <em>timeout</em> seconds are elapsed before returning, a TimeoutError
is raised.</p>
<div class="admonition seealso">
<p class="first admonition-title">See also</p>
<p class="last"><a class="reference internal" href="#distributed.client.Future.exception" title="distributed.client.Future.exception"><code class="xref py py-obj docutils literal"><span class="pre">Future.exception</span></code></a></p>
</div>
<p class="rubric">Examples</p>
<div class="highlight-default"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="kn">import</span> <span class="nn">traceback</span>
<span class="gp">>>> </span><span class="n">tb</span> <span class="o">=</span> <span class="n">future</span><span class="o">.</span><span class="n">traceback</span><span class="p">()</span>
<span class="gp">>>> </span><span class="n">traceback</span><span class="o">.</span><span class="n">export_tb</span><span class="p">(</span><span class="n">tb</span><span class="p">)</span>
<span class="go">[...]</span>
</pre></div>
</div>
</dd></dl>
</dd></dl>
</div>
<div class="section" id="other">
<h2>Other<a class="headerlink" href="#other" title="Permalink to this headline">¶</a></h2>
<dl class="function">
<dt id="distributed.client.as_completed">
<code class="descclassname">distributed.client.</code><code class="descname">as_completed</code><span class="sig-paren">(</span><em>futures=None</em>, <em>loop=None</em>, <em>with_results=False</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/distributed/client.html#as_completed"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#distributed.client.as_completed" title="Permalink to this definition">¶</a></dt>
<dd><p>Return futures in the order in which they complete</p>
<p>This returns an iterator that yields the input future objects in the order
in which they complete. Calling <code class="docutils literal"><span class="pre">next</span></code> on the iterator will block until
the next future completes, irrespective of order.</p>
<p>Additionally, you can also add more futures to this object during
computation with the <code class="docutils literal"><span class="pre">.add</span></code> method</p>
<p class="rubric">Examples</p>
<div class="highlight-default"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">x</span><span class="p">,</span> <span class="n">y</span><span class="p">,</span> <span class="n">z</span> <span class="o">=</span> <span class="n">client</span><span class="o">.</span><span class="n">map</span><span class="p">(</span><span class="n">inc</span><span class="p">,</span> <span class="p">[</span><span class="mi">1</span><span class="p">,</span> <span class="mi">2</span><span class="p">,</span> <span class="mi">3</span><span class="p">])</span>
<span class="gp">>>> </span><span class="k">for</span> <span class="n">future</span> <span class="ow">in</span> <span class="n">as_completed</span><span class="p">([</span><span class="n">x</span><span class="p">,</span> <span class="n">y</span><span class="p">,</span> <span class="n">z</span><span class="p">]):</span>
<span class="gp">... </span> <span class="nb">print</span><span class="p">(</span><span class="n">future</span><span class="o">.</span><span class="n">result</span><span class="p">())</span>
<span class="go">3</span>
<span class="go">2</span>
<span class="go">4</span>
</pre></div>
</div>
<p>Add more futures during computation</p>
<div class="highlight-default"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">x</span><span class="p">,</span> <span class="n">y</span><span class="p">,</span> <span class="n">z</span> <span class="o">=</span> <span class="n">client</span><span class="o">.</span><span class="n">map</span><span class="p">(</span><span class="n">inc</span><span class="p">,</span> <span class="p">[</span><span class="mi">1</span><span class="p">,</span> <span class="mi">2</span><span class="p">,</span> <span class="mi">3</span><span class="p">])</span>
<span class="gp">>>> </span><span class="n">ac</span> <span class="o">=</span> <span class="n">as_completed</span><span class="p">([</span><span class="n">x</span><span class="p">,</span> <span class="n">y</span><span class="p">,</span> <span class="n">z</span><span class="p">])</span>
<span class="gp">>>> </span><span class="k">for</span> <span class="n">future</span> <span class="ow">in</span> <span class="n">ac</span><span class="p">:</span>
<span class="gp">... </span> <span class="nb">print</span><span class="p">(</span><span class="n">future</span><span class="o">.</span><span class="n">result</span><span class="p">())</span>
<span class="gp">... </span> <span class="k">if</span> <span class="n">random</span><span class="o">.</span><span class="n">random</span><span class="p">()</span> <span class="o"><</span> <span class="mf">0.5</span><span class="p">:</span>
<span class="gp">... </span> <span class="n">ac</span><span class="o">.</span><span class="n">add</span><span class="p">(</span><span class="n">c</span><span class="o">.</span><span class="n">submit</span><span class="p">(</span><span class="n">double</span><span class="p">,</span> <span class="n">future</span><span class="p">))</span>
<span class="go">4</span>
<span class="go">2</span>
<span class="go">8</span>
<span class="go">3</span>
<span class="go">6</span>
<span class="go">12</span>
<span class="go">24</span>
</pre></div>
</div>
<p>Optionally wait until the result has been gathered as well</p>
<div class="highlight-default"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">ac</span> <span class="o">=</span> <span class="n">as_completed</span><span class="p">([</span><span class="n">x</span><span class="p">,</span> <span class="n">y</span><span class="p">,</span> <span class="n">z</span><span class="p">],</span> <span class="n">with_results</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span>
<span class="gp">>>> </span><span class="k">for</span> <span class="n">future</span><span class="p">,</span> <span class="n">result</span> <span class="ow">in</span> <span class="n">ac</span><span class="p">:</span>
<span class="gp">... </span> <span class="nb">print</span><span class="p">(</span><span class="n">result</span><span class="p">)</span>
<span class="go">2</span>
<span class="go">4</span>
<span class="go">3</span>
</pre></div>
</div>
</dd></dl>
<dl class="function">
<dt id="distributed.diagnostics.progress">
<code class="descclassname">distributed.diagnostics.</code><code class="descname">progress</code><span class="sig-paren">(</span><em>*futures</em>, <em>**kwargs</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/distributed/diagnostics/progressbar.html#progress"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#distributed.diagnostics.progress" title="Permalink to this definition">¶</a></dt>
<dd><p>Track progress of futures</p>
<p>This operates differently in the notebook and the console</p>
<ul class="simple">
<li>Notebook: This returns immediately, leaving an IPython widget on screen</li>
<li>Console: This blocks until the computation completes</li>
</ul>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><p class="first"><strong>futures: Futures</strong></p>
<blockquote>
<div><p>A list of futures or keys to track</p>
</div></blockquote>
<p><strong>notebook: bool (optional)</strong></p>
<blockquote>
<div><p>Running in the notebook or not (defaults to guess)</p>
</div></blockquote>
<p><strong>multi: bool (optional)</strong></p>
<blockquote>
<div><p>Track different functions independently (defaults to True)</p>
</div></blockquote>
<p><strong>complete: bool (optional)</strong></p>
<blockquote class="last">
<div><p>Track all keys (True) or only keys that have not yet run (False)
(defaults to True)</p>
</div></blockquote>
</td>
</tr>
</tbody>
</table>
<p class="rubric">Notes</p>
<p>In the notebook, the output of <cite>progress</cite> must be the last statement
in the cell. Typically, this means calling <cite>progress</cite> at the end of a
cell.</p>
<p class="rubric">Examples</p>
<div class="highlight-default"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">progress</span><span class="p">(</span><span class="n">futures</span><span class="p">)</span>
<span class="go">[########################################] | 100% Completed | 1.7s</span>
</pre></div>
</div>
</dd></dl>
<dl class="function">
<dt id="distributed.client.wait">
<code class="descclassname">distributed.client.</code><code class="descname">wait</code><span class="sig-paren">(</span><em>fs</em>, <em>timeout=None</em>, <em>return_when='ALL_COMPLETED'</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/distributed/client.html#wait"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#distributed.client.wait" title="Permalink to this definition">¶</a></dt>
<dd><p>Wait until all futures are complete</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><p class="first"><strong>fs: list of futures</strong></p>
<p><strong>timeout: number, optional</strong></p>
<blockquote>
<div><p>Time in seconds after which to raise a gen.TimeoutError</p>
</div></blockquote>
</td>
</tr>
<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first last">Named tuple of completed, not completed</p>
</td>
</tr>
</tbody>
</table>
</dd></dl>
<dl class="function">
<dt id="distributed.worker_client">
<code class="descclassname">distributed.</code><code class="descname">worker_client</code><span class="sig-paren">(</span><em>timeout=3</em>, <em>separate_thread=True</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/distributed/worker_client.html#worker_client"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#distributed.worker_client" title="Permalink to this definition">¶</a></dt>
<dd><p>Get client for this thread</p>
<p>This context manager is intended to be called within functions that we run
on workers. When run as a context manager it delivers a client
<code class="docutils literal"><span class="pre">Client</span></code> object that can submit other tasks directly from that worker.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><p class="first"><strong>timeout: Number</strong></p>
<blockquote>
<div><p>Timeout after which to err</p>
</div></blockquote>
<p><strong>separate_thread: bool, optional</strong></p>
<blockquote class="last">
<div><p>Whether to run this function outside of the normal thread pool
defaults to True</p>
</div></blockquote>
</td>
</tr>
</tbody>
</table>
<div class="admonition seealso">
<p class="first admonition-title">See also</p>
<p class="last"><a class="reference internal" href="#distributed.get_worker" title="distributed.get_worker"><code class="xref py py-obj docutils literal"><span class="pre">get_worker</span></code></a>, <a class="reference internal" href="#distributed.get_client" title="distributed.get_client"><code class="xref py py-obj docutils literal"><span class="pre">get_client</span></code></a>, <a class="reference internal" href="#distributed.secede" title="distributed.secede"><code class="xref py py-obj docutils literal"><span class="pre">secede</span></code></a></p>
</div>
<p class="rubric">Examples</p>
<div class="highlight-default"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="k">def</span> <span class="nf">func</span><span class="p">(</span><span class="n">x</span><span class="p">):</span>
<span class="gp">... </span> <span class="k">with</span> <span class="n">worker_client</span><span class="p">()</span> <span class="k">as</span> <span class="n">c</span><span class="p">:</span> <span class="c1"># connect from worker back to scheduler</span>
<span class="gp">... </span> <span class="n">a</span> <span class="o">=</span> <span class="n">c</span><span class="o">.</span><span class="n">submit</span><span class="p">(</span><span class="n">inc</span><span class="p">,</span> <span class="n">x</span><span class="p">)</span> <span class="c1"># this task can submit more tasks</span>
<span class="gp">... </span> <span class="n">b</span> <span class="o">=</span> <span class="n">c</span><span class="o">.</span><span class="n">submit</span><span class="p">(</span><span class="n">dec</span><span class="p">,</span> <span class="n">x</span><span class="p">)</span>
<span class="gp">... </span> <span class="n">result</span> <span class="o">=</span> <span class="n">c</span><span class="o">.</span><span class="n">gather</span><span class="p">([</span><span class="n">a</span><span class="p">,</span> <span class="n">b</span><span class="p">])</span> <span class="c1"># and gather results</span>
<span class="gp">... </span> <span class="k">return</span> <span class="n">result</span>
</pre></div>
</div>
<div class="highlight-default"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">future</span> <span class="o">=</span> <span class="n">client</span><span class="o">.</span><span class="n">submit</span><span class="p">(</span><span class="n">func</span><span class="p">,</span> <span class="mi">1</span><span class="p">)</span> <span class="c1"># submit func(1) on cluster</span>
</pre></div>
</div>
</dd></dl>
<dl class="function">
<dt id="distributed.get_worker">
<code class="descclassname">distributed.</code><code class="descname">get_worker</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference internal" href="_modules/distributed/worker.html#get_worker"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#distributed.get_worker" title="Permalink to this definition">¶</a></dt>
<dd><p>Get the worker currently running this task</p>
<div class="admonition seealso">
<p class="first admonition-title">See also</p>
<p class="last"><a class="reference internal" href="#distributed.get_client" title="distributed.get_client"><code class="xref py py-obj docutils literal"><span class="pre">get_client</span></code></a>, <a class="reference internal" href="#distributed.worker_client" title="distributed.worker_client"><code class="xref py py-obj docutils literal"><span class="pre">worker_client</span></code></a></p>
</div>
<p class="rubric">Examples</p>
<div class="highlight-default"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="k">def</span> <span class="nf">f</span><span class="p">():</span>
<span class="gp">... </span> <span class="n">worker</span> <span class="o">=</span> <span class="n">get_worker</span><span class="p">()</span> <span class="c1"># The worker on which this task is running</span>
<span class="gp">... </span> <span class="k">return</span> <span class="n">worker</span><span class="o">.</span><span class="n">address</span>
</pre></div>
</div>
<div class="highlight-default"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">future</span> <span class="o">=</span> <span class="n">client</span><span class="o">.</span><span class="n">submit</span><span class="p">(</span><span class="n">f</span><span class="p">)</span>
<span class="gp">>>> </span><span class="n">future</span><span class="o">.</span><span class="n">result</span><span class="p">()</span>
<span class="go">'tcp://127.0.0.1:47373'</span>
</pre></div>
</div>
</dd></dl>
<dl class="function">
<dt id="distributed.get_client">
<code class="descclassname">distributed.</code><code class="descname">get_client</code><span class="sig-paren">(</span><em>address=None</em>, <em>timeout=3</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/distributed/worker.html#get_client"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#distributed.get_client" title="Permalink to this definition">¶</a></dt>
<dd><p>Get a client while within a task</p>
<p>This client connects to the same scheduler to which the worker is connected</p>
<div class="admonition seealso">
<p class="first admonition-title">See also</p>
<p class="last"><a class="reference internal" href="#distributed.get_worker" title="distributed.get_worker"><code class="xref py py-obj docutils literal"><span class="pre">get_worker</span></code></a>, <a class="reference internal" href="#distributed.worker_client" title="distributed.worker_client"><code class="xref py py-obj docutils literal"><span class="pre">worker_client</span></code></a>, <a class="reference internal" href="#distributed.secede" title="distributed.secede"><code class="xref py py-obj docutils literal"><span class="pre">secede</span></code></a></p>
</div>
<p class="rubric">Examples</p>
<div class="highlight-default"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="k">def</span> <span class="nf">f</span><span class="p">():</span>
<span class="gp">... </span> <span class="n">client</span> <span class="o">=</span> <span class="n">get_client</span><span class="p">()</span>
<span class="gp">... </span> <span class="n">futures</span> <span class="o">=</span> <span class="n">client</span><span class="o">.</span><span class="n">map</span><span class="p">(</span><span class="k">lambda</span> <span class="n">x</span><span class="p">:</span> <span class="n">x</span> <span class="o">+</span> <span class="mi">1</span><span class="p">,</span> <span class="nb">range</span><span class="p">(</span><span class="mi">10</span><span class="p">))</span> <span class="c1"># spawn many tasks</span>
<span class="gp">... </span> <span class="n">results</span> <span class="o">=</span> <span class="n">client</span><span class="o">.</span><span class="n">gather</span><span class="p">(</span><span class="n">futures</span><span class="p">)</span>
<span class="gp">... </span> <span class="k">return</span> <span class="nb">sum</span><span class="p">(</span><span class="n">results</span><span class="p">)</span>
</pre></div>
</div>
<div class="highlight-default"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">future</span> <span class="o">=</span> <span class="n">client</span><span class="o">.</span><span class="n">submit</span><span class="p">(</span><span class="n">f</span><span class="p">)</span>
<span class="gp">>>> </span><span class="n">future</span><span class="o">.</span><span class="n">result</span><span class="p">()</span>
<span class="go">55</span>
</pre></div>
</div>
</dd></dl>
<dl class="function">
<dt id="distributed.secede">
<code class="descclassname">distributed.</code><code class="descname">secede</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference internal" href="_modules/distributed/worker.html#secede"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#distributed.secede" title="Permalink to this definition">¶</a></dt>
<dd><p>Have this task secede from the worker’s thread pool</p>
<p>This opens up a new scheduling slot and a new thread for a new task. This
enables the client to schedule tasks on this node, which is
especially useful while waiting for other jobs to finish (e.g., with
<code class="docutils literal"><span class="pre">client.gather</span></code>).</p>
<div class="admonition seealso">
<p class="first admonition-title">See also</p>
<p class="last"><a class="reference internal" href="#distributed.get_client" title="distributed.get_client"><code class="xref py py-obj docutils literal"><span class="pre">get_client</span></code></a>, <a class="reference internal" href="#distributed.get_worker" title="distributed.get_worker"><code class="xref py py-obj docutils literal"><span class="pre">get_worker</span></code></a></p>
</div>
<p class="rubric">Examples</p>
<div class="highlight-default"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="k">def</span> <span class="nf">mytask</span><span class="p">(</span><span class="n">x</span><span class="p">):</span>
<span class="gp">... </span> <span class="c1"># do some work</span>
<span class="gp">... </span> <span class="n">client</span> <span class="o">=</span> <span class="n">get_client</span><span class="p">()</span>
<span class="gp">... </span> <span class="n">futures</span> <span class="o">=</span> <span class="n">client</span><span class="o">.</span><span class="n">map</span><span class="p">(</span><span class="o">...</span><span class="p">)</span> <span class="c1"># do some remote work</span>
<span class="gp">... </span> <span class="n">secede</span><span class="p">()</span> <span class="c1"># while that work happens, remove ourself from the pool</span>
<span class="gp">... </span> <span class="k">return</span> <span class="n">client</span><span class="o">.</span><span class="n">gather</span><span class="p">(</span><span class="n">futures</span><span class="p">)</span> <span class="c1"># return gathered results</span>
</pre></div>
</div>
</dd></dl>
<dl class="function">
<dt id="distributed.rejoin">
<code class="descclassname">distributed.</code><code class="descname">rejoin</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference internal" href="_modules/distributed/threadpoolexecutor.html#rejoin"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#distributed.rejoin" title="Permalink to this definition">¶</a></dt>
<dd><p>Have this thread rejoin the ThreadPoolExecutor</p>
<p>This will block until a new slot opens up in the executor. The next thread
to finish a task will leave the pool to allow this one to join.</p>
<div class="admonition seealso">
<p class="first admonition-title">See also</p>
<dl class="last docutils">
<dt><a class="reference internal" href="#distributed.secede" title="distributed.secede"><code class="xref py py-obj docutils literal"><span class="pre">secede</span></code></a></dt>
<dd>leave the thread pool</dd>
</dl>
</div>
</dd></dl>
<dl class="class">
<dt id="distributed.Queue">
<em class="property">class </em><code class="descclassname">distributed.</code><code class="descname">Queue</code><span class="sig-paren">(</span><em>name=None</em>, <em>client=None</em>, <em>maxsize=0</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/distributed/queues.html#Queue"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#distributed.Queue" title="Permalink to this definition">¶</a></dt>
<dd><p>Distributed Queue</p>
<p>This allows multiple clients to share futures or small bits of data between
each other with a multi-producer/multi-consumer queue. All metadata is
sequentialized through the scheduler.</p>
<p>Elements of the Queue must be either Futures or msgpack-encodable data
(ints, strings, lists, dicts). All data is sent through the scheduler so
it is wise not to send large objects. To share large objects scatter the
data and share the future instead.</p>
<div class="admonition warning">
<p class="first admonition-title">Warning</p>
<p class="last">This object is experimental and has known issues in Python 2</p>
</div>
<div class="admonition seealso">
<p class="first admonition-title">See also</p>
<dl class="last docutils">
<dt><a class="reference internal" href="#distributed.Variable" title="distributed.Variable"><code class="xref py py-obj docutils literal"><span class="pre">Variable</span></code></a></dt>
<dd>shared variable between clients</dd>
</dl>
</div>
<p class="rubric">Examples</p>
<div class="highlight-default"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="kn">from</span> <span class="nn">dask.distributed</span> <span class="k">import</span> <span class="n">Client</span><span class="p">,</span> <span class="n">Queue</span>
<span class="gp">>>> </span><span class="n">client</span> <span class="o">=</span> <span class="n">Client</span><span class="p">()</span>
<span class="gp">>>> </span><span class="n">queue</span> <span class="o">=</span> <span class="n">Queue</span><span class="p">(</span><span class="s1">'x'</span><span class="p">)</span>
<span class="gp">>>> </span><span class="n">future</span> <span class="o">=</span> <span class="n">client</span><span class="o">.</span><span class="n">submit</span><span class="p">(</span><span class="n">f</span><span class="p">,</span> <span class="n">x</span><span class="p">)</span>
<span class="gp">>>> </span><span class="n">queue</span><span class="o">.</span><span class="n">put</span><span class="p">(</span><span class="n">future</span><span class="p">)</span>
</pre></div>
</div>
<dl class="method">
<dt id="distributed.Queue.get">
<code class="descname">get</code><span class="sig-paren">(</span><em>timeout=None</em>, <em>batch=False</em>, <em>**kwargs</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/distributed/queues.html#Queue.get"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#distributed.Queue.get" title="Permalink to this definition">¶</a></dt>
<dd><p>Get data from the queue</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><p class="first"><strong>timeout: Number (optional)</strong></p>
<blockquote>
<div><p>Time in seconds to wait before timing out</p>
</div></blockquote>
<p><strong>batch: boolean, int (optional)</strong></p>
<blockquote class="last">
<div><p>If True then return all elements currently waiting in the queue.
If an integer than return that many elements from the queue
If False (default) then return one item at a time</p>
</div></blockquote>
</td>
</tr>
</tbody>
</table>
</dd></dl>
<dl class="method">
<dt id="distributed.Queue.put">
<code class="descname">put</code><span class="sig-paren">(</span><em>value</em>, <em>timeout=None</em>, <em>**kwargs</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/distributed/queues.html#Queue.put"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#distributed.Queue.put" title="Permalink to this definition">¶</a></dt>
<dd><p>Put data into the queue</p>
</dd></dl>
<dl class="method">
<dt id="distributed.Queue.qsize">
<code class="descname">qsize</code><span class="sig-paren">(</span><em>**kwargs</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/distributed/queues.html#Queue.qsize"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#distributed.Queue.qsize" title="Permalink to this definition">¶</a></dt>
<dd><p>Current number of elements in the queue</p>
</dd></dl>
</dd></dl>
<dl class="class">
<dt id="distributed.Variable">
<em class="property">class </em><code class="descclassname">distributed.</code><code class="descname">Variable</code><span class="sig-paren">(</span><em>name=None</em>, <em>client=None</em>, <em>maxsize=0</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/distributed/variable.html#Variable"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#distributed.Variable" title="Permalink to this definition">¶</a></dt>
<dd><p>Distributed Global Variable</p>
<p>This allows multiple clients to share futures and data between each other
with a single mutable variable. All metadata is sequentialized through the
scheduler. Race conditions can occur.</p>
<p>Values must be either Futures or msgpack-encodable data (ints, lists,
strings, etc..) All data will be kept and sent through the scheduler, so
it is wise not to send too much. If you want to share a large amount of
data then <code class="docutils literal"><span class="pre">scatter</span></code> it and share the future instead.</p>
<div class="admonition warning">
<p class="first admonition-title">Warning</p>
<p class="last">This object is experimental and has known issues in Python 2</p>
</div>
<div class="admonition seealso">
<p class="first admonition-title">See also</p>
<dl class="last docutils">
<dt><a class="reference internal" href="#distributed.Queue" title="distributed.Queue"><code class="xref py py-obj docutils literal"><span class="pre">Queue</span></code></a></dt>
<dd>shared multi-producer/multi-consumer queue between clients</dd>
</dl>
</div>
<p class="rubric">Examples</p>
<div class="highlight-default"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="kn">from</span> <span class="nn">dask.distributed</span> <span class="k">import</span> <span class="n">Client</span><span class="p">,</span> <span class="n">Variable</span>
<span class="gp">>>> </span><span class="n">client</span> <span class="o">=</span> <span class="n">Client</span><span class="p">()</span>
<span class="gp">>>> </span><span class="n">x</span> <span class="o">=</span> <span class="n">Variable</span><span class="p">(</span><span class="s1">'x'</span><span class="p">)</span>
<span class="gp">>>> </span><span class="n">x</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="mi">123</span><span class="p">)</span> <span class="c1"># docttest: +SKIP</span>
<span class="gp">>>> </span><span class="n">x</span><span class="o">.</span><span class="n">get</span><span class="p">()</span> <span class="c1"># docttest: +SKIP</span>
<span class="go">123</span>
<span class="gp">>>> </span><span class="n">future</span> <span class="o">=</span> <span class="n">client</span><span class="o">.</span><span class="n">submit</span><span class="p">(</span><span class="n">f</span><span class="p">,</span> <span class="n">x</span><span class="p">)</span>
<span class="gp">>>> </span><span class="n">x</span><span class="o">.</span><span class="n">set</span><span class="p">(</span><span class="n">future</span><span class="p">)</span>
</pre></div>
</div>
<dl class="method">
<dt id="distributed.Variable.delete">
<code class="descname">delete</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference internal" href="_modules/distributed/variable.html#Variable.delete"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#distributed.Variable.delete" title="Permalink to this definition">¶</a></dt>
<dd><p>Delete this variable</p>
<p>Caution, this affects all clients currently pointing to this variable.</p>
</dd></dl>
<dl class="method">
<dt id="distributed.Variable.get">
<code class="descname">get</code><span class="sig-paren">(</span><em>timeout=None</em>, <em>**kwargs</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/distributed/variable.html#Variable.get"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#distributed.Variable.get" title="Permalink to this definition">¶</a></dt>
<dd><p>Get the value of this variable</p>
</dd></dl>
<dl class="method">
<dt id="distributed.Variable.set">
<code class="descname">set</code><span class="sig-paren">(</span><em>value</em>, <em>**kwargs</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/distributed/variable.html#Variable.set"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#distributed.Variable.set" title="Permalink to this definition">¶</a></dt>
<dd><p>Set the value of this variable</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><p class="first"><strong>value: Future or object</strong></p>
<blockquote class="last">
<div><p>Must be either a Future or a msgpack-encodable value</p>
</div></blockquote>
</td>
</tr>
</tbody>
</table>
</dd></dl>
</dd></dl>
</div>
<div class="section" id="asyncio-client">
<h2>Asyncio Client<a class="headerlink" href="#asyncio-client" title="Permalink to this headline">¶</a></h2>
<dl class="class">
<dt id="distributed.asyncio.AioClient">
<em class="property">class </em><code class="descclassname">distributed.asyncio.</code><code class="descname">AioClient</code><span class="sig-paren">(</span><em>*args</em>, <em>**kwargs</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/distributed/asyncio.html#AioClient"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#distributed.asyncio.AioClient" title="Permalink to this definition">¶</a></dt>
<dd><p>Connect to and drive computation on a distributed Dask cluster</p>
<p>This class provides an asyncio compatible async/await interface for
dask.distributed.</p>
<p>The Client connects users to a dask.distributed compute cluster. It
provides an asynchronous user interface around functions and futures.
This class resembles executors in <code class="docutils literal"><span class="pre">concurrent.futures</span></code> but also
allows <code class="docutils literal"><span class="pre">Future</span></code> objects within <code class="docutils literal"><span class="pre">submit/map</span></code> calls.</p>
<p>AioClient is an <strong>experimental</strong> interface for distributed and may
disappear without warning!</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><p class="first"><strong>address: string, or Cluster</strong></p>
<blockquote class="last">
<div><p>This can be the address of a <code class="docutils literal"><span class="pre">Scheduler</span></code> server like a string
<code class="docutils literal"><span class="pre">'127.0.0.1:8786'</span></code> or a cluster object like <code class="docutils literal"><span class="pre">LocalCluster()</span></code></p>
</div></blockquote>
</td>
</tr>
</tbody>
</table>
<div class="admonition seealso">
<p class="first admonition-title">See also</p>
<dl class="last docutils">
<dt><a class="reference internal" href="#distributed.client.Client" title="distributed.client.Client"><code class="xref py py-obj docutils literal"><span class="pre">distributed.client.Client</span></code></a></dt>
<dd>Blocking Client</dd>
<dt><a class="reference internal" href="scheduling-state.html#distributed.scheduler.Scheduler" title="distributed.scheduler.Scheduler"><code class="xref py py-obj docutils literal"><span class="pre">distributed.scheduler.Scheduler</span></code></a></dt>
<dd>Internal scheduler</dd>
</dl>
</div>
<p class="rubric">Examples</p>
<p>Provide cluster’s scheduler address on initialization:</p>
<div class="highlight-default"><div class="highlight"><pre><span></span><span class="n">client</span> <span class="o">=</span> <span class="n">AioClient</span><span class="p">(</span><span class="s1">'127.0.0.1:8786'</span><span class="p">)</span>
</pre></div>
</div>
<p>Start the client:</p>
<div class="highlight-default"><div class="highlight"><pre><span></span><span class="k">async</span> <span class="k">def</span> <span class="nf">start_the_client</span><span class="p">():</span>
<span class="n">client</span> <span class="o">=</span> <span class="k">await</span> <span class="n">AioClient</span><span class="p">()</span>
<span class="c1"># Use the client....</span>
<span class="k">await</span> <span class="n">client</span><span class="o">.</span><span class="n">close</span><span class="p">()</span>
</pre></div>
</div>
<p>An <code class="docutils literal"><span class="pre">async</span> <span class="pre">with</span></code> statement is a more convenient way to start and shut down
the client:</p>
<div class="highlight-default"><div class="highlight"><pre><span></span><span class="k">async</span> <span class="k">def</span> <span class="nf">start_the_client</span><span class="p">():</span>
<span class="k">async</span> <span class="k">with</span> <span class="n">AioClient</span><span class="p">()</span> <span class="k">as</span> <span class="n">client</span><span class="p">:</span>
<span class="c1"># Use the client within this block.</span>
<span class="k">pass</span>
</pre></div>
</div>
<p>Use the <code class="docutils literal"><span class="pre">submit</span></code> method to send individual computations to the cluster,
and await the returned future to retrieve the result:</p>
<div class="highlight-default"><div class="highlight"><pre><span></span><span class="k">async</span> <span class="k">def</span> <span class="nf">add_two_numbers</span><span class="p">():</span>
<span class="k">async</span> <span class="k">with</span> <span class="n">AioClient</span><span class="p">()</span> <span class="k">as</span> <span class="n">client</span><span class="p">:</span>
<span class="n">a</span> <span class="o">=</span> <span class="n">client</span><span class="o">.</span><span class="n">submit</span><span class="p">(</span><span class="n">add</span><span class="p">,</span> <span class="mi">1</span><span class="p">,</span> <span class="mi">2</span><span class="p">)</span>
<span class="n">result</span> <span class="o">=</span> <span class="k">await</span> <span class="n">a</span>
</pre></div>
</div>
<p>Continue using submit or map on results to build up larger computations,
and gather results with the <code class="docutils literal"><span class="pre">gather</span></code> method:</p>
<div class="highlight-default"><div class="highlight"><pre><span></span><span class="k">async</span> <span class="k">def</span> <span class="nf">gather_some_results</span><span class="p">():</span>
<span class="k">async</span> <span class="k">with</span> <span class="n">AioClient</span><span class="p">()</span> <span class="k">as</span> <span class="n">client</span><span class="p">:</span>
<span class="n">a</span> <span class="o">=</span> <span class="n">client</span><span class="o">.</span><span class="n">submit</span><span class="p">(</span><span class="n">add</span><span class="p">,</span> <span class="mi">1</span><span class="p">,</span> <span class="mi">2</span><span class="p">)</span>
<span class="n">b</span> <span class="o">=</span> <span class="n">client</span><span class="o">.</span><span class="n">submit</span><span class="p">(</span><span class="n">add</span><span class="p">,</span> <span class="mi">10</span><span class="p">,</span> <span class="mi">20</span><span class="p">)</span>
<span class="n">c</span> <span class="o">=</span> <span class="n">client</span><span class="o">.</span><span class="n">submit</span><span class="p">(</span><span class="n">add</span><span class="p">,</span> <span class="n">a</span><span class="p">,</span> <span class="n">b</span><span class="p">)</span>
<span class="n">result</span> <span class="o">=</span> <span class="k">await</span> <span class="n">client</span><span class="o">.</span><span class="n">gather</span><span class="p">([</span><span class="n">c</span><span class="p">])</span>
</pre></div>
</div>
<dl class="method">
<dt id="distributed.asyncio.AioClient.close">
<code class="descname">close</code><span class="sig-paren">(</span><em>timeout=10</em><span class="sig-paren">)</span><a class="headerlink" href="#distributed.asyncio.AioClient.close" title="Permalink to this definition">¶</a></dt>
<dd><p>Close this client</p>
<p>Clients will also close automatically when your Python session ends</p>
<p>If you started a client without arguments like <code class="docutils literal"><span class="pre">Client()</span></code> then this
will also close the local cluster that was started at the same time.</p>
<div class="admonition seealso">
<p class="first admonition-title">See also</p>
<p class="last"><code class="xref py py-obj docutils literal"><span class="pre">Client.restart</span></code></p>
</div>
</dd></dl>
<dl class="method">
<dt id="distributed.asyncio.AioClient.get">
<code class="descname">get</code><span class="sig-paren">(</span><em>dsk</em>, <em>keys</em>, <em>restrictions=None</em>, <em>loose_restrictions=None</em>, <em>resources=None</em>, <em>sync=True</em>, <em>asynchronous=None</em>, <em>**kwargs</em><span class="sig-paren">)</span><a class="headerlink" href="#distributed.asyncio.AioClient.get" title="Permalink to this definition">¶</a></dt>
<dd><p>Compute dask graph</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><p class="first"><strong>dsk: dict</strong></p>
<p><strong>keys: object, or nested lists of objects</strong></p>
<p><strong>restrictions: dict (optional)</strong></p>
<blockquote>
<div><p>A mapping of {key: {set of worker hostnames}} that restricts where
jobs can take place</p>
</div></blockquote>
<p><strong>sync: bool (optional)</strong></p>
<blockquote class="last">
<div><p>Returns Futures if False or concrete values if True (default).</p>
</div></blockquote>
</td>
</tr>
</tbody>
</table>
<div class="admonition seealso">
<p class="first admonition-title">See also</p>
<dl class="last docutils">
<dt><code class="xref py py-obj docutils literal"><span class="pre">Client.compute</span></code></dt>
<dd>Compute asynchronous collections</dd>
</dl>
</div>
<p class="rubric">Examples</p>
<div class="highlight-default"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="kn">from</span> <span class="nn">operator</span> <span class="k">import</span> <span class="n">add</span>
<span class="gp">>>> </span><span class="n">c</span> <span class="o">=</span> <span class="n">Client</span><span class="p">(</span><span class="s1">'127.0.0.1:8787'</span><span class="p">)</span>
<span class="gp">>>> </span><span class="n">c</span><span class="o">.</span><span class="n">get</span><span class="p">({</span><span class="s1">'x'</span><span class="p">:</span> <span class="p">(</span><span class="n">add</span><span class="p">,</span> <span class="mi">1</span><span class="p">,</span> <span class="mi">2</span><span class="p">)},</span> <span class="s1">'x'</span><span class="p">)</span>
<span class="go">3</span>
</pre></div>
</div>
</dd></dl>
<dl class="method">
<dt id="distributed.asyncio.AioClient.shutdown">
<code class="descname">shutdown</code><span class="sig-paren">(</span><em>timeout=10</em><span class="sig-paren">)</span><a class="headerlink" href="#distributed.asyncio.AioClient.shutdown" title="Permalink to this definition">¶</a></dt>
<dd><p>Close this client</p>
<p>Clients will also close automatically when your Python session ends</p>
<p>If you started a client without arguments like <code class="docutils literal"><span class="pre">Client()</span></code> then this
will also close the local cluster that was started at the same time.</p>
<div class="admonition seealso">
<p class="first admonition-title">See also</p>
<p class="last"><code class="xref py py-obj docutils literal"><span class="pre">Client.restart</span></code></p>
</div>
</dd></dl>
</dd></dl>
</div>
<div class="section" id="adaptive">
<h2>Adaptive<a class="headerlink" href="#adaptive" title="Permalink to this headline">¶</a></h2>
<dl class="class">
<dt id="distributed.deploy.Adaptive">
<em class="property">class </em><code class="descclassname">distributed.deploy.</code><code class="descname">Adaptive</code><span class="sig-paren">(</span><em>scheduler</em>, <em>cluster</em>, <em>interval=1000</em>, <em>startup_cost=1</em>, <em>scale_factor=2</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/distributed/deploy/adaptive.html#Adaptive"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#distributed.deploy.Adaptive" title="Permalink to this definition">¶</a></dt>
<dd><p>Adaptively allocate workers based on scheduler load. A superclass.</p>
<p>Contains logic to dynamically resize a Dask cluster based on current use.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><p class="first"><strong>scheduler: distributed.Scheduler</strong></p>
<p><strong>cluster: object</strong></p>
<blockquote>
<div><p>Must have scale_up and scale_down methods/coroutines</p>
</div></blockquote>
<p><strong>startup_cost</strong> : int, default 1</p>
<blockquote>
<div><p>Factor representing how costly it is to start an additional worker.
Affects quickly to adapt to high tasks per worker loads</p>
</div></blockquote>
<p><strong>scale_factor</strong> : int, default 2</p>
<blockquote class="last">
<div><p>Factor to scale by when it’s determined additional workers are needed</p>
</div></blockquote>
</td>
</tr>
</tbody>
</table>
<p class="rubric">Notes</p>
<p>Subclasses can override <a class="reference internal" href="#distributed.deploy.Adaptive.should_scale_up" title="distributed.deploy.Adaptive.should_scale_up"><code class="xref py py-meth docutils literal"><span class="pre">Adaptive.should_scale_up()</span></code></a> and
<a class="reference internal" href="#distributed.deploy.Adaptive.should_scale_down" title="distributed.deploy.Adaptive.should_scale_down"><code class="xref py py-meth docutils literal"><span class="pre">Adaptive.should_scale_down()</span></code></a> to control when the cluster should be
resized. The default implementation checks if there are too many tasks
per worker or too little memory available (see <a class="reference internal" href="#distributed.deploy.Adaptive.needs_cpu" title="distributed.deploy.Adaptive.needs_cpu"><code class="xref py py-meth docutils literal"><span class="pre">Adaptive.needs_cpu()</span></code></a>
and <a class="reference internal" href="#distributed.deploy.Adaptive.needs_memory" title="distributed.deploy.Adaptive.needs_memory"><code class="xref py py-meth docutils literal"><span class="pre">Adaptive.needs_memory()</span></code></a>).</p>
<p><a class="reference internal" href="#distributed.deploy.Adaptive.get_scale_up_kwargs" title="distributed.deploy.Adaptive.get_scale_up_kwargs"><code class="xref py py-meth docutils literal"><span class="pre">Adaptive.get_scale_up_kwargs()</span></code></a> method controls the arguments passed to
the cluster’s <code class="docutils literal"><span class="pre">scale_up</span></code> method.</p>
<p class="rubric">Examples</p>
<div class="highlight-default"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="k">class</span> <span class="nc">MyCluster</span><span class="p">(</span><span class="nb">object</span><span class="p">):</span>
<span class="gp">... </span> <span class="k">def</span> <span class="nf">scale_up</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">n</span><span class="p">):</span>
<span class="gp">... </span> <span class="sd">""" Bring worker count up to n """</span>
<span class="gp">... </span> <span class="k">def</span> <span class="nf">scale_down</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">workers</span><span class="p">):</span>
<span class="gp">... </span> <span class="sd">""" Remove worker addresses from cluster """</span>
</pre></div>
</div>
<dl class="method">
<dt id="distributed.deploy.Adaptive.get_scale_up_kwargs">
<code class="descname">get_scale_up_kwargs</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference internal" href="_modules/distributed/deploy/adaptive.html#Adaptive.get_scale_up_kwargs"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#distributed.deploy.Adaptive.get_scale_up_kwargs" title="Permalink to this definition">¶</a></dt>
<dd><p>Get the arguments to be passed to <code class="docutils literal"><span class="pre">self.cluster.scale_up</span></code>.</p>
<div class="admonition seealso">
<p class="first admonition-title">See also</p>
<p class="last"><code class="xref py py-obj docutils literal"><span class="pre">LocalCluster.scale_up</span></code></p>
</div>
<p class="rubric">Notes</p>
<p>By default the desired number of total workers is returned (<code class="docutils literal"><span class="pre">n</span></code>).
Subclasses should ensure that the return dictionary includes a key-
value pair for <code class="docutils literal"><span class="pre">n</span></code>, either by implementing it or by calling the
parent’s <code class="docutils literal"><span class="pre">get_scale_up_kwargs</span></code>.</p>
</dd></dl>
<dl class="method">
<dt id="distributed.deploy.Adaptive.needs_cpu">
<code class="descname">needs_cpu</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference internal" href="_modules/distributed/deploy/adaptive.html#Adaptive.needs_cpu"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#distributed.deploy.Adaptive.needs_cpu" title="Permalink to this definition">¶</a></dt>
<dd><p>Check if the cluster is CPU constrained (too many tasks per core)</p>
<p class="rubric">Notes</p>
<p>Returns <code class="docutils literal"><span class="pre">True</span></code> if the occupancy per core is some factor larger
than <code class="docutils literal"><span class="pre">startup_cost</span></code>.</p>
</dd></dl>
<dl class="method">
<dt id="distributed.deploy.Adaptive.needs_memory">
<code class="descname">needs_memory</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference internal" href="_modules/distributed/deploy/adaptive.html#Adaptive.needs_memory"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#distributed.deploy.Adaptive.needs_memory" title="Permalink to this definition">¶</a></dt>
<dd><p>Check if the cluster is RAM constrained</p>
<p class="rubric">Notes</p>
<p>Returns <code class="docutils literal"><span class="pre">True</span></code> if the required bytes in distributed memory is some
factor larger than the actual distributed memory available.</p>
</dd></dl>
<dl class="method">
<dt id="distributed.deploy.Adaptive.should_scale_down">
<code class="descname">should_scale_down</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference internal" href="_modules/distributed/deploy/adaptive.html#Adaptive.should_scale_down"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#distributed.deploy.Adaptive.should_scale_down" title="Permalink to this definition">¶</a></dt>
<dd><p>Determine whether any workers should potentially be removed from
the cluster.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Returns:</th><td class="field-body"><strong>scale_down</strong> : bool</td>
</tr>
</tbody>
</table>
<div class="admonition seealso">
<p class="first admonition-title">See also</p>
<p class="last"><code class="xref py py-obj docutils literal"><span class="pre">Scheduler.workers_to_close</span></code></p>
</div>
<p class="rubric">Notes</p>
<p><code class="docutils literal"><span class="pre">Adaptive.should_scale_down</span></code> always returns True, so we will always
attempt to remove workers as determined by
<code class="docutils literal"><span class="pre">Scheduler.workers_to_close</span></code>.</p>
</dd></dl>
<dl class="method">
<dt id="distributed.deploy.Adaptive.should_scale_up">
<code class="descname">should_scale_up</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference internal" href="_modules/distributed/deploy/adaptive.html#Adaptive.should_scale_up"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#distributed.deploy.Adaptive.should_scale_up" title="Permalink to this definition">¶</a></dt>
<dd><p>Determine whether additional workers should be added to the cluster</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Returns:</th><td class="field-body"><p class="first"><strong>scale_up</strong> : bool</p>
<p>Notes</p>
<p>Additional workers are added whenever</p>
<ol class="last arabic simple">
<li>There are unrunnable tasks and no workers</li>
<li>The cluster is CPU constrained</li>
<li>The cluster is RAM constrained</li>
</ol>
</td>
</tr>
</tbody>
</table>
<div class="admonition seealso">
<p class="first admonition-title">See also</p>
<p class="last"><a class="reference internal" href="#distributed.deploy.Adaptive.needs_cpu" title="distributed.deploy.Adaptive.needs_cpu"><code class="xref py py-obj docutils literal"><span class="pre">needs_cpu</span></code></a>, <a class="reference internal" href="#distributed.deploy.Adaptive.needs_memory" title="distributed.deploy.Adaptive.needs_memory"><code class="xref py py-obj docutils literal"><span class="pre">needs_memory</span></code></a></p>
</div>
</dd></dl>
</dd></dl>
</div>
</div>
</div>
<div class="articleComments">
</div>
</div>
<footer>
<div class="rst-footer-buttons" role="navigation" aria-label="footer navigation">
<a href="faq.html" class="btn btn-neutral float-right" title="Frequently Asked Questions" accesskey="n" rel="next">Next <span class="fa fa-arrow-circle-right"></span></a>
<a href="client.html" class="btn btn-neutral" title="Client" accesskey="p" rel="prev"><span class="fa fa-arrow-circle-left"></span> Previous</a>
</div>
<hr/>
<div role="contentinfo">
<p>
© Copyright 2017, Anaconda, Inc..
</p>
</div>
Built with <a href="http://sphinx-doc.org/">Sphinx</a> using a <a href="https://github.com/snide/sphinx_rtd_theme">theme</a> provided by <a href="https://readthedocs.org">Read the Docs</a>.
</footer>
</div>
</div>
</section>
</div>
<script type="text/javascript">
var DOCUMENTATION_OPTIONS = {
URL_ROOT:'./',
VERSION:'0+unknown',
COLLAPSE_INDEX:false,
FILE_SUFFIX:'.html',
HAS_SOURCE: true,
SOURCELINK_SUFFIX: '.txt'
};
</script>
<script type="text/javascript" src="_static/jquery.js"></script>
<script type="text/javascript" src="_static/underscore.js"></script>
<script type="text/javascript" src="_static/doctools.js"></script>
<script type="text/javascript" src="_static/js/theme.js"></script>
<script type="text/javascript">
jQuery(function () {
SphinxRtdTheme.StickyNav.enable();
});
</script>
</body>
</html>
|