I have a task (called in a flow) that modifies a json file. When running the flow locally in my terminal, the json file is successfully edited.
However, when running the code via a prefect deployment/agent, the json file is not edited despite the code logging success and no errors/exceptions were raised.
@task(name="Modify Json")
def modify_json()
with open('json_path', 'r+') as f:
dict= json.load(f)
# updates json field
dict['key'] = 'update'
f.seek(0)
json.dump(dict, f, indent=4)
f.truncate()
# log success
logger.info(f"success")
@flow(name="test")
def test_json()
modify_json()
if __name__ = "__main__":
test_json()
I follow the deployment instructions here: