Errors and Diagnostics
All PyTRIO domain exceptions inherit from pytrio.PyTrioError, carrying a stable error code, remediation hint, and request trace ID for programmatic handling and logging.
python
import pytrio
try:
client = pytrio.ServiceClient()
training_client = client.create_lora_training_client(base_model="Qwen/Qwen3.5-4B")
except pytrio.PyTrioError as err:
print(err.code, err.message)
print(err.hint)
print(err.diagnostic_fields())Common Exceptions
| Exception | Module | Typical cause |
|---|---|---|
PyTrioError | pytrio / pytrio.errors.base | Base class for all PyTRIO exceptions |
ValidationError | pytrio.errors.base | Local input validation failure (invalid LoRA rank, empty batch, max_tokens <= 0, out-of-range token ID, checkpoint config mismatch, etc.) |
DependencyError | pytrio.errors.base | Missing optional dependency (such as torch for forward_backward_custom) |
AuthError | pytrio.errors.auth | Missing API key, invalid local config file, or authentication failure |
ConfigurationError | pytrio.errors.protocol | Invalid profile or environment variable setting |
SDKCompatibilityError | pytrio.errors.control | Current SDK version is too old; upgrade pytrio |
Server request and execution failures also raise subclasses of PyTrioError. Catch pytrio.PyTrioError and branch on err.code, err.status_code, and err.retryable.
Diagnostic Attributes
| Attribute / Method | Type | Description |
|---|---|---|
message | str | User-facing error summary |
code | str | Stable machine-readable code (e.g., validation.invalid_lora_rank, auth.missing_api_key, billing_insufficient_balance) |
hint | str | Suggested fix |
details | dict[str, object] | Structured error details (such as config mismatches or submission_unknown on create_batch) |
status_code | int | HTTP status code (0 for local errors) |
retryable | bool | Whether the operation can be safely retried |
request_id | str | Server request trace ID (useful when contacting support) |
diagnostic_fields() | dict[str, object] | Returns all non-empty diagnostic fields as a dictionary for structured logging |
Error Log File
To persist SDK ERROR logs to a local file (defaults to ~/.pytrio/error.log), call:
python
from pytrio.logging.setup import configure_error_file_logging
configure_error_file_logging() # writes to ~/.pytrio/error.log
configure_error_file_logging("./pytrio.log") # or a custom path