arioso.translation#
Parameter translation layer.
Translates between the unified affordance names and each platform’s native parameter names, applying type coercions along the way.
Module Attributes
Affordances that always raise on an unsupported platform, regardless of that platform's own |
Functions
|
Warn or raise for kwargs not declared in a platform's |
|
Build a generate() callable from a platform config. |
|
Build a kwargs translation function from a platform's param_map. |
- arioso.translation.ALWAYS_RAISE_UNSUPPORTED = ('lyrics',)#
Affordances that always raise on an unsupported platform, regardless of that platform’s own
on_unsupported_parampolicy. Losing these silently is losing content, not a quality knob – e.g. an instrumental with none of the caller’s words in it, with no signal that happened. See thorwhalen/arioso#3.
- arioso.translation.check_supported_params(kwargs, config, *, always_raise=('lyrics',))[source]#
Warn or raise for kwargs not declared in a platform’s
supported_affordances.on_unsupported_paramwas, until thorwhalen/arioso#3, only ever enforced insidemake_kwargs_trans()– reached solely by the REST-fallbackgeneratebuilt bymake_generate_func(). Every platform that ships a customadapter.py(which is all 14, as of this writing) never went through that translator: itsAdapter.generate(..., **kwargs)absorbed and silently dropped anything unsupported, regardless of the config’s declared policy. Call this once, uniformly, before dispatching to any adapter – seearioso.generate/arioso.generate_many.This only validates; it does not translate or drop keys itself. The caller’s kwargs are passed to the adapter unchanged either way.
- Parameters:
- Return type:
- arioso.translation.make_generate_func(config)[source]#
Build a generate() callable from a platform config.
This is the fallback when no custom adapter.py is provided. For REST API platforms, it builds the HTTP function from the config and wraps it with parameter translation and output normalization.
- arioso.translation.make_kwargs_trans(param_map, *, on_unsupported='warn', passthrough=())[source]#
Build a kwargs translation function from a platform’s param_map.
The returned function transforms:
{common_name: value, ...} -> {native_name: coerced_value, ...}
- Parameters:
param_map (
dict) – Dict mapping common affordance names to native config dicts. Each value has keys:native_name(str),coerce(optional callable),adapter_handled(optional bool).on_unsupported (
str) – What to do with params not in param_map. One of ‘warn’, ‘raise’, or ‘ignore’.passthrough – Adapter-only keyword names (a config’s
adapter_params) passed through untranslated and unwarned.
- Return type:
- Returns:
A function that translates outer kwargs to inner kwargs.