The easiest way to run code on the cloud
Project description
CloudInvoke
The easiest way to run code on the cloud with automatic dependency detection and file upload support.
Features
- Decorator-based remote execution: Simply add a decorator to run functions on the cloud
- Automatic dependency detection: Automatically detects and bundles required imports and helper functions
- File upload support: Automatically detects and uploads file dependencies
- Async execution: Support for fire-and-forget execution patterns
- Full stdout/stderr capture: See all output from remote execution
Installation
From PyPI (once published)
pip install cloudinvoke
From wheel file
pip install cloudinvoke-0.1.0-py3-none-any.whl
From source
git clone https://github.com/yourusername/cloudinvoke.git
cd cloudinvoke
pip install -e .
Quick Start
from cloudinvoke import CloudRunner
# Initialize the runner with your API credentials
runner = CloudRunner(
api_key="your_runpod_api_key",
endpoint_id="your_endpoint_id"
)
# Decorate functions to run them on the cloud
@runner.remote
def process_data(x, y):
import torch
# Your computation here
return x + y
# Call the function normally - it executes on the cloud
result = process_data(5, 3)
print(result) # 8
Usage
Basic Remote Execution
from cloudinvoke import CloudRunner
runner = CloudRunner(api_key="your_api_key")
@runner.remote
def my_function(x, y):
import numpy as np
return np.array([x, y]).sum()
result = my_function(10, 20)
print(result) # 30
Async Execution
For fire-and-forget patterns or when you want to submit multiple jobs:
@runner.remote_async
def long_running_task(n):
import time
time.sleep(n)
return f"Slept for {n} seconds"
# Returns immediately with a request ID
request_id = long_running_task(10)
# Get the result later
result = runner.get_result(request_id, wait=True)
print(result)
Automatic File Upload
CloudInvoke automatically detects file references in your code and uploads them:
@runner.remote
def process_csv():
import pandas as pd
# File is automatically uploaded and available
df = pd.read_csv('data.csv')
return df.shape[0]
result = process_csv()
Debug Mode
Enable debug mode to see the generated code and execution details:
runner = CloudRunner(
api_key="your_api_key",
debug=True # Enable debug output
)
@runner.remote
def test_function(x):
return x * 2
result = test_function(5)
# Prints the generated code, function name, args, etc.
Configuration
The CloudRunner class accepts the following parameters:
api_key(str, required): Your RunPod API keyendpoint_id(str): RunPod endpoint ID (default: "yv68hhady2hgii")base_url(str): Base URL for RunPod API (default: "https://api.runpod.ai/v2")poll_interval(float): Seconds between status polls (default: 1.0)timeout(int): Maximum seconds to wait for execution (default: 300)debug(bool): Print debug information (default: False)auto_upload_files(bool): Automatically detect and upload files (default: True)base_dir(str): Base directory for resolving file paths (default: '.')
How It Works
CloudInvoke analyzes your decorated functions to:
- Extract the function source code
- Recursively collect all dependencies (imports and helper functions)
- Detect file references in the code
- Bundle everything into a payload
- Submit to RunPod for execution
- Poll for results and return them
Requirements
- Python 3.7+
- requests>=2.25.0
Development
Building from source
# Install development dependencies
pip install -e ".[dev]"
# Run tests
pytest
# Build wheel
python -m build
Running tests
pytest tests/
License
MIT License - see LICENSE file for details
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
Support
For issues and questions, please use the GitHub issue tracker.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file cloudinvoke-0.1.1.tar.gz.
File metadata
- Download URL: cloudinvoke-0.1.1.tar.gz
- Upload date:
- Size: 12.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
82a56a41cff0d8e50db290bd056ec54d9be156b7127f4be461a8c3e503a101d1
|
|
| MD5 |
9d7a0f1fc65ce31c16479c82bc184667
|
|
| BLAKE2b-256 |
f2237ecb7f3b81ea1f9c89c625b5b6cb9494873cce010e9f8e013483d6726bac
|
File details
Details for the file cloudinvoke-0.1.1-py3-none-any.whl.
File metadata
- Download URL: cloudinvoke-0.1.1-py3-none-any.whl
- Upload date:
- Size: 9.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8ac29f30bef9e8a2fa4d7988f7bd35ece76f69354f6330d415caacf1a6755d24
|
|
| MD5 |
14f51f8711b4b9ace3b4ddad1bfe5b6c
|
|
| BLAKE2b-256 |
d68749876f79a762f8a75c7aa57a5a9c43785d89322406a1b57e3af909a7368b
|