Step 4: sessions and downloads
Why a file needs its session, and what the SDK remembers for you.
Everything you generate lives in a session: a private workspace on the server. You did not create one, because Catalyst makes one for you and uses it on every call. Two things follow.
1. Files belong to a session. The API finds a file by its session and its id. The SDK remembers this for you: every file it returns carries its session, so download(file) is all you write.
2. A bare file id needs a session. If you only have a file id (from a database, from yesterday's run), the SDK cannot know the session and will not guess. It stops before sending anything:
catalyst.download("fil_0123abcd") # InvalidRequestError: session_id is required
catalyst.download("fil_0123abcd", session_id="sdk-...") # worksTo see the message, catch the error and print it. The error is raised before anything is sent, so it is instant and free:
from falcore import InvalidRequestError
try:
catalyst.download("fil_0123abcd")
except InvalidRequestError as e:
print(e)422 INVALID_REQUEST session_id: is required to download 'fil_0123abcd': the API finds a file by its session. Pass session_id=..., or download the File object a call returned (it already knows its session).(The 422 is the SDK's own status for a rejected input; no request was sent.)
That is why the manifest in step 8 stores the session_id: it is what lets you download the same files tomorrow. To work in one session across runs, set it once.
catalyst.session_id = "my-project"A download goes to the folder you give it as a file path (used exactly) or a folder (named <file_id>.<format>). The data is written to a .part file and renamed when complete, so a crash never leaves a half-written file under the real name.