API Reference¶
Welcome to the RHAPSODY API Reference. This section provides detailed documentation for all public APIs, classes, and functions in RHAPSODY.
Core Modules¶
rhapsody.backends¶
Backend implementations for different execution environments.
rhapsody.session¶
Session management for workflow orchestration.
rhapsody.tasks¶
Task definition and specification utilities.
rhapsody.config¶
Configuration management and utilities.
rhapsody.utils¶
Utility functions and helpers.
Quick Reference¶
Basic Usage¶
import rhapsody
from rhapsody.backends import Session
# Create session and get backend
session = Session()
backend = rhapsody.get_backend("dask")
# Define tasks
tasks = [
{
"uid": "example_task",
"executable": "echo",
"arguments": ["Hello, World!"]
}
]
# Submit and execute
backend = rhapsody.get_backend("dask")
await backend.submit_tasks(tasks)
### Common Patterns
#### Task Dependencies
```python
tasks = [
{"uid": "task_1", "executable": "echo", "arguments": ["step 1"]},
{"uid": "task_2", "executable": "echo", "arguments": ["step 2"],
"dependencies": ["task_1"]}
]
Error Handling¶
try:
await backend.submit_tasks(tasks)
await backend.wait()
except Exception as e:
print(f"Workflow failed: {e}")
Callbacks¶
def monitor_progress(task, state):
print(f"Task {task['uid']}: {state}")
backend.register_callback(monitor_progress)
API Index¶
Functions¶
get_backend()- Get a backend instanceregister_backend()- Register a custom backendlist_backends()- List available backends
Classes¶
Session- Workflow session managementBaseExecutionBackend- Base backend interfaceDaskExecutionBackend- Dask-based distributed executionRadicalExecutionBackend- RADICAL-Pilot HPC execution
Exceptions¶
RhapsodyError- Base exception classBackendError- Backend-specific errorsTaskError- Task execution errorsConfigurationError- Configuration errors
Type Definitions¶
RHAPSODY uses type hints throughout. Key type definitions:
from typing import Dict, List, Any, Optional, Callable
TaskDict = Dict[str, Any]
TaskList = List[TaskDict]
CallbackFunction = Callable[[TaskDict, str], None]
Configuration Schema¶
Task definition schema:
task:
uid: string # Required: Unique identifier
executable: string # Required: Command to execute
arguments: list # Optional: Command arguments
dependencies: list # Optional: Task UIDs this depends on
input_staging: list # Optional: Input files to stage
output_staging: list # Optional: Output files to collect
environment: dict # Optional: Environment variables
working_directory: string # Optional: Working directory
cpu_cores: integer # Optional: CPU cores required
gpu_cores: integer # Optional: GPU cores required
memory: string # Optional: Memory requirement (e.g., "4GB")
walltime: string # Optional: Maximum runtime (e.g., "1:00:00")
Version Information¶
Current Version: 0.1.0 Release Date: 2024 Source Code: GitHub Repository
API Stability¶
- Stable APIs: Core functionality is stable and backward compatible
- Experimental APIs: Marked with
@experimentaldecorator - Deprecated APIs: Will include deprecation warnings
Need Help?¶
- Getting Started - Quick start guide and tutorials
- GitHub Issues - Bug reports and questions
- Discussions - Community forum