heaptree-logo
Heaptree

Create Node

Provision one or more virtual machines

Signature

def create_node(
    num_nodes: int = 1,
    node_size: NodeSize = NodeSize.SMALL,
    lifetime_seconds: int = 330,
) -> CreateNodeResponse

Parameters

  • num_nodes (int) – number of nodes to create (default 1)
  • node_size (NodeSize) – SMALL, MEDIUM, or LARGE (default SMALL)
  • lifetime_seconds (int) – auto-termination after this many seconds (default 300 seconds)

Node Sizes

Available node sizes and their specifications:

  • SMALL - 1 vCPU and 1 GB of Memory
  • MEDIUM - 1 vCPU and 2 GB of Memory
  • LARGE - 2 vCPU and 4 GB of Memory

For more powerful compute options, please email heaptreehq@gmail.com.

Returns

CreateNodeResponse object which consists of:

  • node_id (str) – the nodeId of the created node (only use when num_nodes = 1)
  • node_ids (list[str]) – list of created node IDs
  • status (str) – operation status
  • execution_time_seconds (float) – time taken to create

Example

from heaptree import Heaptree
from heaptree.enums import NodeSize

client = Heaptree(api_key=API_KEY)

result = client.create_node(
    node_size=NodeSize.SMALL,
    lifetime_seconds=1800,
)
print(result.node_id)
print(result.execution_time_seconds)

Exceptions

  • MissingCredentialsException
  • UsageLimitsExceededException
  • InvalidRequestParametersException
  • InternalServerErrorException