Is there a way to use the `StringFormatter` task w...
# prefect-community
p
Is there a way to use the
StringFormatter
task with a template that is read at run time?
c
Hi Pedro, yes, the template kwarg is also available as a run method kwarg
p
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
Yup yup that is correct
p
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
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