Deploy Python API

The Deploy class and result models from praisonai-deploy

The Deploy class runs, inspects, and tears down a deployment from Python.

python
from praisonai_deploy import Deploy

deploy = Deploy.from_yaml("agents.yaml")
result = deploy.deploy()
status = deploy.status()
Diagram

Deploy

deploy

plan

status

doctor

destroy

Quick Start

  1. From a YAML file
    python
    from praisonai_deploy import Deploy
    
    deploy = Deploy.from_yaml("agents.yaml")
    result = deploy.deploy()
  2. From a config object
    python
    from praisonai_deploy import Deploy, DeployConfig, DeployType
    
    config = DeployConfig(type=DeployType.API)
    deploy = Deploy(config, agents_file="agents.yaml")
    result = deploy.deploy()

Methods

MethodReturnsDescription
Deploy.from_yaml(agents_file="agents.yaml")DeployBuild a Deploy from the deploy: section of a YAML file
Deploy(config, agents_file="agents.yaml")DeployBuild a Deploy from a DeployConfig object
deploy(background=False)DeployResultExecute the deployment
plan()dictReturn the planned configuration without deploying
status()DeployStatusReturn the current service state
doctor()DoctorReportRun readiness checks for the configured type
destroy(force=False)DestroyResultTear down the deployment

Result Models

Each operation returns a typed model.

DeployResult

FieldTypeDescription
successboolWhether the deployment succeeded
messagestrHuman-readable result message
urlOptional[str]Deployed service URL
errorOptional[str]Error message if it failed
metadataDict[str, Any]Additional metadata

DeployStatus

FieldTypeDefaultDescription
stateServiceState(required)running / stopped / pending / failed / not_found / unknown
urlOptional[str]NoneService URL/endpoint
messagestr""Status message
service_nameOptional[str]NoneService name
providerOptional[str]Noneapi / docker / <any registered provider>. Plugin providers surface here too, as their normalised name.
regionOptional[str]NoneDeployment region
healthyboolFalseWhether the service is healthy
instances_runningint0Running instances
instances_desiredint0Desired instances
created_atOptional[str]NoneCreation timestamp
updated_atOptional[str]NoneLast update timestamp
metadataDict[str, Any]{}Provider-specific metadata

DeployStatus.to_dict() returns a JSON-serialisable dictionary.


Programmatic APIs

The registry — not the CloudProvider enum — is the authority on what is deployable.

python
from praisonai_deploy import (
    CloudProvider,           # built-in constants (aws, azure, gcp, fly, railway, render)
    coerce_cloud_provider,   # validate a name against the registry
    list_cloud_providers,    # every deployable name (built-ins + plugins)
)
from praisonai_deploy.providers import CloudProviderRegistry
FunctionReturnsDescription
list_cloud_providers()list[str]Every deployable name now. Built-ins first (declaration order), plugins appended sorted.
coerce_cloud_provider(value)`CloudProvider \str`A CloudProvider member for built-ins, a normalised lowercase str for plugins. Raises ValueError with a registry-derived list on unknown names.
CloudProviderRegistry.default()CloudProviderRegistryThe shared registry. Use list_names(), register(name, cls), and resolve(name) for programmatic use.
python
from praisonai_deploy import list_cloud_providers, coerce_cloud_provider

print(list_cloud_providers())          # ['aws', 'azure', 'gcp', 'fly', 'railway', 'render', ...]
print(coerce_cloud_provider("AWS"))    # CloudProvider.AWS  (built-in keeps enum identity)
print(coerce_cloud_provider(" gcp "))  # CloudProvider.GCP  (stripped + lowercased)

DestroyResult

FieldTypeDescription
successboolWhether the destroy succeeded
messagestrResult message
resources_deletedList[str]Deleted resource identifiers
errorOptional[str]Error message if it failed
metadataDict[str, Any]Additional metadata

Common Patterns

Read the status as JSON.

python
from praisonai_deploy import Deploy

deploy = Deploy.from_yaml("agents.yaml")
status = deploy.status()
print(status.to_dict())

Plan before deploying.

python
from praisonai_deploy import Deploy

deploy = Deploy.from_yaml("agents.yaml")
print(deploy.plan())  # dict describing the planned deployment

Tear down when finished.

python
from praisonai_deploy import Deploy

deploy = Deploy.from_yaml("agents.yaml")
result = deploy.destroy(force=True)
print(result.resources_deleted)

Best Practices

Check success before reading url

DeployResult.url is only set when success is True. Branch on result.success first.

Use to_dict() for logs and APIs

DeployStatus.to_dict() returns plain JSON types, ready to serialise into logs or an HTTP response.

Import from praisonai_deploy

Use from praisonai_deploy import Deploy — the praisonai.deploy path is a compatibility shim only.


Related