Path to persistent files?
I’m running a python program in a Gradio space.  I want to use persistent storage to create, read, write a small text file to track usage across different sessions.  For testing purposes I’m only trying to use the free (non-persistent) storage.  So my program creates, writes to and reads from the small text file all within a current session.  When I get it working I will subscribe to paid persistent storage.I’m told the folder for storage is /data but I cannot figure out how to compose a valid path to a file (example “userLog.txt” ) in this folder.  Anything I try just throws an exception when trying to open and use the file.Can someone clue me in here?  TIA
2024-07-23T18:45:43Z
I figured it out,  so if it will help any other noobs I post it here:Create a directory for the file::from pathlib import Pathdp = Path(‘…/data’)dp.mkdir(exist_ok=True) # does nothing if dir already existsThen  file  ops (open, read, write) will succeed with file paths such as:dataLogFilePath = “…/data/usageData.txt”EDIT:  Discovered by trial and error (after setting up persistent storage) that to access that storage you need:  ‘/data’ in the places where I had ‘…/data’ above.
2024-07-24T06:46:29Z
This topic was automatically closed 12 hours after the last reply. New replies are no longer allowed.