Launchable CLI
Launchable CLI is a Python3 package that serves as the command-line interface to the Launchable test failure intelligence platform. It enables users to integrate their build tools and test runners with Launchable for features like predictive test selection, test suite parallelization, intelligent test failure diagnostics, and test trend analysis. The library is actively maintained, adhering to semantic versioning, with frequent updates to its '1.x' major release line.
Common errors
-
Error: 'launchable' command not found. or OSError: [Errno 2] No such file or directory: 'launchable'
cause The 'launchable' executable is not installed or not available in the system's PATH environment variable.fixEnsure the library is installed with `pip install launchable` and that your `~/.local/bin` (or equivalent) is in your PATH, or specify the full path to the `launchable` executable. -
Error: API key is not set. Please set LAUNCHABLE_TOKEN environment variable.
cause The `LAUNCHABLE_TOKEN` environment variable, required for authentication with the Launchable API, has not been set or is empty.fixSet the `LAUNCHABLE_TOKEN` environment variable with your Launchable API key. For example, `export LAUNCHABLE_TOKEN=your_api_key` in a shell, or configure it in your CI/CD system's secrets. -
ModuleNotFoundError: No module named 'launchable.client'
cause Attempting to `import` a non-existent internal module or assuming a direct Python SDK interface that is not publicly exposed for general use. The `launchable` package is primarily a CLI wrapper, not a traditional Python SDK with exposed high-level programmatic APIs.fixInteract with Launchable using the `launchable` command-line tool via `subprocess` calls in Python scripts, rather than attempting direct Python imports of non-public modules.
Warnings
- breaking Major version updates (e.g., from `1.x` to `2.x`) are explicitly stated to introduce drastic changes that break backward compatibility. Pin your dependency to `launchable~=1.0` for stability within the 1.x release line.
- gotcha The Launchable CLI requires a Java Runtime Environment (JRE) version 8 or newer to be installed and accessible in the system's PATH, even though the CLI itself is a Python package. This is a common oversight for Python-only environments.
- gotcha Authentication to the Launchable platform primarily relies on the `LAUNCHABLE_TOKEN` environment variable. If this is not set or is incorrect, CLI commands will fail with authentication errors. For open-source projects, tokenless authentication via GitHub OIDC requires specific GitHub Actions YAML configuration.
Install
-
pip install launchable -
pip install --user --upgrade launchable~=1.0
Imports
- launchable
import subprocess subprocess.run(['launchable', '--version'])
Quickstart
import os
import subprocess
# Replace with your actual Launchable API key or retrieve from environment
# For CI/CD, this is typically set as an environment variable (e.g., LAUNCHABLE_TOKEN)
api_key = os.environ.get('LAUNCHABLE_TOKEN', 'YOUR_LAUNCHABLE_API_KEY')
if not api_key or api_key == 'YOUR_LAUNCHABLE_API_KEY':
print("Warning: LAUNCHABLE_TOKEN environment variable not set. Using placeholder.")
print("Please set LAUNCHABLE_TOKEN for actual usage.")
# For demonstration, we'll proceed, but real usage requires a valid token
os.environ['LAUNCHABLE_TOKEN'] = api_key
try:
print("Verifying Launchable CLI configuration...")
result = subprocess.run(['launchable', 'verify'], capture_output=True, text=True, check=True)
print("Launchable CLI verification successful:")
print(result.stdout)
except subprocess.CalledProcessError as e:
print(f"Error verifying Launchable CLI: {e.stderr}")
print("Please ensure LAUNCHABLE_TOKEN is set correctly and Java 8+ is installed.")
except FileNotFoundError:
print("Error: 'launchable' command not found.")
print("Please ensure the Launchable CLI is installed and in your system's PATH.")