I am using prefect2.0. I have the following flow t...
# prefect-community
m
I am using prefect2.0. I have the following flow that I run in a docker infrastructure.
Copy code
@flow
def my_flow():
    return "hola"
Using the OrionClient I am able to read the states of a flow run using
orion_client.read_flow_run_states(flow_run_id)
. The last state is
COMPLETED
and has a
data
attribute that is NOT
None
. For example the data attribute value is:
Copy code
state.data = _Result(key='b1fd11041ae54cfcbb9b41ec938ff0cf', filesystem_document_id=UUID('bd1ed851-82d2-4f87-b11c-be04a80634af'))
What does this represents? Why don't I have
state.data = "hola"
instead? How do I get my flow return data from the OrionClient? Thanks a lot!
1
z
Hi! We don’t store your data in the database. Instead, we store a reference to the file system it was persisted to and a key that identifies that unique result. We have a utility at
prefect.results._retrieve_result
that retrieves the result for a given state. In the near future, we will allow you to configure different file systems to persist results to (currently it is always local to the flow run, so its in your container’s file syste) and update the
State.result()
method to automatically pull from that location.
m
has my orion_client is outside the container and the flow_run has completed (thus container has exited). The data is then loss right?
In the near future, we will allow you to configure different file systems to persist results to (currently it is always local to the flow run, so its in your container’s file system
With that feature, the flows return could be directed towards a blob
azure
gcs
, etc file system instead? When is that feature be available? For now my only solution would be to do something like:
Copy code
@flow
def my_flow():
    my_return = "hola".encode()
    azure_block = Azure.load("azureblobblock")
    azure_blob.write_path("flow-result-{os.environ['PREFECT__FLOW_RUN_ID']}.json", my_return)
    return my_return
right?
z
Yes the data is gone then unless you create a volume mount where results are persisted. Yep that is the intention. I can’t confirm a date. It’s the next thing I’m working on.
🙌 1