CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/pypi-modal

Python 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.

85

1.60x
Overview
Eval results
Files

task.mdevals/scenario-6/

Execution Context Logger

A utility that demonstrates the difference between local and remote execution in Modal by logging execution context information.

Capabilities

Context Detection

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.

  • When run locally using the local entrypoint, it prints "Running in local context" @test
  • When the Modal function executes remotely, it logs the function call ID and input ID @test
  • The local entrypoint invokes the remote function and displays its return value @test

Implementation

@generates

API

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.
    """
    pass

Dependencies { .dependencies }

modal { .dependency }

Provides serverless cloud compute capabilities and execution context functions.

Install with Tessl CLI

npx tessl i tessl/pypi-modal

tile.json