Olve Heitmann
10/23/2025, 1:50 PMMarvin
10/23/2025, 1:50 PMMarvin
10/23/2025, 1:53 PMpip install prefect-github
2) Create and save a Local File System block
from prefect.filesystems import LocalFileSystem
# Point this to the directory you want Prefect to use
local_fs = LocalFileSystem(basepath="/path/on/this/machine")
local_fs.save("my-local-fs", overwrite=True)
3) Create and save a GitHub Credentials block
from prefect_github.credentials import GitHubCredentials
gh_creds = GitHubCredentials(token="ghp_your_personal_access_token")
gh_creds.save("my-github-creds", overwrite=True)
4) Load and use them later
from prefect.filesystems import LocalFileSystem
from prefect_github.credentials import GitHubCredentials
local_fs = LocalFileSystem.load("my-local-fs")
gh_creds = GitHubCredentials.load("my-github-creds")
# Optional: quick check that local_fs works
local_fs.write_path("test.txt", b"hello")
print(local_fs.read_path("test.txt"))
Notes
- You must be connected to your Prefect backend (Cloud or a running server) to save blocks.
- Use overwrite=True if you want to update an existing block with the same name.
- The GitHub token is stored as a secret and will be masked in the UI/logs.
Docs
- Blocks overview: Prefect 3 Blocks
- File systems API: LocalFileSystem API
- GitHub integration: prefect-github