https://prefect.io logo
#prefect-community
Title
# prefect-community
p

Pedro Machado

09/22/2020, 4:04 AM
Is there a way to use the
StringFormatter
task with a template that is read at run time?
c

Chris White

09/22/2020, 4:30 AM
Hi Pedro, yes, the template kwarg is also available as a run method kwarg
p

Pedro Machado

09/22/2020, 4:55 AM
Hi Chris. Thanks for your reply. The template location is a
Parameter
Would I need to have another task that takes the location as an input and returns the contents of the file as a string to pass it to the
StringFormatter
task?
c

Chris White

09/22/2020, 4:56 AM
Yup yup that is correct
p

Pedro Machado

09/22/2020, 4:59 AM
Got it. One more thing ... is there a way to persist the rendered template as plain text using a templated
target
without writing a custom serializer? The rendered template produces SQL and we'd like this to be in plain text format. I wrote a
PlainTextSerializer
class for this but I am wondering if there is a better way. Thanks again!
c

Chris White

09/22/2020, 5:01 AM
No worries! Sounds like you’ve got a great handle on things - you are correct that as of right now you will need a custom serializer to save task output as plain text. In fact, that seems like a really useful serializer - it’d be great if you could open a PR with it to include it in the library!
👍 1