Core API#
Registration#
- pyvcad_attribute_resolver.register_conversion(source, target, converter_factory, name=None, priority=0, tags=None, required_inputs=None)[source]#
Register a conversion edge in the global graph.
- Parameters:
source – Input attribute name (e.g.
"shore_hardness").target – Output attribute name (e.g.
"temperature").converter_factory – Zero-argument callable that returns a fresh
AttributeConverterBaseinstance.name – Optional human-readable name. Defaults to
"{source}_to_{target}".priority – Higher values are preferred during disambiguation.
tags – Optional list of context-filtering labels.
required_inputs – Optional list of attribute names that must be present before this conversion can be applied. Defaults to
[source].
- Returns:
The name of the registered conversion.
- pyvcad_attribute_resolver.unregister_conversion(name)[source]#
Remove a conversion by name.
Raises
KeyErrorif the name is not found.
Adaptation#
- pyvcad_attribute_resolver.adapt(design, target_attributes, allowed_conversions=None, tags=None, max_depth=10)[source]#
Wrap a design node with AttributeModifiers to produce target attributes.
For each target attribute not already present on the design, the solver finds a conversion path through the registered graph and wraps the design in the corresponding
AttributeModifierchain.Targets are processed sequentially so that attributes produced by earlier conversions are available for later ones.
- Parameters:
design –
pyvcad.Node, the root of the design tree.target_attributes – List of attribute name strings the caller needs on the output.
allowed_conversions – Optional list of
ConversionEntrynames to restrict the solver.tags – Optional list of tags to filter conversions.
max_depth – Maximum chain length per target (default 10).
- Returns:
pyvcad.Node— the original design wrapped in zero or moreAttributeModifiernodes. Returns the design unchanged if all targets are already present.- Raises:
NoPathError – If any target attribute cannot be reached.
AmbiguousPathError – If disambiguation fails for any target.
Discovery#
Data Structures#
- class pyvcad_attribute_resolver.ConversionEntry(source, target, converter_factory, name=None, priority=0, tags=None, required_inputs=None)[source]#
A registered conversion between two attribute types.
Each entry represents a directed edge in the conversion graph, from a source attribute to a target attribute. The
converter_factorycallable produces a freshAttributeConverterBaseinstance each time it is invoked, supporting clone-safe, thread-safe parallel evaluation.- source#
Input attribute name.
- target#
Output attribute name.
- converter_factory#
Zero-argument callable returning an
AttributeConverterBase.
- name#
Human-readable identifier for this conversion.
- priority#
Higher values are preferred when disambiguating multiple equally-short paths.
- tags#
Context-filtering labels (e.g.
"foaming_tpu").
- required_inputs#
Attribute names that must already be present on the design before this conversion can be applied.