Updating Python Modules
This document provides guidance on migrating from the Protegrity AI Developer Edition to the Protegrity AI Team Edition (Cloud Protectors) using the Python SDK.
Prerequisites
- Install and set up the Protegrity Provisioned Cluster (PPC) and AI Team Edition using the steps from the PPC documentation and the respective feature documentation.
- Install and set up a compatible Cloud Protector for Protegrity AI Team Edition.
Move to Protegrity AI Team Edition using one of the following approaches:
- CLI tool: For an automated CLI-based migration, refer to Using the CLI tool.
- Python SDK: To migrate manually using the AI Team Edition Python SDK, refer to Using the Python SDK of AI Team Edition.
Scenario 1: Using the CLI Tool
Protegrity AI Developer Edition version 1.2.0 includes a CLI to make the Protegrity AI Developer Edition (DE) → Protegrity AI Team Edition (TE) transition mechanical rather than manual. Install the Python package and use the CLI tool to verify the migration and to create the required policies on PPC.
Set Team Edition environment variables for the SDK on the application host:
export PTY_CP_HOST=<your-cloud-protect-invoke-url> export PTY_AUTH_MODE=aws_iam # or cognito, bearer_token, mtls, noneSet PPC credentials. This is used by both
checkandcreate-policy:export PTY_PPC_HOST=<your-ppc-host> export PTY_PPC_PASSWORD=<admin-password>Both commands also accept
--ppc-host <host>and--ppc-password <password>flags if you prefer to pass them explicitly per invocation. Environment variables are recommended to keep credentials out of shell history.As an alternative, every
pty-migrateand SDK setting can also reside in~/.protegrity/config.yaml. The resolution order: CLI flag > env var > YAML file > default. Storing passwords in the file requiresallow_secrets_in_file: trueANDchmod 600on the file. This is the same model as~/.pgpass. For the full key list, refer toconfig.yaml.templatein theprotegrity-ai-developer-pythonpackage.Run a readiness check to view any missing requirements:
pty-migrate checkBy default, this verifies only the data elements and users present in the local usage stats. Add
--fullto verify the entire bundled Protegrity AI Developer Edition policy instead.The output lists each item, such as the SDK version, endpoint reachability, PPC data elements, datastore export key, and role members, with
✓or✗and a concrete remediation command for anything missing.Deploy the policy to PPC. This is only needed the first time, or after a PPC reset:
pty-migrate create-policyBy default, the CLI deploys only the data elements that usage stats show are used. Add
--fullto deploy the complete bundled Developer Edition policy. This is recommended for QA, training, or demo environments that should mirror Protegrity AI Developer Edition.Register the datastore export key so the Policy Agent can sync the policy to Cloud Protect. The exact
curlcommand with the right datastore id is printed at the end ofcreate-policy. Supply the KMS public key (PEM); the fingerprint returned must matchPTY_DATASTORE_KEYon the Policy Agent Lambda.Trigger the Policy Agent Lambda or wait for its hourly schedule to push the policy from PPC to Cloud Protect.
Re-run
pty-migrate check. If required, add--fullif earlier deployed with--full. When every line shows✓, the application’s existingsample-app-protection.py/sample-app-protection.shcommands will work unchanged against Protegrity AI Team Edition with the samepolicy_userand samedata_elementnames.
Note: The same data elements, role names, and policy users you used in Protegrity AI Developer Edition, such as
superuser,admin,name,address,text,ccn, and so on, are preserved on Protegrity AI Team Edition bycreate-policy. No application code changes are required to switch environments.
Configuration Reference
All settings can be supplied using environment variables, a YAML file at ~/.protegrity/config.yaml (override path with PTY_CONFIG_FILE), or built-in defaults - resolved in that order. A starter template is available at config.yaml.template in the protegrity-ai-developer-python package.
# ~/.protegrity/config.yaml - keys mirror the PTY_* env vars but lowercased
protect_host: https://cp.example.com/pty
auth_mode: bearer_token
request_timeout: 30
max_retries: 3
# static_token: eyJhbGciOi... # see security note below
Note: Secret keys, such as
static_tokenandclient_secretare loaded from the YAML file. This is only if the file ischmod 600, that is, owner read/write only the same rulesshand~/.pgpassenforce. If the file is group-readable or world-readable, secret keys are dropped at load time and a warning is printed to stderr; non-secret keys still load normally. On Windows, the POSIX permission check is skipped.
| Environment variable | Purpose | Default |
|---|---|---|
PTY_CP_HOST | Cloud Protect endpoint URL (Protegrity AI Team Edition). | none |
PTY_AUTH_MODE | Force a specific auth mode: cognito, aws_iam, bearer_token, mtls, none. | auto-detect |
PTY_API_VERSION | Cloud Protect API version segment. | 1 |
PTY_REQUEST_TIMEOUT | Per-request HTTP timeout in seconds. | 30 |
PTY_MAX_RETRIES | Retries on transient failures (HTTP 429, 5xx, connection errors) with exponential backoff. 0 disables. | 3 |
PTY_STATIC_TOKEN | Bearer token for bearer_token mode. | none |
PTY_TOKEN_ENDPOINT, PTY_CLIENT_ID, PTY_CLIENT_SECRET | OAuth2 client-credentials token fetch for bearer_token mode. | none |
PTY_CLIENT_CERT, PTY_CLIENT_KEY, PTY_CA_CERT | mTLS material. | none |
PTY_CONFIG_FILE | Override the YAML config location. | ~/.protegrity/config.yaml |
DEV_EDITION_EMAIL, DEV_EDITION_PASSWORD, DEV_EDITION_API_KEY | Protegrity AI Developer Edition credentials, selects cognito mode. | none |
Usage Statistics
appython writes anonymous local counters, such as operation type, data element, and day, to ~/.protegrity/stats.json after every protect/unprotect/reprotect call. The file never leaves your machine and contains no payloads or credentials. Disable with PTY_DISABLE_USAGE_STATS=1.
Note:
PTY_PROTECT_HOSTfrom earlier 1.2.0 pre-releases was renamed toPTY_CP_HOSTto avoid confusion withPTY_PPC_*(Policy Console) variables. Update any scripts before upgrading.
The pty-migrate CLI
Installed automatically with the package.
Run the following three subcommands to help you create the required policies and migrate:
pty-migrate check # Pre-flight readiness validation
pty-migrate create-policy # Create the equivalent DE policy on your PPC
pty-migrate stats # View local usage statistics
pty-migrate checkvalidates SDK version,PTY_CP_HOST, auth credentials, and (optionally) round-trips a realprotectcall against your Cloud Protect endpoint. Run it once after exporting your env vars; it prints actionable hints for each missing piece.pty-migrate create-policytalks to your Protegrity Provisioned Cluster (PPC) usingPTY_PPC_HOST,PTY_PPC_USER,PTY_PPC_PASSWORD, andPTY_WORKBENCH_PASSWORD, then creates a TE policy whose data elements match the ones DE provided out of the box (ccn,ssn,name,email, …). It is safe to re-run this command.pty-migrate statsprints a per-data-element, per-day breakdown so you can size your TE deployment based on real DE usage.
Note: Storing PPC passwords in the YAML file is supported but off by default. To opt in, add
allow_secrets_in_file: trueto~/.protegrity/config.yamlandchmod 600the file; only then willppc_passwordandworkbench_passwordbe read from it. Without both,pty-migrateignores those keys and prints a remediation hint - the same model as~/.pgpassand~/.npmrc. CLI flags (--ppc-password) and env vars (PTY_PPC_PASSWORD) always take precedence and need no opt-in.
Scenario 2: Using the AP Python module of AI Team Edition
Note: When the policy is set up on the AI Team Edition, ensure that the same data elements added for the AI Developer Edition are used. For more information about the data elements policy, refer to Policy Definition.
If you use different data elements while creating the policy, then modify the data elements used in the AI Developer Edition accordingly before running the modules.
Select the venv where protegrity-ai-developer-python is installed.
Install Application Protector Python using the steps from the Application Protector Python documentation.
Note:
When prompted for the ESA IP address, enter the hostname of the PPC. Similarly, when prompted for the ESA listening port number, enter25400. This enables the protector to integrate with the PPC.
After installation, the AP Python module of AI Developer Edition is replaced with the AP Python module of AI Team Edition.Run the samples.
Feedback
Was this page helpful?