Skip to content

delayed and docs

Compare
Choose a tag to compare
@Contextualist Contextualist released this 20 Jun 18:46
· 101 commits to master since this release

What's new

Operate on pending results as if they are actual numbers, with the new frontend, Delayed.

@delayed
@subprocify
def f(i): # ith term of arctan(x)'s Taylor series, x=1
    return (1 if i%2==0 else -1) * 1/(2*i+1)

async def pi_approx(): # approximate pi as arctan(1)/4
    pi_4 = 0
    for i in range(1000):
        pi_4 += (f @ Cores(1))(i) # calculate each term on a separate core
    print(await (pi_4 * 4)) # block until the answer is ready.

Delayed comes with tutorial and documentations. Check it out!

Breaking changes

  • grain unreg -> grain quit, and it will wait until all pending calculation on that worker is done. The old, forceful behavior can be used with grain quit -f
  • Most of of the top-level exports are removed (e.g. grain.Cores -> grain.resource.Cores. See f2f75e4). Use their modules instead.
  • Rename: grain.combine.run_combine -> grain.combine.run