Is there an example of creating a blob type from string?

129 Views Asked by At

I need to pass a large string to a workflow - seems that the right way to do it would be using a blob. Will be helpful to have an example of how to do it.

1

There are 1 best solutions below

2
Matt Smith On BEST ANSWER

From outside a task:

from flytekit.interfaces.data.data_proxy import Data

with open('/tmp/some.file', 'w') as w:
    w.write("Me iz a big string......... x100000000")

Data.put_data('/tmp/some.file', 's3://some/location')

your_launch_plan.execute('project', 'domain', inputs={'string_blob': 's3://some/location'})

If you're inside a task, you have a context which allows operating on files in a scratch space, so simply:

my_big_string_blob = Types.Blob()
with my_big_string_blob as w:
    w.write("Me iz a big string......... x100000000")