{"id":8297,"library":"lucopy","title":"LucoPy","description":"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.","status":"active","version":"1.3.14","language":"en","source_language":"en","source_url":"https://github.com/luco-data/lucopy","tags":["data observability","API client","SDK","Luco","data quality"],"install":[{"cmd":"pip install LucoPy","lang":"bash","label":"Install latest version"}],"dependencies":[],"imports":[{"symbol":"LucoApi","correct":"from LucoPy import LucoApi"}],"quickstart":{"code":"import os\nfrom LucoPy import LucoApi\n\n# --- Configuration --- \n# It is highly recommended to set these as environment variables.\n# Example: export LUCO_BASE_URL=\"https://your-luco-instance.com/api\"\nBASE_URL = os.environ.get('LUCO_BASE_URL', 'https://api.luco.data')\nTENANT_ID = os.environ.get('LUCO_TENANT_ID', '') # Directory (tenant) ID\nCLIENT_ID = os.environ.get('LUCO_CLIENT_ID', '') # Application (client) ID for LucoPy\nCLIENT_SECRET = os.environ.get('LUCO_CLIENT_SECRET', '') # Secret value for LucoPy App Registration\nRESOURCE_ID = os.environ.get('LUCO_RESOURCE_ID', '') # Application (client) ID of the target API\n\nif not all([TENANT_ID, CLIENT_ID, CLIENT_SECRET, RESOURCE_ID]):\n    print(\"Warning: Authentication credentials not fully provided. API calls may fail.\")\n\ntry:\n    # Initialize the Luco API client\n    api = LucoApi(\n        base_url=BASE_URL,\n        tenant_id=TENANT_ID,\n        client_id=CLIENT_ID,\n        client_secret=CLIENT_SECRET,\n        resource_id=RESOURCE_ID\n    )\n\n    print(f\"Successfully initialized LucoApi client for base URL: {BASE_URL}\")\n\n    # Example: Check API health (if such an endpoint exists and is public, or requires auth)\n    # Note: A real health check might require specific authentication.\n    # For a simple test, we'll just show the client is ready.\n\n    # In a real scenario, you would perform operations like:\n    # from LucoPy.quality import CheckResult, CollectionResult\n    # check = CheckResult(check_name='MyDataCheck', success=True, observed_value='OK')\n    # collection = CollectionResult(collection_name='DailyChecks', checks=[check])\n    # api.submit_quality(collection)\n\n    print(\"LucoPy client ready. You can now make API calls (e.g., submit_quality, get_metrics).\")\n\nexcept Exception as e:\n    print(f\"Error initializing LucoApi: {e}\")\n    print(\"Please ensure your BASE_URL and authentication credentials are correct.\")\n","lang":"python","description":"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."},"warnings":[{"fix":"Upgrade to LucoPy version 1.3.6 or later to use the refactored method. If on an affected version, adjust code to the new return format or pin a version prior to 1.3.3.","message":"The return format of the `Submission.get_metrics()` method changed in LucoPy versions 1.3.3, 1.3.4, and 1.3.5. This was a potential breaking change for users.","severity":"breaking","affected_versions":"1.3.3 - 1.3.5"},{"fix":"Ensure environment variables like `LUCO_TENANT_ID`, `LUCO_CLIENT_ID`, `LUCO_CLIENT_SECRET`, `LUCO_RESOURCE_ID`, and `LUCO_BASE_URL` are set, or pass the corresponding values as arguments to the `LucoApi` constructor.","message":"LucoPy attempts to load authentication credentials (tenant ID, client ID, client secret, resource ID, base URL) from environment variables if not provided directly during `LucoApi` instantiation. Failure to set these or provide them as arguments will result in authentication errors.","severity":"gotcha","affected_versions":"All versions"}],"env_vars":null,"last_verified":"2026-04-16T00:00:00.000Z","next_check":"2026-07-15T00:00:00.000Z","problems":[{"fix":"Verify that all required authentication parameters are correctly provided to the `LucoApi` constructor, either directly or via the specified environment variables (e.g., `LUCO_BASE_ID`, `LUCO_TENANT_ID`, `LUCO_CLIENT_ID`, `LUCO_CLIENT_SECRET`, `LUCO_RESOURCE_ID`). Check for typos or expired secrets.","cause":"The `LucoApi` client could not obtain a valid authenticated access token to make API requests, usually due to missing or incorrect authentication parameters (`base_url`, `tenant_id`, `client_id`, `client_secret`, `resource_id`) during initialization, or invalid credentials.","error":"API call failed: Authentication token missing or invalid."},{"fix":"Update your `lucopy` package to version 1.3.6 or newer (`pip install --upgrade LucoPy`) to use the corrected method signature. Alternatively, if upgrading is not an option, review the specific return format for your exact `lucopy` version (1.3.3-1.3.5) and adjust your code accordingly.","cause":"This error occurs in LucoPy versions 1.3.3 to 1.3.5 because the return format of `Submission.get_metrics()` was changed.","error":"AttributeError or KeyError when accessing result from `api.submission.get_metrics()`."}]}