Skip to main content

Heaptree | Launch Virtual Machines With One Line of Code

Project description

What is Heaptree?

Heaptree lets you launch secure cloud instances with one line of code. Perfect for AI workloads, asynchronous tasks, or any application that needs on-demand compute.

Getting Started

1. Install the SDK

pip install htsdk

2. Login from your terminal

This opens your browser to sign in with GitHub/Google and automatically configures your API key.

heaptree login

This will:

  • Save your key to ~/.heaptree/config.json
  • Add HEAPTREE_API_KEY to your shell profile (e.g. ~/.zshrc)

Open a new terminal (or run source ~/.zshrc) for the environment change to take effect.

3. Create your first node

import os
from heaptree import Heaptree

# Initialize the client
client = Heaptree(api_key=os.getenv("HEAPTREE_API_KEY"))

# Create a new node
result = client.create_node(
    num_nodes=1,
    node_size="small"
)

print(f"Node created: {result.node_id}")

4. Use your node

# Run a command on the node
response = client.run_command(
    node_id=result.node_id,
    command="echo 'Hello from Heaptree!'"
)

# Clean up when done
client.terminate_node(result.node_id)

Local development (no PyPI)

Use any of the following to test changes locally without publishing to PyPI.

Option A: Run the CLI directly from source (no install)

cd /Users/jordanhilado/projects/heaptree/sdk
python -m heaptree.cli login

Option B: Editable install into your environment

cd /Users/jordanhilado/projects/heaptree/sdk

# (optional) create/activate a virtualenv or conda env
python -m venv .venv
source .venv/bin/activate
# conda alternative: conda activate heaptree

# ensure old installs don't shadow your local one
python -m pip uninstall -y htsdk heaptree || true

# install locally in editable mode
python -m pip install -e .

# run the CLI
heaptree login

Verify the local package is being used:

which heaptree
python -c "import heaptree, inspect; print(heaptree.__file__)"

Expected output paths should point inside .../projects/heaptree/sdk/....

Optional: Override platform URL

export HEAPTREE_PLATFORM_URL="https://staging.heaptree.com"
python -m heaptree.cli login

Optional: Reset local login state

rm -f ~/.heaptree/config.json

After a successful login that updates your shell profile, reload your shell:

source ~/.zshrc
echo "$HEAPTREE_API_KEY"

Switch back to the PyPI build later

python -m pip uninstall -y htsdk heaptree
python -m pip install htsdk

Updating the SDK

To update to the latest version of the SDK, run:

pip install --upgrade htsdk

Or use the shorthand:

pip install -U htsdk

To check your current SDK version:

pip show htsdk

Features

  • Node Management: Create, terminate, and manage cloud instances
  • File Operations: Upload and download files to/from nodes
  • Command Execution: Run commands remotely on your nodes
  • Multiple Node Support: Create and manage multiple nodes simultaneously

Install Python packages in Firecracker sandboxes

import os
from heaptree import Heaptree

client = Heaptree(api_key=os.getenv("HEAPTREE_API_KEY"))
node = client.create(
    lifetime_seconds=300,
    pip_install=["numpy", "boto3", "requests"]
)

Git in Firecracker nodes

from heaptree import Heaptree

client = Heaptree(api_key=os.getenv("HEAPTREE_API_KEY"))
node = client.create()

# Clone a public repo
node.git_clone(
    url="https://github.com/user/repo.git",
    path="workspace/repo"
)

# Clone with authentication (e.g., PAT)
node.git_clone(
    url="https://github.com/user/private-repo.git",
    path="workspace/private-repo",
    username="git",
    password="personal_access_token"
)

# Clone a specific branch
node.git_clone(
    url="https://github.com/user/repo.git",
    path="workspace/repo-branch",
    branch="develop"
)

# Get repo status
status = node.git_status("workspace/repo")
print(status.current_branch, status.ahead, status.behind)
for f in status.file_status:
    print(f.name, f.status)

# List branches
branches = node.git_branches("workspace/repo")
for b in branches.branches:
    print(b)

List files and directories in Firecracker nodes

from heaptree import Heaptree
import os

client = Heaptree(api_key=os.getenv("HEAPTREE_API_KEY"))
node = client.create()

# List files in a directory
files = node.list_files("workspace")

for file in files:
    print(f"Name: {file.name}")
    print(f"Is directory: {file.is_dir}")
    print(f"Size: {file.size}")
    print(f"Modified: {file.mod_time}")

Create directories with specific permissions

from heaptree import Heaptree
import os

client = Heaptree(api_key=os.getenv("HEAPTREE_API_KEY"))
node = client.create()

node.create_folder("workspace/new-dir", "755")

File permissions (set/get and recursive)

from heaptree import Heaptree
import os

client = Heaptree(api_key=os.getenv("HEAPTREE_API_KEY"))
node = client.create()

# Set file permissions
node.set_permissions("workspace/file.txt", "644")

# Get file permissions
file_info = node.get_permissions("workspace/file.txt")
print(f"Permissions: {file_info.permissions}")

# Set directory permissions recursively
node.set_directory_permissions_recursive("workspace/new-dir", "755")

API Reference

For complete SDK documentation, including all available methods, parameters, and examples, visit the official documentation:

📖 Heaptree Documentation

License

This project is licensed under the MIT License - see the LICENSE file for details.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

htsdk-0.1.0b12.tar.gz (22.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

htsdk-0.1.0b12-py3-none-any.whl (20.2 kB view details)

Uploaded Python 3

File details

Details for the file htsdk-0.1.0b12.tar.gz.

File metadata

  • Download URL: htsdk-0.1.0b12.tar.gz
  • Upload date:
  • Size: 22.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.11

File hashes

Hashes for htsdk-0.1.0b12.tar.gz
Algorithm Hash digest
SHA256 b4004535ec2797205636be0a58ad7f43b56ffb4ce711543f7964f8608f39a74d
MD5 f5f451226e6204c57a1f9e70da889bca
BLAKE2b-256 734b4a11233900e09977e4faa1164d5337970ee7b6ee36319aa2fcfbe35bba03

See more details on using hashes here.

File details

Details for the file htsdk-0.1.0b12-py3-none-any.whl.

File metadata

  • Download URL: htsdk-0.1.0b12-py3-none-any.whl
  • Upload date:
  • Size: 20.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.11

File hashes

Hashes for htsdk-0.1.0b12-py3-none-any.whl
Algorithm Hash digest
SHA256 f1da75acf06bc947179c5945465604dea3879cdff85253e833a430e91cd5f5e2
MD5 d8c5da415ffe90fa7bbc860ea316564a
BLAKE2b-256 fcc7abdf10b61ce6c43164fec0243a19514f7995a1fd9bc0df61b4a6dd1a4627

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page