an.stores#
Project mall: a dict of dol-backed MutableMapping stores.
The mall is the unit of persistence in an. Every long-lived state — assets (characters, props, environments, voices, styles, sounds, recordings), the scene file pair, intermediate artifacts (audio, viseme tracks, best-of-N take records, per-shot mp4s, the content-keyed shot cache, linked transcripts), final output and its caption sidecar, the agent’s decision log, and the asset library’s lockfile of pinned check-outs — is keyed inside a store. Stores are dol-backed so the same call sites work against filesystem, SQLite, S3, etc.
>>> import tempfile
>>> from pathlib import Path
>>> with tempfile.TemporaryDirectory() as d:
... mall = build_project_mall(d, ensure=True)
... sorted(mall.keys()) == [
... 'audio', 'captions', 'characters', 'contact_sheets', 'decisions',
... 'environments', 'library_lock', 'measurements', 'output',
... 'pictures', 'previews', 'props', 'recordings', 'render_reports', 'scenes',
... 'shot_cache', 'shots', 'sounds', 'sources', 'styles', 'takes',
... 'transcripts', 'visemes', 'voices',
... ]
True
Module Attributes
The folders of a project's tree that no store owns, which |
Functions
|
Why |
|
|
|
|
|
|
|
Build the standard project mall over |
Classes
|
|
|
Per-character directory store. |
|
Per-environment directory store (meta + sidecar art). |
|
JSON-only voice descriptors. |
|
Pure-JSON style descriptors. |
|
Per-prop directory store. |
|
|
|
Per-sound directory store. |
|
Per-take directory store: |
|
TTS-rendered audio clips (.wav). |
|
Lip-sync viseme tracks (.json) — stored as bytes for cache uniformity. |
|
Best-of-N take records (.json bytes), keyed by the line's audio key: which take was kept, its sha256, every take's score and the scorer (an#265). |
|
Per-shot rendered mp4s. |
|
Low-res preview renders (mp4 or png sequence wrapper). |
|
Contact sheets (.png): frames of a render at its settled beats, labelled with their time, for a person or an agent to LOOK at (core study §2.10). |
|
Measurements a clock-owning renderer made of its content (.json bytes), keyed by that content's key — DERIVED data, never the author's (an#279): a Manim shot's length, its timeline of beats, its findings. |
|
An opaque renderer's raw picture (.mp4) — a Manim scene's own render, before it is conformed to a film's fps and size, so a change that is not to the picture (narration, fps) does not run Manim again (an#279). |
|
What a render found (.json), keyed like the output it describes — |
|
Python scene sources ( |
|
Final composited renders. |
|
Append-only JSONL log keyed by ordinal index (as string). |
|
|
- class an.stores.AudioArtifactStore(root_dir, *, ensure=False)[source]#
Bases:
_BlobStoreTTS-rendered audio clips (.wav).
- class an.stores.CharactersStore(root_dir, *, ensure=False)[source]#
Bases:
JsonSidecarStorePer-character directory store.
>>> import tempfile >>> with tempfile.TemporaryDirectory() as d: ... store = CharactersStore(d) ... store['maya'] = {'name': 'Maya', 'voice_ref': 'maya-warm'} ... store['maya']['name'] 'Maya'
- class an.stores.ContactSheetStore(root_dir, *, ensure=False)[source]#
Bases:
_BlobStoreContact sheets (.png): frames of a render at its settled beats, labelled with their time, for a person or an agent to LOOK at (core study §2.10).
Content-addressed — the key is the sha256 of the PNG bytes — so a shot whose render is reused from the shot cache still points at its sheet through the cached provenance, and two shots with one picture share one file.
- class an.stores.DecisionLogStore(log_path, *, ensure=False)[source]#
Bases:
MutableMappingAppend-only JSONL log keyed by ordinal index (as string).
Mutating in-place (
__setitem__,__delitem__) is intentionally forbidden; the log is append-only by design.>>> import tempfile, os >>> with tempfile.TemporaryDirectory() as d: ... log = DecisionLogStore(os.path.join(d, 'decisions.jsonl')) ... _ = log.append(kind='test', body={'x': 1}) ... _ = log.append(kind='test', body={'x': 2}) ... entries = list(log.values()) ... entries[0]['body']['x'], entries[1]['body']['x'] (1, 2)
- class an.stores.EnvironmentsStore(root_dir, *, ensure=False)[source]#
Bases:
JsonSidecarStorePer-environment directory store (meta + sidecar art).
- class an.stores.JsonDirStore(root_dir, *, ensure=False)[source]#
Bases:
LazyFolder,MutableMappingMutableMappingof name -> JSON document, stored as<name>.jsonfiles.Backed by the filesystem under
root_dir. Keys are the file stems; values are arbitrary JSON-serializable Python objects.__contains__,__iter__, and__len__are derived from directory listing. Exported froman.storesfor hosts (an#664): a write is atomic andlocked()is the contract for a read, change and write shared with other processes.Its folder follows
LazyFolder’s rule (an#696): made by the first write or lock, so a host can scan many folders through the store without leaving an empty one in each.>>> import tempfile >>> d = Path(tempfile.mkdtemp()) / "voice_options" >>> store = JsonDirStore(d) >>> list(store), "jerry" in store, d.exists() ([], False, False) >>> store["jerry"] = {"options": []} >>> list(store), d.exists() (['jerry'], True)
- locked(key)[source]#
Hold
key’s file lock (<key>.json.lock): a read, change and write ofkeyinside it is one step for every process that takes it too (an#587). The lock file and the atomic write’s temp file are never keys.>>> import tempfile >>> store = JsonDirStore(tempfile.mkdtemp()) >>> with store.locked("jerry"): ... store["jerry"] = {"options": []} >>> list(store), store["jerry"] (['jerry'], {'options': []})
- class an.stores.MeasurementStore(root_dir, *, ensure=False)[source]#
Bases:
_BlobStoreMeasurements a clock-owning renderer made of its content (.json bytes), keyed by that content’s key — DERIVED data, never the author’s (an#279): a Manim shot’s length, its timeline of beats, its findings.
- class an.stores.OutputStore(root_dir, *, ensure=False)[source]#
Bases:
_BlobStoreFinal composited renders.
- class an.stores.PictureStore(root_dir, *, ensure=False)[source]#
Bases:
_BlobStoreAn opaque renderer’s raw picture (.mp4) — a Manim scene’s own render, before it is conformed to a film’s fps and size, so a change that is not to the picture (narration, fps) does not run Manim again (an#279). Content-addressed (the key is the sha256 of the mp4): the measurement record under the picture key names it, so a record and its picture are written as one (an#291).
- class an.stores.PreviewArtifactStore(root_dir, *, ensure=False)[source]#
Bases:
_BlobStoreLow-res preview renders (mp4 or png sequence wrapper).
- class an.stores.ProjectLock(project_dir)[source]#
Bases:
MutableMapping<store>/<key> -> pinover a project’sassets.lock.json.Every write rewrites the whole (small) file, sorted, so the lockfile diffs cleanly under version control. The mapping is the
assetssection;kitsis thekitssection, and a write to either keeps the other.
- class an.stores.PropsStore(root_dir, *, ensure=False)[source]#
Bases:
JsonSidecarStorePer-prop directory store.
>>> import tempfile >>> with tempfile.TemporaryDirectory() as d: ... store = PropsStore(d) ... store['lamp'] = {'name': 'Desk lamp'} ... store['lamp']['name'] 'Desk lamp'
- class an.stores.RecordingsStore(root_dir, *, ensure=False)[source]#
Bases:
AudioSidecarStorePer-take directory store:
<key>/recording.json+<key>/audio.wav.- ENTRY_NOUN = 'recording'#
What an entry is called in error messages.
- class an.stores.RenderReportStore(root_dir, *, ensure=False)[source]#
Bases:
_BlobStoreWhat a render found (.json), keyed like the output it describes —
render_reports["main"]— soorchestrateand MCP read the findings thatan renderwarned (an#279).
- class an.stores.ScenesStore(project_dir, scene_file='scene.md')[source]#
Bases:
MutableMappingMutableMappingexposing the scene file pair under a project root.Keys: currently always
"main". The store enforces this by raisingKeyErrorfor other keys.- patch_shot_durations(durations)[source]#
Set
durationon the named shots WITHOUT regeneratingscene.md.__setitem__rewrites the markdown from the IR, which drops every word of prose and every comment the IR does not hold. This writes the JSON through the read boundary as usual, and patches only each shot’sduration:line in the markdown (inserting one into its `````yaml shot ``block, or the block itself, when there is none) — whatan sync --accept-measureduses to take a measured duration into the authored scene (an#279).- Return type:
- class an.stores.ShotArtifactStore(root_dir, *, ensure=False)[source]#
Bases:
_BlobStorePer-shot rendered mp4s.
- class an.stores.SoundsStore(root_dir, *, ensure=False)[source]#
Bases:
AudioSidecarStorePer-sound directory store.
>>> import tempfile >>> with tempfile.TemporaryDirectory() as d: ... store = SoundsStore(d) ... store['hit'] = {'description': 'a stick on a table'} ... store.write_audio('hit', b'RIFF....') ... store['hit']['description'], store.read_audio('hit') ('a stick on a table', b'RIFF....')
- AUDIO_NAME = 'audio.wav'#
an.soundsreads its header for the duration a fade-out needs, deterministically.- Type:
The sidecar holding the audio bytes. WAV only in v1
- ENTRY_NOUN = 'sound'#
What an entry is called in error messages.
- class an.stores.SourcesStore(root_dir, *, ensure=False)[source]#
Bases:
_BlobStorePython scene sources (
.pybytes) — a Manim scene file per key.
- class an.stores.StylesStore(root_dir, *, ensure=False)[source]#
Bases:
JsonDirStorePure-JSON style descriptors.
- class an.stores.TakesArtifactStore(root_dir, *, ensure=False)[source]#
Bases:
_BlobStoreBest-of-N take records (.json bytes), keyed by the line’s audio key: which take was kept, its sha256, every take’s score and the scorer (an#265).
- an.stores.UNSTORED_FOLDERS = ('ir',)#
The folders of a project’s tree that no store owns, which
ensure=Truelays out beside the stores’ own:ir/, where the scene store writes the default scene’s IR (the store’s root is the project folder itself).
- class an.stores.VisemeArtifactStore(root_dir, *, ensure=False)[source]#
Bases:
_BlobStoreLip-sync viseme tracks (.json) — stored as bytes for cache uniformity.
- class an.stores.VoicesStore(root_dir, *, ensure=False)[source]#
Bases:
JsonDirStoreJSON-only voice descriptors.
>>> import tempfile >>> with tempfile.TemporaryDirectory() as d: ... store = VoicesStore(d) ... store['maya-warm'] = {'provider': 'elevenlabs', 'voice_id': 'xyz'} ... 'maya-warm' in store True
- an.stores.asset_ref_problem(rel)[source]#
Why
rel, a path an asset document names, is NOT a clean relative path inside the asset’s folder, orNonewhen it is one (an#483).An asset reference resolves inside its own folder, never anywhere else: an absolute path, a
..that leaves the folder or a URL is refused by name, before any read — a project may be someone else’s input (a production pack checked on a server), and a reference that reaches outside it is a file-existence and XML-parse oracle on the host. The spelling is held to the library’s rule too (no.or empty segment, no backslash), so a reference that validates here publishes there unchanged.>>> asset_ref_problem("parts/head.svg") is None True >>> asset_ref_problem("/etc/hostname") 'is an absolute path' >>> asset_ref_problem("../../other/plate.png") 'leaves the asset folder (`..`)' >>> asset_ref_problem("file:///etc/hostname"), asset_ref_problem("C:/art/x.svg") ('is a URL or a drive path (`:`)', 'is a URL or a drive path (`:`)') >>> asset_ref_problem("./parts/head.svg"), asset_ref_problem("parts\\head.svg"), asset_ref_problem("") ('has an empty or `.` segment', 'uses a backslash (write the path with `/`)', 'is empty')
- an.stores.asset_ref_problems(doc, folder=None, *, file_problems=None)[source]#
(label, message)for every reference indoc(asset_references()) that breaks the asset-reference rule (an#483, an#552);[]when none does. The one rule the core and a genre share.A reference is judged by NAME first (
asset_ref_problem()), and is never read when its name is bad; with afolder, also by where it resolves (inside_folder(): a link out of the folder is the same error).file_problems, when given, is asked about each file that passed (the core passes its SVG self-containment check): it is called for every path that passed the name (and folder) check, whether or not the file exists, so it must tolerate an absent file. Each message it returns is appended to"<label> names <path>, which", so it must begin with a verb ("is SVG that ...","is not in the folder").messageis a whole sentence, label included, so a caller can report it as is.>>> asset_ref_problems({"source_svg": "../x.svg", "planes": [ ... {"name": "sky", "art": {"kind": "image", "src": "sky.png"}}]}) [('source_svg', "source_svg names '../x.svg', which leaves the asset folder (`..`): an asset reference must be a relative path inside the asset's own folder (nothing outside it is read)")] >>> asset_ref_problems({"source_svg": "source.svg"}, ".") [] >>> asset_ref_problems({"source_svg": "ok.svg"}, ".", ... file_problems=lambda f: [f"is SVG that holds a <script>"]) [('source_svg', "source_svg names 'ok.svg', which is SVG that holds a <script>")]
- an.stores.asset_references(doc)[source]#
(label, path)for every file path an asset document names (an#552): an environment’s image planes (planes/<name>/art/src), a rig’s attachments (skins/<skin>/slots/<slot>/<attachment>/path; labelledpart <skin>:<slot>/<attachment>outside the default skin), a character’ssource_svgand the files itscolour_roleskeys name.The one list of what an asset document references; the core’s
an validateand a genre’s own validator both walk it, so they cannot disagree about which fields hold a path.>>> asset_references({"planes": [{"name": "sky", "art": {"kind": "image", "src": "sky.png"}}, ... {"name": "fill", "art": {"kind": "fill"}}]}) [('plane sky', 'sky.png')] >>> asset_references({"skins": {"default": {"slots": {"body": {"body": {"path": "parts/body.svg"}}}}}, ... "source_svg": "source.svg", "colour_roles": {"parts/body.svg": {"#fff": "skin"}}}) [('part body/body', 'parts/body.svg'), ('source_svg', 'source.svg'), ('colour_roles parts/body.svg', 'parts/body.svg')]
A malformed document names nothing where it is malformed (its schema check reports it), rather than raising:
>>> asset_references({"planes": [{"art": "sky.png"}], "skins": {"default": {"slots": ["body"]}}, ... "source_svg": 3}) [] >>> asset_references({"planes": "sky.png", "skins": ["default"]}) []
- an.stores.build_project_mall(project_dir, *, ensure=False, scene_file='scene.md', **overrides)[source]#
Build the standard project mall over
project_dir.Building it lays out nothing (an#696): every file store makes its folder on its first write, a missing one reading as empty.
ensure=True(an init) lays out the tree at once: each store’s folder, through the store, and theUNSTORED_FOLDERS.scene_filepicks the scene thescenesstore holds (an#539;scene.mdby default). Pass keyword overrides to swap in alternate stores (e.g. an in-memorydictfor tests).- Return type:
- an.stores.inside_folder(folder, rel)[source]#
folder / relwhenrelis a relative path that stays insidefolderonce symlinks are resolved, elseNone(an#483). The path is returned as joined, not resolved, so a caller’s own stat and digest see the same spelling they always did.>>> import tempfile, os >>> with tempfile.TemporaryDirectory() as d: ... inside_folder(d, "parts/head.svg") == Path(d) / "parts/head.svg" ... inside_folder(d, "../head.svg") is None, inside_folder(d, "/etc/hostname") is None True (True, True)
Modules
Artifact stores — derived, regeneratable products of the pipeline. |
|
Characters store — descriptor + sidecar folder per character. |
|
Decision log — append-only JSONL of agent decisions and user approvals. |
|
Environments store — backgrounds, set pieces, and prop bundles. |
|
The project lockfile: which library version each checked-out asset came from. |
|
Props store — descriptor + sidecar folder per prop. |
|
Recordings store — one directory per recorded take: |
|
Scenes store — wraps the project's |
|
Sounds store — one directory per sound: |
|
The project's opaque scene sources: files a whole-shot renderer runs as they are. |
|
Styles store — visual style presets (color palette, line weight, fonts). |
|
Transcripts as linked artifacts in the project store (an#493). |
|
Voices store — pure JSON; one entry per voice. |