hey hey, I'm a bit stumped trying to implement a ...
# prefect-community
b
hey hey, I'm a bit stumped trying to implement a data ingestion pattern in prefect. Is it possible to access task parameter values when templating the result 'target' filename? I'm trying to have my results stored in a directory structure (aka 'hive' dir partitioning). Thanks for any insight
đź‘€ 1
the target path should reflect the task parameters if that makes sense
d
Hey @Bob Colner! That definitely makes sense. I don’t believe it’s possible at this time, but let me double-check with the rest of the team before I say that definitively
b
cool
d
@Bob Colner Great news! You totally can!
The task kwargs are available just like the items in context
b
oh nice, is there an example of how?
d
Something like:
Copy code
@task(target="{param}/file.txt")
def my_task(param):
    pass
Should work on Prefect version 0.12.0 and above
đź‘Ť 1
There is not
I’m going to open a ticket to better document this now
@Marvin open “Better document the fact that task kwargs can be used to template result targets”
b
I'll give this a try.
d
đź‘Ť let us know how it goes!
b
FYI I think this would make a good additional idiom -especially when we can do custom serializers (parquet etc.) common use case (API calls -> dir partitioned csv/parquet
d
That’s a great suggestion
b
speaking of, do you have an idea of when the custom/passthrough serialization will be ready?
d
I’m not sure
Let me see if I can find the issue
@Bob Colner looks like it’s on 0.12.1, so you’re good to go!
b
very cool
so this example in the docs in would work as a 'passthrough'?
Copy code
class MySerializer(prefect.engine.serializers.Serializer):

    def serialize(self, value: Any) -> bytes:
        # transform a Python object into bytes
        pass

    def deserialize(self, value: Union[bytes, str]) -> Any:
        # recover a Python object from bytes
        pass