stapel-vocabularies
Reference vocabularies too large to inline into a category's feature schema — 14 962 phone models, 107 049 car modifications — stored as levels, terms and parent/child edges rather than as paths, so one 'black' is shared by every model that comes in black and can be translated once and faceted on. Ships the public typeahead and cascade reads a listing composer needs (ETag'd on a revision, anonymous, no cookie), the two VocabularyResolver implementations stapel-attributes' ref_select / ref_hierarchical_select types validate values through (in-process and over comm), a batched transactional loader for reviewed fixtures that spends one revision and one event per file, and Django-free converters that turn a vendor's nested XML or CSV catalogue into such a fixture without loading the document into memory.
Part of the Stapel framework — composable Django apps that deploy as a monolith or as microservices without changing module code.
Install
pip install stapel-vocabularies
At a glance
| Fact | Value |
|---|---|
| Version | 0.1.1 |
| Python | >=3.11 (3.11, 3.12, 3.13, 3.14) |
| HTTP operations | 4 |
| Config axes | 1 |
| Usage surface | 13 |
| Extension points | 5 |
| Error codes | 45 |
| Fleet dependencies | stapel-attributes · stapel-categories (optional) · stapel-core |
Documentation
OpenAPI · capabilities.json · llms.txt (for agents)
What this is
Some option lists are too big to be options. A phone catalogue has 14 962 models; a car catalogue has 107 049 modifications. Inlining those into a category's feature schema is not a tuning question — the schema is fetched on every form render, and it would be megabytes.
stapel-vocabularies is where they live instead.
- Levels, terms and edges — not paths.
Vendor → Model → MemorySize → Coloris 56 921 distinct paths in the Avito phone catalogue and only 15 844 distinct terms. Storing the terms and the parent/child edges between them means oneColor=chernyyshared by every model that comes in black: 17 colours to translate instead of 56 921 path nodes, and a facet on a colour code that is answerable at all. - A read surface built for a typeahead.
terms/?level=Model&parent=apple&q=proanswers a page withtotalandhas_children, prefix matches ranked first. Anonymous,ETag'd on the vocabulary's revision,Cache-Control: public, and noSet-Cookie— so the shared cache in front of it works and a crawler does not start a session per request. - Two resolvers, one protocol.
ref_select/ref_hierarchical_selectin stapel-attributes validate values through aVocabularyResolver.OrmResolveranswers from these tables and is registered at startup;CommResolveranswers the same questions over the bus, for a service that validates listings but holds no catalogues. Both cachedescribeby revision, so a re-imported catalogue stops validating against the levels it used to have the moment the import commits. - Loading is data plumbing, not an admin screen.
manage.py load_vocabulary phones.jsonis one transaction, one revision increment and onevocabulary.changedevent for the whole file, whatever its size. The real Avito phone catalogue — 15 844 terms, 39 749 edges — loads in ~1.2 s. - Converters that do not read the file into memory. A vendor's nested XML
or a one-path-per-row CSV becomes a reviewable fixture, streamed through
iterparse, with codes assigned deterministically (Cyrillic transliterated, collisions numbered in label sort order) so re-converting an unchanged catalogue produces an unchanged diff.
Alpha. See MODULE.md for the agent-facing map of seams.
Quick start
pip install stapel-vocabularies
# settings.py
INSTALLED_APPS = [..., "stapel_vocabularies"]
# urls.py
path("vocabularies/", include("stapel_vocabularies.urls")) # -> /vocabularies/api/v1/...
python manage.py convert_vocabulary phone_catalog.xml \
--slug avito-phones --name "Phones (Avito)" --out fixtures/avito-phones.json
python manage.py load_vocabulary fixtures/avito-phones.json --replace
A feature then points at it instead of carrying options:
{"type": "ref_select", "optionsRef": {"vocabulary": "avito-phones",
"level": "Model",
"parentFeature": "vendor"}}
API
| Method | Path | What |
|---|---|---|
| GET | /vocabularies/api/v1/vocabularies/ |
every vocabulary: {slug, name, levels, term_count, revision} |
| GET | /vocabularies/api/v1/vocabularies/{slug}/ |
one of them |
| GET | /vocabularies/api/v1/vocabularies/{slug}/terms/ |
?level= (required), ?parent=, ?q=, ?limit= (≤200, default 50), ?offset= → {results: [{code, label, level, has_children}], total} |
| GET | /vocabularies/api/v1/vocabularies/{slug}/terms/resolve/ |
?level=&codes=a,b,c (≤200) → {code: label}, unknown codes omitted |
Accept-Language selects a translated label where the term carries one; the
response Varys on it and the ETag covers it.
The fixture format
One file per vocabulary, byte-stable, reviewed as code (schema):
{ "slug": "avito-phones", "name": "Phones (Avito)", "source": "https://…/phone_catalog.xml",
"levels": [{"name": "Vendor"}, {"name": "Model", "parent": "Vendor"}],
"terms": [["Vendor", "apple", "Apple", null], ["Model", "iphone-10", "iPhone 10", null]],
"edges": [["Vendor", "apple", "Model", "iphone-10"]] }
A level's parent must be declared before it. That single rule is the whole
acyclicity argument: a level can only point backwards, so no chain of parents
can return to where it started.
License
MIT — see LICENSE.
This page is assembled by stapel-readme from docs/readme.md plus the contract artifacts in docs/. Edit the prose in docs/readme.md; the badges, facts and links above and below it are generated — do not hand-edit README.md.
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file stapel_vocabularies-0.1.1.tar.gz.
File metadata
- Download URL: stapel_vocabularies-0.1.1.tar.gz
- Upload date:
- Size: 70.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
520c19ba456d7afe8b40035df370cd409e7011cb9f08a3abafcd62d1fbe5c883
|
|
| MD5 |
1f18ecb67eab7ce7004af7c94e93ee95
|
|
| BLAKE2b-256 |
c1b1acb646ef970b75bf9a99877bf5611c6c8e2c0f36b2292dd69349115cde01
|
Provenance
The following attestation bundles were made for stapel_vocabularies-0.1.1.tar.gz:
Publisher:
publish.yml on usestapel/stapel-vocabularies
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
stapel_vocabularies-0.1.1.tar.gz -
Subject digest:
520c19ba456d7afe8b40035df370cd409e7011cb9f08a3abafcd62d1fbe5c883 - Sigstore transparency entry: 2655546190
- Sigstore integration time:
-
Permalink:
usestapel/stapel-vocabularies@1b39192c9314fba04ac6f2173cb7568cb4cf1f87 -
Branch / Tag:
refs/tags/v0.1.1 - Owner: https://github.com/usestapel
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@1b39192c9314fba04ac6f2173cb7568cb4cf1f87 -
Trigger Event:
push
-
Statement type:
File details
Details for the file stapel_vocabularies-0.1.1-py3-none-any.whl.
File metadata
- Download URL: stapel_vocabularies-0.1.1-py3-none-any.whl
- Upload date:
- Size: 64.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e29ee58707a727265286b84bd7a4c6b9d7365a0f1a46e7bf886b841c8c1d577b
|
|
| MD5 |
249cfccf944a7e2546f34c930bd7652f
|
|
| BLAKE2b-256 |
cb071aeccfdf5b3abacbf4963b83c9ca4f4f60ec3a2417f07dbbd6a4bed2b39d
|
Provenance
The following attestation bundles were made for stapel_vocabularies-0.1.1-py3-none-any.whl:
Publisher:
publish.yml on usestapel/stapel-vocabularies
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
stapel_vocabularies-0.1.1-py3-none-any.whl -
Subject digest:
e29ee58707a727265286b84bd7a4c6b9d7365a0f1a46e7bf886b841c8c1d577b - Sigstore transparency entry: 2655546193
- Sigstore integration time:
-
Permalink:
usestapel/stapel-vocabularies@1b39192c9314fba04ac6f2173cb7568cb4cf1f87 -
Branch / Tag:
refs/tags/v0.1.1 - Owner: https://github.com/usestapel
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@1b39192c9314fba04ac6f2173cb7568cb4cf1f87 -
Trigger Event:
push
-
Statement type: