Serverless Functions
Run any Python Remotely
This guide will show you how to run powerful cloud functions with Beam.
Adding function decorators in Python
This tutorial introduces several key concepts:
- You can wrap any function in a
function()
decorator to run it on the cloud - You can invoke a function locally with
.local()
- You can invoke a function remotely with
.remote()
- You can fan out workloads to hundreds or thousands of containers with
.map()
View the Code
See the code for this example on Github.
Running the code remotely
In your shell, run this script by running this command. Make sure to replace app.py
with the name of your file.
Streaming remote logs
When you run this command, your code is containerized and shipped onto a server in the cloud, and the logs are streamed back to your local shell.
Scaling out to more containers
The .map()
method in main()
spawns 5 remote containers, but that number is arbitrary.
You can change 5
to 20
, and invoke this function again — you’ll see 20 containers spin up almost instantly.
Was this page helpful?