foley.sources.pull#
add_from — the live-source pull façade (SOURCE → INDEX in one call).
The live analog of foley.bootstrap.bootstrap()’s per-corpus ingest loop:
resolve a registered live SourceAdapter, search it
(with the license filter pushed into the query), gate each hit through the
fail-closed foley.keep() license check, fetch its (transient) bytes, and run
them through the SAME foley.index.ingest.ingest_one() pipeline the local and
bulk paths use — so decode / QC / embed / tag / store are not forked.
For Freesound this stores every sound BY-REFERENCE (cache_bytes_ok=False): the
transient preview bytes are embedded once, then discarded; only the stable URI +
provenance + the CLAP vector persist. The audio is re-fetched on demand via the
adapter (there is no local blob to serve — library.audio(id) raises for a
remote by-reference sound; that is the contract).
Module Attributes
the source's own ( |
|
The licence a search asks for when neither the call nor the source says. |
Functions
|
Search a live |
|
The |
- foley.sources.pull.DFLT_SEARCH_LICENSE: str = 'cc0'#
The licence a search asks for when neither the call nor the source says.
- foley.sources.pull.SOURCE_DEFAULT_LICENSE: str = 'source-default'#
the source’s own (
config['license']['search_default']),DFLT_SEARCH_LICENSEwhen it declares none. A music library has one licence, so it declaresNone.- Type:
add_from’slicensedefault
- foley.sources.pull.add_from(source, *, query, license='source-default', limit=50, library=None, intended_use=None, adapter=None, on_unsupported=None, provider_params=None, **affordances)[source]#
Search a live
sourceand ingest its license-clean hits intolibrary.Progressive disclosure:
add_from("freesound", query="ocean waves")works out of the box (CC0-only, into the process-wide default library); every other knob is an optional keyword. Each hit is license-gated BEFORE any bytes are fetched (fail-closed), then routed throughingest_one(), which applies the by-reference storage gate from the sound’s own license.- Parameters:
source (
str) – A registered live-source name (e.g.'freesound').query (
Union[str,Sequence[str]]) – The natural-language search query (a music library also takes a list of titles).license (
Optional[str]) – License constraint pushed into the source query. Default: the source’s own (config['license']['search_default']),'cc0'for a source that declares none; a music library (one licence) declares no narrowing. The per-item fail-closed guard enforces the source’s accepted-license allowlist regardless.limit (
int) – Max candidates to request from the source.library – Target
SoundLibrary(default: the process-wide default library).intended_use (
Optional[IntendedUse]) – The rights intent each candidate is gated against (default:DEFAULT_INTENDED_USE).adapter – An optional pre-built adapter to use instead of the registry’s (the dependency-injection seam — a test passes a fake-transport adapter; production omits it and the registry lazily builds one).
on_unsupported (
Optional[str]) – A search parameter the source cannot honour:None(default) drops it with a note inreport.notes;'raise'raises (seefoley.sources._dispatch.translate_affordances()).provider_params (
Optional[dict]) – Native search params of the source that foley has no unified affordance for (#61), e.g. Freesound’s{"filter": "ac_brightness:[50 TO 100]"}. Passed to the adapter’ssearchuntranslated (so the unsupported-parameter policy does not see them) and merged over its translated params; the licence filter and the fail-closed gate still apply.**affordances – Extra unified affordances forwarded to the adapter’s
search(seefoley.base.QUERY_AFFORDANCES):duration_range,sort(relevance|newest|popular|duration),page,kind(sfx|music),sources,include_explicit,similar_to,ucs_category.
- Return type:
- Returns:
An
IngestReport— inspect.ingestedfor the stored records (eachstorage_mode == by_referencefor Freesound) and.summary()for counts, exactly likefoley.ingest().- Raises:
SearchArgumentError – A search argument the source refuses before any call (a
ValueError), e.g. apagepast its result window (Openverse serves ~240 results a query), or Freesound’skindanducs_categorynaming two different top levels.SourceConfigurationError – A missing key or optional dependency.
- foley.sources.pull.search_license(license, config)[source]#
The
licensea search sends:license, or the source’s default for it.>>> search_license("CC-BY-4.0", {}), search_license(SOURCE_DEFAULT_LICENSE, {}) ('CC-BY-4.0', 'cc0') >>> print(search_license(SOURCE_DEFAULT_LICENSE, {"license": {"search_default": None}})) None