# How do I set Decimal precision on dask distributed?

Hey Guys sorry I’m a bit new to Python as well as dask, but I’d like to get a POC working with the code below.

I think it’s pretty close (feel free to tell me how I can make it better) but I need the result to show the digit defined by the precision variable

Locally, I can just call `getcontext().prec=precision` but how do I set the precision on the remote workers?

Thanks

``````from decimal import Decimal
from decimal import getcontext
from dask.distributed import Client

def fa(k):
return 1/Decimal(16)**k

def fb(k):
return Decimal(4)/(8*k+1)

def fc(k):
return Decimal(2)/(8*k+4)

def fd(k):
return Decimal(1)/(8*k+5)

def fe(k):
return Decimal(1)/(8*k+6)

def fsub(b, c, d, e):
return b - c - d - e

def fmul(a, bcde):
return a * bcde

precision = 100
getcontext().prec=precision
inits = range(precision)
output = []
for x in inits:
a = fa(x)
b = fb(x)
c = fc(x)
d = fd(x)
e = fe(x)
bcde = fsub(b, c, d, e)
mul = fmul(a, bcde)
output.append(mul)

print(total.compute())
``````

Hi @myarbrou-rh,

You need to make Workers aware about the precision you want them to work with.

I give it a quick try, launching:

``````def set_context(precision):
getcontext().prec=precision

client.run(set_context, 2)
``````

before computing any delayed operation works. Maybe you can set the default in other ways with Decimal, I don’t know.