TableModel classes and FastAPIRouter in app.py. Put app.py in
the directory you run pxt init in. pxt init writes pixeltable.toml,
or appends [[tool.pixeltable.database]] to an existing pyproject.toml.
pxt schema update and pxt service update error if you have not run
pxt init in this directory or a parent.
proj
pixeltable.toml
app.py
functions.py
pixeltable.toml makes proj the root. app.py imports as app.
from functions import excerpt works because functions.py is a sibling.
A nested file (ads/app.py) imports as ads.app. Every directory name
on that path has to be a Python identifier. pxt init reports names that
are not.
A pyproject.toml is a project root only if it has [tool.pixeltable].
If both files sit in the same directory, pixeltable.toml wins. pxt init
writes one or the other, not both. Nested pxt init is refused: one
project, one root.
Create tables, then start HTTP:
my_app is a namespace inside Pixeltable, not a folder in this repo. A
second file under the same project root can use a different last-argument
name:
[[pixeltable.database]] block for a second database. Leave
name off for the local database. For Cloud, set name = "pxt://org:db"
and list the files pxt db update should upload:
app.py, different last argument:
app.py only declares models and a FastAPIRouter for Pixeltable,
start HTTP with pxt service update, not python app.py. If you mount
the router on your own FastAPI app, start that app as in HTTP serving.
Minimum Python and Pixeltable versions:
pxt schema update once before you start HTTP processes.
Pixeltable Starter Kit
Two apps. Each ships a Dockerfile and docker-compose.yml.
Where files live
Default home is~/.pixeltable: pgdata (PostgreSQL), media (generated files), file_cache (downloads). Names like my_app are Pixeltable namespaces (you can also create one with pxt.create_dir), not folders in your repo.
- Inserted local files: the path is stored; the original stays put.
- Inserted URLs: the URL is stored; first access downloads into the file cache.
- Generated media: written to the media store (local, or
destination=/PIXELTABLE_OUTPUT_MEDIA_DEST).
file_cache_size_g in config.toml only. Configuration.
export_sql. Self-hosting. A long-running service needs a persistent volume at PIXELTABLE_HOME (pgdata, media, file_cache). Starter-kit Dockerfiles set PIXELTABLE_HOME=/data/pixeltable.