Is there any sort of built-in support for task arg...
# prefect-community
b
Is there any sort of built-in support for task arguments that can be either a
Result
instance or a raw value? The functionality I’m looking for is basically this:
Copy code
@task
def foo(bar):
    if isinstance(bar, Result):
        bar = bar.read(bar.location).value
    return do_something(bar)
Clearly the above isn’t hard to add, but it also seems like the kind of thing where (a) there might be hidden gotchas and (b) it seems common enough that
prefect
might have something built in
d
Hey @Ben Fogelson! Can you tell me a little more about what you’re hoping to achieve? Prefect does some of the
Result
unpacking for you under the hood. Are you trying to explicitly pass a
Result
class?
b
Hey @Dylan, yeah this is what I’m actually trying to do. Say we have two flows: Flow A has a task that produces a large dataframe that we store in google cloud (with the
GCSResult
class). Flow B has a parameter that it expects to be a dataframe. It would be nice if the parameter for Flow B could be either a raw dataframe or some pointer to the location in gcs that prefect automatically unpacks into a dataframe
Or put it another way: it would be nice if the team developing Flow B could write their code just expecting a dataframe and not care whether we instead pass them a reference to the previous result in gcs
d
Got it
🧐
b
Hey @Dylan, wondering if you were able to find anything out here. Thanks!
d
Hey @Ben Fogelson, we don’t have anything like this at the moment
However, I think it’s an interesting feature
Definitely feel free to open a feature request issue on the Prefect Core repo!
b
Thanks Dylan! Will do