bit of a philosophical q: why are `Parameter`s req...
# prefect-community
bit of a philosophical q: why are `Parameter`s required to be unique rather than just all receiving the input? I mentioned to @Chris White that I need to duplicate a large part of one flow in multiple places, so I was toying with a pattern like
Copy code
def add(x, y):
    return x + y

def add_to_x(y):
    x = Parameter('x')
    total = task(add)(x, y)

with Flow('flow') as f:
in this case you could just pass in
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? 🤔
Hey @Brett Naul - so you’re expecting that every reference to
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 necessarily
makes sense; right now to test it out I’m just doing
Copy code
class 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 🤯
haha ok nice! Yea, I like your subclass approach because it’s explicit