Monte Carlo Python Client
The `montecarlodata` library provides a Python client for interacting with the Monte Carlo data observability platform. It allows users to programmatically manage metadata, incidents, and other aspects of their data environment. As of version 0.163.0, it offers a robust API wrapper. The library sees frequent updates, often multiple minor releases per week, indicating active development and continuous improvements.
Common errors
-
AttributeError: module 'montecarlodata' has no attribute 'MonteCarloClient'
cause Attempting to import `MonteCarloClient` directly from the `montecarlodata` package instead of its `client` submodule.fixChange your import statement from `from montecarlodata import MonteCarloClient` to `from montecarlodata.client import MonteCarloClient`. -
montecarlodata.errors.AuthenticationError: Invalid credentials provided
cause The API key or secret provided to the `MonteCarloClient` is either missing, incorrect, or expired.fixDouble-check your `MONTE_CARLO_API_KEY` and `MONTE_CARLO_API_SECRET` environment variables or the values passed directly to the client. Ensure they are valid and active within your Monte Carlo account.
Warnings
- breaking The client initialization method underwent significant changes around version `0.117.0`. Older versions might have used different parameter names or relied on implicit environment variables without direct passing. The current method requires `api_key` and `api_secret` to be passed explicitly to the `MonteCarloClient` constructor.
- gotcha Incorrect or missing API keys (`MONTE_CARLO_API_KEY`, `MONTE_CARLO_API_SECRET`) will prevent the client from authenticating and making successful API calls, leading to authentication errors.
Install
-
pip install montecarlodata
Imports
- MonteCarloClient
from montecarlodata import MonteCarloClient
from montecarlodata.client import MonteCarloClient
Quickstart
import os
from montecarlodata.client import MonteCarloClient
# It is highly recommended to store API keys securely in environment variables.
# Example: export MONTE_CARLO_API_KEY="your_key"
api_key = os.environ.get("MONTE_CARLO_API_KEY", "")
api_secret = os.environ.get("MONTE_CARLO_API_SECRET", "")
if not api_key or not api_secret:
print("Warning: MONTE_CARLO_API_KEY and MONTE_CARLO_API_SECRET environment variables are not set.")
print("Client initialization may fail without valid credentials.")
# For a runnable quickstart, we proceed, but real applications would raise an error.
try:
client = MonteCarloClient(api_key=api_key, api_secret=api_secret)
print("MonteCarloClient initialized successfully (credentials may be invalid).")
# Example: Attempt to list some catalogs. This will likely fail with invalid/missing keys.
# This demonstrates an API call but requires proper authentication and data setup.
# catalog_info = client.metadata.list_catalogs()
# print(f"Successfully fetched {len(catalog_info.items)} catalog entries.")
except Exception as e:
print(f"Error initializing MonteCarloClient or making an API call: {e}")
print("Please ensure your MONTE_CARLO_API_KEY and MONTE_CARLO_API_SECRET are correctly set.")