Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 35 additions & 0 deletions flash/apps/deploy-apps.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -316,6 +316,41 @@ When one endpoint needs to call a function on another endpoint:

Each endpoint maintains its own connection to the state manager, querying for peer endpoint URLs as needed and caching results for 300 seconds to minimize API calls.

#### Calling another endpoint from your code

To call one endpoint from another, import the target endpoint function **inside** your function body. Flash automatically detects these imports and generates the necessary dispatch stubs.

For example, if you have a GPU worker for inference:

```python gpu_worker.py
from runpod_flash import Endpoint, GpuType

@Endpoint(
name="gpu-inference",
gpu=GpuType.NVIDIA_GEFORCE_RTX_4090,
dependencies=["torch"]
)
async def gpu_inference(payload: dict) -> dict:
import torch
# GPU inference logic
return {"result": "processed"}
```

You can call it from a CPU-based pipeline endpoint:

```python cpu_worker.py
from runpod_flash import Endpoint

@Endpoint(name="pipeline", cpu="cpu5c-4-8")
async def classify(text: str) -> dict:
# Import the GPU endpoint inside the function body
from gpu_worker import gpu_inference

# Flash routes this call to the gpu-inference endpoint
result = await gpu_inference({"text": text})
return {"classification": result}
```

## Troubleshooting

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Citation: This example documents the in-body import pattern that PR #224 fixes. The PR adds resolve_in_function_imports() and strip_remote_imports() to the dependency resolver, enabling the pattern shown in this code example where from gpu_worker import gpu_inference is used inside the function body for cross-endpoint dispatch.
View source

### No @Endpoint functions found
Expand Down
Loading