Skip to content

Integrations

Each page maps one Python library family onto MeTTa forms: tables to facts, models to constructor expressions, stores to spaces, arrays to one operation vocabulary. The examples behind these pages run in the test suite, so every walkthrough stays true to the code.

Shipping one as a package

A third-party package advertises what it brings through packaging entry points, pytest plugins' and SQLAlchemy dialects' own mechanism, three groups:

toml
[project.entry-points."metta.integrations"]
mylib = "mylib.metta_glue"          # a module with install_metta(m)

[project.entry-points."metta.spaces"]
duck = "mylib.spaces:DuckProvider"  # a provider class or factory

[project.entry-points."metta.libraries"]
nars = "mylib:LIBRARY_DIR"          # the directory of sources it ships

Nothing auto-registers on import. metta.integrate.entry_points(group) answers the advertised names without loading anything, and the app loads by name, keeping control:

python
from metta import attach, integrate

integrate.discover(m)                                     # install every advertised integration
attach("&duck", integrate.load_entry_point("duck"))
m.register_library_path(
    integrate.load_entry_point("nars", group=integrate.LIBRARIES_GROUP), "nars"
)

A callable target is a factory and is called with your arguments; a non-callable one answers as-is. An unknown name refuses by listing what is installed, so a typo reads as one.

Released under the MIT License.