Skip to main content

Official HiddenLayer Python SDK

Project description

HiddenLayer SDK Python (Beta)

Hiddenlayer is a Python SDK that provides a simple and efficient way to interact with the Hiddenlayer API, a platform for building and deploying machine learning models. The SDK allows developers to easily protect models using the Hiddenlayer API, without having to write complex code or manage the underlying infrastructure.

Contents

Installation

Install from PyPi using pip, a package manager for Python.

pip install hiddenlayer-sdk

Scanning models on different platforms such as AWS S3 and Huggingface are supported. You can install the dependenices yourself or via optional dependencies:

pip install hiddenlayer-sdk[aws]
pip install hiddenlayer-sdk[azure]
pip install hiddenlayer-sdk[hf]

Getting Started

Once you've installed the hiddenlayer package, you can instantiate the HiddenlayerServiceClient for the SaaS platform as follows:

from hiddenlayer import HiddenlayerServiceClient

hl_client = HiddenlayerServiceClient(
  host="https://api.us.hiddenlayer.ai",
  api_id=..., # Your Hiddenlayer API Client ID
  api_key=... # Your Hiddenalyer API Secret Key
)

Scanning Models

hl_client.model_scanner.scan_file(
  model_name="name_of_the_model",
  model_path="path/to/model/file.pkl"
)

If you would like to specify the version associated with the model, you can pass that in as well. Note that the model version must not already exist.

hl_client.model_scanner.scan_file(
  model_name="name_of_the_model",
  model_version=1,
  model_path="path/to/model/file.pkl"
)

Scanning Folders

hl_client.model_scanner.scan_folder(
  model_name="name_of_the_model",
  path="path/to/model/"
)

If you would like to specify the version associated with the model, you can pass that in as well. Note that the model version must not already exist.

hl_client.model_scanner.scan_folder(
  model_name="name_of_the_model",
  model_version=1,
  path="path/to/model/"
)

Using AIDR for Predictive Models

Note: This is only supported using the SaaS version of the platform.

model = hl_client.model.create_model(model_name="example_model")

hl_client.aidr_predictive.submit_vectors(
  model_id=model.sensor_id,
  requestor_id="custom-source-id",
  input_vectors=X,
  output=y
)

Code Examples

Code examples can be found in the repo here

Interface Stability

Hiddenlayer is actively working on stabilizing the Hiddenlayer SDK for Python's interfaces. You are highly encouraged to pin the exact dependency version.

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

hiddenlayer_sdk-1.0.0.tar.gz (91.5 kB view details)

Uploaded Source

Built Distribution

hiddenlayer_sdk-1.0.0-py3-none-any.whl (213.8 kB view details)

Uploaded Python 3

File details

Details for the file hiddenlayer_sdk-1.0.0.tar.gz.

File metadata

  • Download URL: hiddenlayer_sdk-1.0.0.tar.gz
  • Upload date:
  • Size: 91.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/5.1.1 CPython/3.12.7

File hashes

Hashes for hiddenlayer_sdk-1.0.0.tar.gz
Algorithm Hash digest
SHA256 ada92dd0f5c2d34056292474add7c83747dbf394860d8dadb60077ce7e4e9070
MD5 01a8b4ddea8926f5743e9d5c638c0804
BLAKE2b-256 a6ff57cd3529ec560a05ff71e70b0a01aa734450e49b743c6ade8b70d3d35487

See more details on using hashes here.

Provenance

The following attestation bundles were made for hiddenlayer_sdk-1.0.0.tar.gz:

Publisher: python-release.yml on hiddenlayerai/hiddenlayer-sdk-python

Attestations:

File details

Details for the file hiddenlayer_sdk-1.0.0-py3-none-any.whl.

File metadata

File hashes

Hashes for hiddenlayer_sdk-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 75320837ffe957205a85bdf9824e13957e0fb01393e6d02d982c19875dd60f83
MD5 1c4c7a8d405f05ffba831b62a7b5b9b0
BLAKE2b-256 007c27a30d135ad86200d4125eb2d34a601b1c57d02c1868e7b89004416a4911

See more details on using hashes here.

Provenance

The following attestation bundles were made for hiddenlayer_sdk-1.0.0-py3-none-any.whl:

Publisher: python-release.yml on hiddenlayerai/hiddenlayer-sdk-python

Attestations:

Supported by

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