LucoPy

1.3.14 · active · verified Thu Apr 16

LucoPy is a Python SDK designed to facilitate interaction with the Luco data observability tool's API. It provides functionality for submitting data quality results, reporting metrics, and managing data slots. The current stable version is 1.3.14, which was released on September 27, 2023.

Common errors

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to initialize the `LucoApi` client. It retrieves authentication details (base URL, tenant ID, client ID, client secret, and resource ID) from environment variables for security. After initialization, the client is ready to interact with the Luco API for data observability tasks.

import os
from LucoPy import LucoApi

# --- Configuration --- 
# It is highly recommended to set these as environment variables.
# Example: export LUCO_BASE_URL="https://your-luco-instance.com/api"
BASE_URL = os.environ.get('LUCO_BASE_URL', 'https://api.luco.data')
TENANT_ID = os.environ.get('LUCO_TENANT_ID', '') # Directory (tenant) ID
CLIENT_ID = os.environ.get('LUCO_CLIENT_ID', '') # Application (client) ID for LucoPy
CLIENT_SECRET = os.environ.get('LUCO_CLIENT_SECRET', '') # Secret value for LucoPy App Registration
RESOURCE_ID = os.environ.get('LUCO_RESOURCE_ID', '') # Application (client) ID of the target API

if not all([TENANT_ID, CLIENT_ID, CLIENT_SECRET, RESOURCE_ID]):
    print("Warning: Authentication credentials not fully provided. API calls may fail.")

try:
    # Initialize the Luco API client
    api = LucoApi(
        base_url=BASE_URL,
        tenant_id=TENANT_ID,
        client_id=CLIENT_ID,
        client_secret=CLIENT_SECRET,
        resource_id=RESOURCE_ID
    )

    print(f"Successfully initialized LucoApi client for base URL: {BASE_URL}")

    # Example: Check API health (if such an endpoint exists and is public, or requires auth)
    # Note: A real health check might require specific authentication.
    # For a simple test, we'll just show the client is ready.

    # In a real scenario, you would perform operations like:
    # from LucoPy.quality import CheckResult, CollectionResult
    # check = CheckResult(check_name='MyDataCheck', success=True, observed_value='OK')
    # collection = CollectionResult(collection_name='DailyChecks', checks=[check])
    # api.submit_quality(collection)

    print("LucoPy client ready. You can now make API calls (e.g., submit_quality, get_metrics).")

except Exception as e:
    print(f"Error initializing LucoApi: {e}")
    print("Please ensure your BASE_URL and authentication credentials are correct.")

view raw JSON →