Skip to main content

ML_adapter plugin for waylay-sdk-py.

Project description

waylay-ml-adapter-sdk

ML Model Adapter plugin for waylay-sdk.

Installation

# installs the ml tool, and the required sdk modules:
pip install waylay-ml-adapter-sdk

# install the adapter module you need:
pip install waylay-ml-adapter-sklearn[dill]

Classes exported by ml_adapter.sdk

The module ml_adapter.sdk exports the following classes

MLTool

ml_adapter.sdk.tool.MLTool

MLAdapter utility service for the waylay client.

Helps creating waylay webscripts and plugs that wrap a machine learning model.

Loaded as tool with name ml_tool in the python sdk.

Example

# create and test a simple model
import numpy as np
test_data = [1,2,3]
expected_result = [2,4,6]
doubler = lambda x: x*2
assert np.array_equal(
    np.array(expected_result),
    doubler(np.array(test_data))
)

# wrap in an adapter, test remoting
from ml_adapter.numpy import V1NumpyModelAdapter
adapter=V1NumpyModelAdapter(model=doubler)
test_resp == await adapter.call({"instances": test_data.tolist()})
assert test_resp['predictions'] = expected_result.tolist()

# use the ml_tool to deploy and test a webscript
# configure logging to see what is happening
import logging
logging.basicConfig(level='INFO')
from waylay.sdk import WaylayClient
client = WaylayClient.from_profile('demo')

ref = await client.ml_tool.create_webscript(
    adapter, name='MyMLWebscript', draft=True
)
ref = await client.ml_tool.wait_until_ready(ref)
result = await client.ml_tool.test_webscript(ref, test_data)
if expected_result.to_list() == result:
    await client.ml_tool.publish(ref)
else:
    await client.ml_tool.remove(ref)

See also

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

waylay_ml_adapter_sdk-0.1.0.tar.gz (10.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

waylay_ml_adapter_sdk-0.1.0-py3-none-any.whl (10.1 kB view details)

Uploaded Python 3

File details

Details for the file waylay_ml_adapter_sdk-0.1.0.tar.gz.

File metadata

  • Download URL: waylay_ml_adapter_sdk-0.1.0.tar.gz
  • Upload date:
  • Size: 10.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.12

File hashes

Hashes for waylay_ml_adapter_sdk-0.1.0.tar.gz
Algorithm Hash digest
SHA256 bd340778c0116f35744ea280bf0fadb2e03ef489d9dd7ee81e734872409b69a7
MD5 86c003c02625045db28542f3f9533999
BLAKE2b-256 d3b104e749884540fd08789adfbc1428ec778dbcb56a943dd5ea1f2adb0d70d4

See more details on using hashes here.

File details

Details for the file waylay_ml_adapter_sdk-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for waylay_ml_adapter_sdk-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 26f7ce405706b8ae0053cab532b7ea77bc817524c4a7eb8c22071959b7f296e4
MD5 74011ed58c0f1337fc666cebbe245646
BLAKE2b-256 d58e44c15900f1822fb927b53bd0ead35aa6e6680b41d947c9ab4fb1758d4d8d

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page