Skip to main content

whylogs-container-client

A client library for accessing FastAPI.

See the WhyLabs doc site for full documentation, or see the API endpoint documentation for information on a specific API. The structure there mimics the module structure in the generated client.

Usage

First, create a client:

from whylogs_container_client import AuthenticatedClient

# Create an authenticated client for a container running on localhost
# The token field should match the password that you set on your whylogs container deployment.
client = AuthenticatedClient(base_url="http://localhost:8000", token="password", prefix="", auth_header_name="X-API-Key")

from whylogs_container_client import Client

# Can use a regular Client if the container has no password set
client = Client(base_url="http://localhost:8000")

APIs

Things to know:

  1. Every API has four ways of calling it.

    1. sync: Blocking request that returns parsed data (if successful) or None
    2. sync_detailed: Blocking request that always returns a Request, optionally with parsed set if the request was successful.
    3. asyncio: Like sync but async instead of blocking
    4. asyncio_detailed: Like sync_detailed but async instead of blocking
  2. APIs are grouped by their "tags" as Python modules.

  3. APIs that do not have a tag are in whylogs_container_client.api.default

Here are some example requests for common APIs.

Log Data

from datetime import datetime

import whylogs_container_client.api.profile.log as Log
from whylogs_container_client.models import LogMultiple, LogRequest

# Get current time in epoch milliseconds using datetime
time_ms = int(datetime.now().timestamp() * 1000)

data = LogRequest(
    dataset_id="model-141",
    timestamp=time_ms,
    multiple=LogMultiple(
        columns=["custom_metric_1", "custom_metric_2"],
        data=[[1, 2], [3, 4]],
    ),
)

response = Log.sync_detailed(client=client, body=data)
if response.status_code != 200:
    raise Exception(f"Failed to log data. Status code: {response.status_code}")

Validate LLM

from whylogs_container_client.models.evaluation_result import EvaluationResult
from whylogs_container_client.models.llm_validate_request import LLMValidateRequest
from whylogs_container_client.models.validation_result import ValidationResult

request = LLMValidateRequest(
    prompt="?",
    response="I'm sorry you feel that way.",
    dataset_id="model-139",
    id="myid",
)

response = Evaluate.sync_detailed(client=client, body=request)

if not isinstance(response.parsed, EvaluationResult):
    raise Exception(f"Failed to validate data. Status code: {response.status_code}. {response.parsed}")

result: ValidationResult = response.parsed.validation_results

Health check

import whylogs_container_client.api.manage.health as Health

response = Health.sync_detailed(client=client)

if not response.status_code == 200:
    raise Exception(f"Failed health check. Status code: {response.status_code}. {response.parsed}")

Get Status

import whylogs_container_client.api.manage.status as Status
from whylogs_container_client.models.status_response import StatusResponse

response = Status.sync_detailed(client=client)

if response.parsed is None:
    raise Exception("Unexpected response type")

result: StatusResponse = response.parsed

Certificates

You can customize or disable the certificate verification.

# Example of using a custom certificate bundle
client.verify_ssl = "/path/to/certificate_bundle.pem"
# Adding event hooks to the httpx client
def log_request(request):
    print(f"Request event hook: {request.method} {request.url} - Waiting for response")

def log_response(response):
    request = response.request
    print(f"Response event hook: {request.method} {request.url} - Status {response.status_code}")

client.httpx_args = {"event_hooks": {"request": [log_request], "response": [log_response]}}

Advanced customizations

You can set the httpx client directly, but beware that this will override any existing settings (e.g., base_url):

import httpx
from whylogs_container_client import Client

client = Client(
    base_url="https://api.example.com",
)
# Note that base_url needs to be re-set, as would any shared cookies, headers, etc.
client.set_httpx_client(httpx.Client(base_url="https://api.example.com", proxies="http://localhost:8030"))

Metadata

Release files for whylogs-container-client 2.2.3

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

Source distribution (sdist)

Source distribution for whylogs-container-client 2.2.3
File Size Uploaded Provenance Actions
whylogs_container_client-2.2.3.tar.gz 24.3 kB Without provenance Details for whylogs_container_client-2.2.3.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for whylogs-container-client 2.2.3
File Interpreter ABI Platform Actions
whylogs_container_client-2.2.3-py3-none-any.whl Python 3 none any Details for whylogs_container_client-2.2.3-py3-none-any.whl

Total release size: 90.2 kB

Release files / whylogs_container_client-2.2.3.tar.gz

Download URL whylogs_container_client-2.2.3.tar.gz
Size 24.3 kB
Tags Source
SHA-256 checksum
How to use checksums
9017bec99a3d9d5959240e3b561b98bb315b94438013c870c8e09ce2da14516e
BLAKE2b-256 checksum
How to use checksums
579b3793c42c8736d8ca28e7c9eb852e9e3737f32b33d6629b8e468006ff30aa
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.7.1 CPython/3.10.8 Linux/6.5.0-1025-azure

Release files / whylogs_container_client-2.2.3-py3-none-any.whl

Download URL whylogs_container_client-2.2.3-py3-none-any.whl
Size 65.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
b85053bfd4a6c6f224ab50c9869d2fa5a154da140fadc50d8c2b77c315cc5d03
BLAKE2b-256 checksum
How to use checksums
4e02d7945a36597be90d744ea4f85a70e4234ddc4a79e2722ecd77cc608baa74
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.7.1 CPython/3.10.8 Linux/6.5.0-1025-azure

Security for whylogs-container-client 2.2.3

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.

Release history Release notifications | RSS feed

This release

2.2.3 This release

2 release files No provenance

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