Brett Naul
11/11/2019, 4:55 AMdef add(x, y):
return x + y
def add_to_x(y):
x = Parameter('x')
total = task(add)(x, y)
with Flow('flow') as f:
add_to_x(1)
add_to_x(2)
in this case you could just pass in x
to the “factory” function instead, but in practice I have lots of parameters so it feels a bit clumsy. I’m sure there was a good reason for enforcing that parameters be unique; but doesn’t the fact that we’re able to assert that it’s unique mean that we could also just grab a reference to the already-existing task? 🤔Chris White
11/11/2019, 3:50 PMParameter('x')
reference the same underlying parameter? I think there are two reasons we haven’t done this yet:
- whenever a parameter is not required and provides a default value, we’d need to validate that every reference provides the same default
- typically we try to encourage explicit code, and this has the opportunity to surprise people at run time
That being said, I see the benefit in a scenario like this so I’m not against it necessarilyBrett Naul
11/11/2019, 4:23 PMclass GlobalParameter(Parameter):
def __init__(self, name, slug=None, *args, **kwargs):
super().__init__(name=name, *args, **kwargs)
self.slug = slug or uuid.uuid4()
will let you know if anything goes 🤯Chris White
11/11/2019, 4:25 PM