heaptree-logo
Heaptree

Run Code

Execute source code on a remote node

Signature

def run_code(node_id: str, lang: Language, code: str) -> ExecutionResponseWrapper

Parameters

  • node_id (str) – target node
  • lang (Language) – PYTHON, JAVASCRIPT, TYPESCRIPT, or CPP
  • code (str) – source code to execute

Returns

ExecutionResponseWrapper with:

  • output – stdout text
  • error – stderr text (if any)
  • exit_code – process exit code
  • success – boolean convenience (exit_code == 0 and no error)
  • execution_time_seconds – time taken

Example

from heaptree.enums import Language

result = client.run_code(node_id, lang=Language.PYTHON, code="print('Hello')")
print(result.output)

Exceptions

  • MissingCredentialsException
  • InternalServerErrorException