s

    Sam Werbalowsky

    9 months ago
    Is there any issue with wrapping tasks together? For example, I want to use the
    StringFormatter
    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

    Kevin Kho

    9 months ago
    Not necessarily. But for this specifically, what does StringFormatter give you that
    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.
    s

    Sam Werbalowsky

    9 months ago
    Yeah I think
    f-string
    is probably just the way to go here. Good to know for general concepts though, thanks Kevin