Skip to content

feat(client): add async function support to remote decorator#112

Merged
deanq merged 5 commits intomainfrom
deanq/ae-1469-bug-support-async-and-non-for-remote-decorator
Nov 14, 2025
Merged

feat(client): add async function support to remote decorator#112
deanq merged 5 commits intomainfrom
deanq/ae-1469-bug-support-async-and-non-for-remote-decorator

Conversation

@deanq
Copy link
Member

@deanq deanq commented Nov 14, 2025

Complements runpod-workers/flash#42

Support both def and async def function definitions in @Remote decorator.

Changes:

  • Modified AST parser to recognize both FunctionDef and AsyncFunctionDef nodes
  • Added textwrap.dedent() to handle indented function definitions
  • Updated client.py docstring with async/sync examples
  • Added comprehensive test suite for async function support

Fixes ValueError when wrapping async functions with @Remote decorator.

Support both `def` and `async def` function definitions in @Remote decorator.

Changes:
- Modified AST parser to recognize both FunctionDef and AsyncFunctionDef nodes
- Added textwrap.dedent() to handle indented function definitions
- Updated client.py docstring with async/sync examples
- Added comprehensive test suite for async function support

Fixes ValueError when wrapping async functions with @Remote decorator.
Support both `def` and `async def` function definitions in the `@remote` decorator.

Changes:
- Modified AST parser to recognize both FunctionDef and AsyncFunctionDef nodes
- Added textwrap.dedent() to handle indented function definitions
- Updated client.py docstring with async/sync examples
- Added comprehensive test suite for async function support

Fixes ValueError when wrapping async functions with the remote decorator.
…rator' of https://github.com/runpod/tetra-rp into deanq/ae-1469-bug-support-async-and-non-for-remote-decorator
@deanq deanq requested review from Copilot and jhcipar November 14, 2025 05:28
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR adds support for async function definitions to the @Remote decorator by updating the AST parser to recognize both FunctionDef and AsyncFunctionDef nodes. The changes fix a ValueError that occurred when wrapping async functions.

Key changes:

  • Modified AST parser to handle both sync and async function definitions
  • Added textwrap.dedent() to properly handle indented function definitions
  • Updated documentation with async/sync usage examples

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.

File Description
src/tetra_rp/stubs/live_serverless.py Updated AST parser to recognize both FunctionDef and AsyncFunctionDef nodes, added dedent for indented contexts
src/tetra_rp/client.py Updated docstring with async/sync examples and clarified function signature support
tests/unit/test_async_function_support.py Added comprehensive test suite covering sync/async functions, type hints, imports, and edge cases

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Fixes ValueError when using @Remote decorator with async functions by:
- Adding inspect.unwrap() to get original function from wrapper
- Supporting ast.AsyncFunctionDef in addition to ast.FunctionDef
- Adding early dedenting to handle functions defined in classes/methods

This enables proper source extraction for both sync and async decorated
functions, resolving the "Could not find function definition" error.
@deanq deanq merged commit b0222e0 into main Nov 14, 2025
7 checks passed
@deanq deanq deleted the deanq/ae-1469-bug-support-async-and-non-for-remote-decorator branch November 14, 2025 18:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants