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 AttributeConverterBase instance.

  • 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 KeyError if the name is not found.

pyvcad_attribute_resolver.list_conversions()[source]#

Return all registered ConversionEntry objects.

pyvcad_attribute_resolver.clear_conversions()[source]#

Remove all registered conversions.

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 AttributeModifier chain.

Targets are processed sequentially so that attributes produced by earlier conversions are available for later ones.

Parameters:
  • designpyvcad.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 ConversionEntry names 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 more AttributeModifier nodes. Returns the design unchanged if all targets are already present.

Raises:

Discovery#

pyvcad_attribute_resolver.list_modules()[source]#

Return the names of all installed sub-packages under modules/.

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_factory callable produces a fresh AttributeConverterBase instance 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.

Errors#

exception pyvcad_attribute_resolver.ResolverError[source]#

Base error for the attribute resolver.

exception pyvcad_attribute_resolver.NoPathError[source]#

No conversion path found between the available and target attributes.

exception pyvcad_attribute_resolver.AmbiguousPathError(message, paths=None)[source]#

Multiple equally-valid conversion paths found.