Theom
03/20/2025, 11:00 AMtxn.is_committed()
always returns false even though I can see a record written with the expected key in the storage directory.
I tried the example from the docs:
from prefect import task, flow
from prefect.transactions import transaction
@task
def download_data():
"""Imagine this downloads some data from an API"""
return "some data"
@task
def write_data(data: str):
"""This writes the data to a file"""
with open("data.txt", "w") as f:
f.write(data)
@flow(log_prints=True)
def pipeline():
with transaction(key="download-and-write-data") as txn:
if txn.is_committed():
print("Data file has already been written. Exiting early.")
return
data = download_data()
write_data(data)
if __name__ == "__main__":
pipeline()
I don't get the expected print statement and the download/write tasks are executed.Nate
03/20/2025, 1:40 PMpbpaste | uv run --with git+<https://github.com/PrefectHQ/prefect.git@refs/pull/17541/head> -
Nate
03/20/2025, 4:14 PMTheom
03/20/2025, 4:14 PMNate
03/20/2025, 4:15 PMpip install git+<https://github.com/PrefectHQ/prefect.git@refs/pull/17541/head>
and then your script
but sounds good! thanks for the follow upTheom
03/20/2025, 4:40 PMNate
03/20/2025, 4:43 PMTheom
03/20/2025, 4:44 PMNate
03/20/2025, 4:44 PM