source_consts
Shared constants and types for model record provenance ("sources").
A source identifies where a model record originated. The canonical
horde-model-reference data is served under the reserved id "horde"; third
parties register :class:~horde_model_reference.providers.base.ModelProvider
instances under their own ids to contribute additional records for any category.
These constants live in their own dependency-light module so that both the query
layer (:mod:horde_model_reference.query) and the provider layer
(:mod:horde_model_reference.providers) can import them without creating an
import cycle.
HORDE_SOURCE_ID
module-attribute
Reserved source id for canonical horde-model-reference data.
This is the default source for every read/query API, so existing callers that do
not pass a source argument keep their current behavior unchanged.
ANY_SOURCE
module-attribute
Sentinel selector meaning "the canonical source plus every registered provider".
When used as a query selector, records from all sources are merged. By default the
canonical source wins name collisions; see
:meth:horde_model_reference.query.ModelQuery.duplicate_names to detect when a
collision occurred.
RESERVED_SOURCE_IDS
module-attribute
Source ids that third-party providers may not register under.
SourceOutcome
The result of attempting to read a single selected source for one category.
"ok"- the source contributed at least one record."empty"- the source was reachable but had nothing for this category (returnedNone/empty, or does not serve the category)."error"- the source raised during fetch and was skipped (error isolation).
Surfaced to consumers via :meth:horde_model_reference.query.ModelQuery.source_status
so a failed source can be distinguished from a genuinely empty one.
SourceSelector
A source selection accepted by the read/query APIs.
May be:
"horde"(:data:HORDE_SOURCE_ID) - canonical data only (the default)."any"(:data:ANY_SOURCE) - canonical data merged with all providers.- a single provider id (e.g.
"civitai"). - a sequence of ids (e.g.
["horde", "civitai"]) - an explicit, ordered set. Ordering controls collision precedence: earlier sources win.
normalize_source_selector
Return source as a de-duplicated, order-preserving list of source ids.
A bare string becomes a single-element list. ANY_SOURCE is preserved as a
sentinel and resolved later by the manager (which knows the live provider set).
Parameters:
-
source(SourceSelector) –The source selector to normalize.
Returns: