Sam Werbalowsky
12/08/2021, 4:31 PMStringFormatter but pass in a file that is opened…is something like this bad practice:
@task
def format_sql_file(file):
with open(file, 'r') as sql:
string_to_format = sql.read()
return StringFormatter().run(var1='my_value', var2='other_value', template = string_to_format)Kevin Kho
f-string format doesn’t? But using a task inside a task is not bad and it makes sense sometimes. I personally use the SlackTask inside other tasks to send messages out.
Especially for an operation like this (string formatting) that doesn’t need retries or observability of state, it should be fine.Sam Werbalowsky
12/08/2021, 4:54 PMf-string is probably just the way to go here. Good to know for general concepts though, thanks Kevin