SDK for https://github.com/helixml/run-python-helix-app/
The run-python-helix-app
repository provides a Python SDK for interacting with the Helix platform. The SDK facilitates the execution of Python code within the Helix environment.
Usage
The SDK provides functionalities to:
Initialize a Helix session: This step establishes a connection to the Helix platform and sets up the necessary environment for code execution.
Run Python code: The SDK allows users to submit Python code snippets for execution within the Helix environment.
Retrieve results: After code execution, the SDK retrieves and returns the results generated by the Python code.
Options
The SDK offers various options to customize the code execution process. These options include:
Input data: Users can specify the input data required by the Python code.
Execution environment: The SDK allows users to define the specific Python environment (e.g., version, packages) within which the code should be executed.
Timeout: Users can set a timeout duration for the code execution.
Examples
Example 1: Basic Code Execution
from helix_sdk import Helix
# Initialize a Helix session
helix = Helix()
# Python code to execute
code = """
print("Hello from Helix!")
"""
# Execute the code
result = helix.run_code(code)
# Print the result
print(result)
Example 2: Code Execution with Input Data
from helix_sdk import Helix
# Initialize a Helix session
helix = Helix()
# Python code to execute
code = """
def sum_numbers(a, b):
return a + b
result = sum_numbers(10, 20)
print(result)
"""
# Input data for the code
input_data = {"a": 10, "b": 20}
# Execute the code with input data
result = helix.run_code(code, input_data=input_data)
# Print the result
print(result)
Example 3: Code Execution with Specific Environment
from helix_sdk import Helix
# Initialize a Helix session
helix = Helix()
# Python code to execute
code = """
import pandas as pd
df = pd.DataFrame({"A": [1, 2, 3], "B": [4, 5, 6]})
print(df)
"""
# Define the Python environment
environment = {"packages": ["pandas"]}
# Execute the code with the specified environment
result = helix.run_code(code, environment=environment)
# Print the result
print(result)