tessl install tessl/pypi-modal@1.1.0Python client library for Modal, a serverless cloud computing platform that enables developers to run Python code in the cloud with on-demand access to compute resources.
Agent Success
Agent success rate when using this tile
85%
Improvement
Agent success rate improvement when using this tile compared to baseline
1.6x
Baseline
Agent success rate without this tile
53%
A utility that demonstrates the difference between local and remote execution in Modal by logging execution context information.
Write a program that uses Modal execution context functions to detect and log whether code is running in a local or remote environment. The program should run a simple function both locally and remotely, logging execution details.
@generates
import modal
app = modal.App("context-logger")
@app.function()
def log_context(message: str) -> dict:
"""
A Modal function that logs execution context information.
Args:
message: A message to include in the log
Returns:
A dictionary containing:
- 'is_local': Boolean indicating if running locally
- 'message': The input message
- 'function_call_id': The function call ID (or None if local)
- 'input_id': The input ID (or None if local)
"""
pass
@app.local_entrypoint()
def main():
"""
Local entrypoint that demonstrates the difference between
local and remote execution contexts.
"""
passProvides serverless cloud compute capabilities and execution context functions.