Getting Started with Data Quality as Code
This guide will help you install the OpenMetadata Python SDK and configure authentication to start running data quality tests programmatically.Prerequisites
Before you begin, ensure you have:- Python 3.10 or higher installed
- pip package manager
- Access to an OpenMetadata instance (version 2.0.3 or later)
- A JWT token for authentication (see Authentication below)
Installation
The examples below target an OpenMetadata 2.0.3 server and allow ingestion package patch releases within2.0.3. For another server version, use the matching ingestion package version. Install the necessary connector extras for your use case:
Basic Installation
Installation with Database Connectors
Install additional dependencies based on the databases you’ll be testing:Installation with DataFrame Support
If you plan to use DataFrame validation features:Installation with Multiple Features
Combine multiple extras as needed:Authentication
Data Quality as Code requires authentication with your OpenMetadata instance. The SDK supports JWT token authentication.Getting a JWT Token
You can obtain a JWT token in two ways:Note: The Bots tile under Settings is only visible to users with Admin privileges. If you don’t see it, ask your organization’s OpenMetadata Admin to generate a bot token for you or grant you Admin access.
Option 1: Using an Existing Bot Token
OpenMetadata provides pre-configured bots like theingestion-bot:
- Log in to your OpenMetadata instance
- Navigate to Settings > Bots
- Find the ingestion-bot (or create a new bot)
- Copy the JWT token

Option 2: Creating a Custom Bot
For production use, create a dedicated bot with specific permissions:- Go to Settings > Bots
- Click Add Bot
- Provide a name and description
- Assign appropriate roles (typically
DefaultBotPolicyandIngestion Bot Policy) - Copy the generated JWT token
Configuring the SDK
Once you have a JWT token, configure the SDK in your Python code.Using Environment Variables
For better security, letconfigure pick them up from environment variables:
Configuration Parameters
Theconfigure() function accepts the following parameters:
Using External Secrets Managers
This section explains when and how to configure the SDK to work with an external secrets manager instead of database-stored credentials.Important Note
If your OpenMetadata instance uses database-stored credentials (the default configuration), you don’t need to follow this guide. The SDK will automatically retrieve and decrypt credentials. This guide is only necessary when your organization uses an external secrets manager for credential storage.Why This Is Required
TheTestRunner API executes data quality tests directly from your Python code (for example, within your ETL pipelines). To connect to your data sources, it needs to:
- Retrieve the service connection configuration from OpenMetadata
- Decrypt the credentials stored in your secrets manager
- Establish a connection to the data source
- Execute the test cases
General Setup Steps
-
Contact your OpenMetadata administrator to obtain:
- The secrets manager type (AWS, Azure, GCP, and so on)
- The secrets manager loader configuration
- Required environment variables or configuration files
- Any additional setup (IAM roles, service principals, and so on)
- Install required dependencies for your secrets manager provider
- Configure environment variables with access credentials
- Initialize the SecretsManagerFactory before using TestRunner
- Authenticate with an ingestion-bot JWT instead of a personal user token. See Authentication for how to obtain one.
- Configure the SDK
- Run your tests
Example Using AWS Secrets Manager
Required Dependencies:openmetadata-ingestion[mysql,snowflake]~=2.0.3.0. Make sure to use the same openmetadata-ingestion version as your OpenMetadata server version.
Example Configuration:
Configuration by Provider
Each provider needs its own dependency,SecretsManagerProvider value, and environment variables, listed below.
AWS Secrets Manager and AWS Systems Manager Parameter Store
OpenMetadata ingestion dependency: the baseopenmetadata-ingestion package includes the AWS secrets manager client libraries.
SecretsManagerProvider: (one of)
SecretsManagerProvider.awsSecretsManagerProvider.managed_awsSecretsManagerProvider.aws_ssmSecretsManagerProvider.managed_aws_ssm
AWS_ACCESS_KEY_IDAWS_SECRET_ACCESS_KEYAWS_DEFAULT_REGION
Azure Key Vault
OpenMetadata ingestion dependency: the baseopenmetadata-ingestion package includes the Azure Key Vault client libraries.
SecretsManagerProvider: (one of)
SecretsManagerProvider.azure_kvSecretsManagerProvider.managed_azure_kv
AZURE_CLIENT_IDAZURE_CLIENT_SECRETAZURE_TENANT_IDAZURE_KEY_VAULT_NAME
Google Cloud Secret Manager
OpenMetadata ingestion dependency: the baseopenmetadata-ingestion package includes the Google Cloud Secret Manager client libraries.
SecretsManagerProvider: SecretsManagerProvider.gcp
Environment variables:
GOOGLE_APPLICATION_CREDENTIALS: path to the credentials JSON fileGOOGLE_CLOUD_PROJECT
Troubleshooting
If you hit one of these errors while using an external secrets manager, check the matching cause and solution below.Error: “Cannot decrypt service connection”
Cause: Secrets manager not initialized or misconfigured Solution: EnsureSecretsManagerFactory is initialized before calling configure() or creating the TestRunner
Error: “SecretsManagerFactory settings don’t take effect”
Cause:SecretsManagerFactory is a singleton. Only the first call in a Python process takes effect. If configure(), TestRunner, or anything else from metadata.sdk runs first, the factory already initializes with defaults. This happens even if the first call comes through an earlier import. Later SecretsManagerFactory(...) calls are silently ignored.
Solution: Call SecretsManagerFactory(...) as the first SDK-related statement in your script. Restart the session if you’re in a long-running or interactive environment, such as a notebook, where the SDK might already have been used.
Error: “Access Denied” or “Unauthorized”
Cause: Insufficient permissions to access secrets Solution:- Verify IAM role/service principal has correct permissions
- Check credentials are valid and not expired
- Ensure correct region/vault name is specified
Error: “Module not found” for secrets manager
Cause: Missing dependencies for your secrets manager Solution: Install the base ingestion package that matches your OpenMetadata server version. Add connector-specific extras required by the service you test.Tests Fail with Connection Errors
Cause: Credentials not properly decrypted or secrets manager misconfigured Solution:- Verify secrets manager provider matches your OpenMetadata backend configuration
- Test credential access independently (for example, using AWS CLI, Azure CLI, or gcloud)
- Check network connectivity to secrets manager service
- Enable debug logging to see detailed error messages:
Contact Your Administrator
If you’re unsure about:- Which secrets manager your organization uses
- Required environment variables or configuration
- Access credentials or IAM roles
- Permissions needed
For More Information
- For more information about configuring a secrets manager for your OpenMetadata deployment, see Enable Secrets Manager.
- For provider-specific setup steps, see Supported implementations.
Verify Installation
Create a simple test to verify your setup:"your_service.database.schema.table" with the fully qualified name of an actual table in your OpenMetadata instance.
Your First Data Quality Test
Now that you’re set up, let’s run your first data quality test:Common Installation Issues
Connection Timeout
If you experience connection timeouts, verify:- OpenMetadata instance is running and accessible
- API URL is correct (should end with
/api) - Network connectivity between your script and OpenMetadata
- Firewall rules allow the connection
Import Errors
If you encounter import errors:Next Steps
Now that you have the SDK installed and configured:- Learn how to run table-level tests using the TestRunner API
- Explore DataFrame validation for ETL pipelines
- Review the complete test definitions reference