Skip to main content

waylay-ml-adapter-base

Provides the ml_adapter.base module for the Waylay ML Adapter solution.

To use an ML Adapter in a Waylay plugin or webscript, use the adapter relevant to your machine learning framework:

This waylay-ml-adapter-base module provides the framework for these adapters. Only if you would need to create an adapter utility for another framework, you would install this module separately:

pip install waylay-ml-adapter-base

Classes exported by ml_adapter.base

The module ml_adapter.base exports the following classes

PythonMLAdapter

ml_adapter.base.assets.python_ml.PythonMLAdapter extending ml_adapter.base.assets.python.PythonFunctionAdapter

Base adapter for a python ML function.

Adds methods to intialize the manifest and script for a python plugin or webscript.

  • as_webscript() initializes the manifest and script for a webscript that uses an ML Adapter.
  • as_plug() initializes the manifest and script for a rule plugin that uses an ML Adapter.

PythonFunctionAdapter

ml_adapter.base.assets.python.PythonFunctionAdapter extending ml_adapter.base.assets.manifest.WithManifest

Adapter for python based plugs or webscripts.

  • requirements handles the dependency file (at requirements.txt)
  • lib handles the libraries that are uploaded with the function archive itself. (at lib/*.tar.gz)
  • main_script handles the main script of the function (main.py)
  • scripts handles other utility scripts of the function (*.py)

NodeFunctionAdapter

ml_adapter.base.assets.node.NodeFunctionAdapter extending ml_adapter.base.assets.manifest.WithManifest

Adapter for node based plugs or webscripts.

  • package handles the project file (at package.json)
  • main_script handles the main script of the function (index.js or index.ts)
  • scripts handles other utility scripts of the function (*.js,*.ts)

WithManifest

ml_adapter.base.assets.manifest.WithManifest extending ml_adapter.base.assets.mixin.WithAssets

Mixin for a configuration that has a waylay function manifest file.

Adds methods to manage the function manifest of a waylay plugin or webscript.

  • manifest returns the manifest asset of the function archive at plug.json or webscript.json.

ModelAdapter

ml_adapter.base.adapter.ModelAdapter

Model Adapter base.

Provides the basic contract for exposing a model to a waylay plugin or webscript.

  • Delegates to a marshaller to map the remote, json-compatible python data structures from and to the native tensor data structures for the ML framework.
  • Delegates to a invoker to find the model method to be called.
  • The call method maps remote requests and invokes the model method.
  • The call_remote method tests the round trip serialization, encoding native data request to remotable and back before invoking call.

TensorModelAdapter

ml_adapter.base.adapter.TensorModelAdapter extending ml_adapter.base.adapter.ModelAdapter

Model adapter that uses (dicts of) tensors as inputs and outputs.

Requests are mapped to the model invocation using named parameters, falling back to mapping the "main" entry to the first positional parameter.

ModelAdapterBase

ml_adapter.base.adapter.ModelAdapterBase extending ml_adapter.base.adapter.TensorModelAdapter, ml_adapter.base.assets.python_ml.PythonMLAdapter, ml_adapter.base.model.access.WithModel

Generic model adapter for plugs and webscripts.

  • supports creation of waylay webscript and plug functions
  • pluggable tensor marshalling (DEFAULT_MARSHALLER = NoMarshaller)
  • pluggable model loading (dill, joblib, selfserializing, custom) configured by MODEL_ASSET_CLASSES and MODEL_CLASS

WithAssets

ml_adapter.base.assets.mixin.WithAssets

Mixin for a configuration backed by assets.

Manages assets of the the plugin or webscript.

Used read-only within a deployed adapter to e.g. load the model definition.

Used read/write within the ml_tool to edit the assets of a plugin or webscript.

WithOpenapi

ml_adapter.base.assets.openapi.WithOpenapi extending ml_adapter.base.assets.mixin.WithAssets

Mixin for a configuration that has an openapi description.

Adds methods to a WithAssets adapter to manage the openapi description of waylay plugin or webscript.

  • openapi returns an asset of type OpenApiAsset (normally at openapi.json)

WithModel

ml_adapter.base.model.access.WithModel extending ml_adapter.base.assets.mixin.WithAssets

Holder of model assets.

Adds methods to a WithAssets adapter to manage the model instance. A model can either be:

  • given as model in the constructor of the adapter
  • loaded from model_path in the assets
  • loaded with a model_class (using an optional model_path)

The MODEL_ASSET_CLASSES configured on the adapter define the methods to load a model. Defaults are

  • DillModelAsset (".dill", ".pkl", "*.pickle" files)
  • JoblibModelAsset (".joblib", ".joblib.gz" files)
  • SelfSerializingModelAsset ("*.sav" files)

If no MODEL_ASSET_CLASSES are configured, the model can only be set by the contructor (using the model or model_class parameters)

SelfSerializingModelAsset

ml_adapter.base.model.serialize.SelfSerializingModelAsset extending ml_adapter.base.model.base.ModelAsset

Model asset with own serialization methods.

Reads/writes the model from model.sav using the save and load methods defined on the model_class.

DillModelAsset

ml_adapter.base.model.dill.DillModelAsset extending ml_adapter.base.model.base.ModelAsset

Model asset for dill-serialized models.

Reads/writes the model from paths like model.dill, model.pkl, model.pickle using dill serialisation.

JoblibModelAsset

ml_adapter.base.model.joblib.JoblibModelAsset extending ml_adapter.base.model.base.ModelAsset

Model asset with joblib serialization.

Reads/writes the model from model.joblib or model.joblib.gz using joblib serialisation.

Marshaller

ml_adapter.base.marshall.base.Marshaller extending ml_adapter.base.marshall.base.RequestMarshaller, ml_adapter.base.marshall.base.ResponseMarshaller

Abstract base class to marshall inference requests and responses.

Methods used to invoke the model in a plugin or webscript:

  • map_request() maps remote requests (generic type RREQ) to native requests (generic type MREQ)
  • map_response() maps native responses (generic type MRES) to remote a response (generic type RRES)

Methods used to test roundtrip encoding in a client:

  • encode_request() encodes a native request to a remote request that can be sent to a waylay function.
  • decode_response() decodes a remote response from a function to native a response.

Metadata

Release files for waylay-ml-adapter-base 0.1.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for waylay-ml-adapter-base 0.1.1
File Size Uploaded Provenance Actions
waylay_ml_adapter_base-0.1.1.tar.gz 31.7 kB Without provenance Details for waylay_ml_adapter_base-0.1.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for waylay-ml-adapter-base 0.1.1
File Interpreter ABI Platform Actions
waylay_ml_adapter_base-0.1.1-py3-none-any.whl Python 3 none any Details for waylay_ml_adapter_base-0.1.1-py3-none-any.whl

Total release size: 72.7 kB

Release files / waylay_ml_adapter_base-0.1.1.tar.gz

Download URL waylay_ml_adapter_base-0.1.1.tar.gz
Size 31.7 kB
Tags Source
SHA-256 checksum
How to use checksums
cb591473c101b1a9bafcf9c4cf17ba0eb42ab89ea42afb36ef4a78bb3afa0805
BLAKE2b-256 checksum
How to use checksums
66cb230d58d869d41e52f53417e14bbdcc5520979b830560480e44679be660a0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.11.12

Release files / waylay_ml_adapter_base-0.1.1-py3-none-any.whl

Download URL waylay_ml_adapter_base-0.1.1-py3-none-any.whl
Size 41.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
8733e7480f290db295ff75e955f5973a6fb276659e99f1bddcb8195a634edec9
BLAKE2b-256 checksum
How to use checksums
a307b17a91730e2e1eeb60e0879a911cf9ea7c0647ab80a8a79808b27d916b9e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.11.12

Security for waylay-ml-adapter-base 0.1.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page