July 2, 2024
0.2.43
- Added
beam logs
command to stream logs to a local shell - Added custom timeouts for serves
- Added
env.is_remote()
to avoid import errors when running Beam apps locally - Signup for Beam V2 without a waitlist
Upgrade to the latest CLI:
pip install --upgrade beam-client
Stream Remote Logs with beam logs
To simplify remote debugging, you can now stream logs from a task, deployment, or a container directly to your shell.
Deployment
Streams logs for a deployment.
beam logs --deployment-id [DEPLOYMENT-ID]
You can find the deployment ID by running beam deployment list
.
$ beam logs --deployment-id 2089b5b5-9b2a-450e-9a56-a50d4f0a8d4c
Starting task worker[0]
Worker[0] ready
Running task <25156946-2c3a-4900-8a2c-568f162493a7>
Task completed <25156946-2c3a-4900-8a2c-568f162493a7>, took 3.4570693s
Spinning down taskqueue
Task
Streams logs for a task.
beam logs --task-id [TASK-ID]
You can find the task ID by running beam task list
.
Container
Streams logs for a container.
beam logs --container-id [CONTAINER-ID]
You can find the container ID by running beam container list
.
Set Custom Timeouts for beam serve
You can configure how long to keep your serve session connected with the --timeout
flag.
beam serve file.py:func --timeout 300
- Timeout value of 0 will use the default timeout
- Timeout value of -1 will remove the timeout and persist the container for as long as the user is connected
Manage Remote Imports with env.is_remote()
Typically, your apps that run on Beam will be using packages that you don’t have installed locally.
If your Beam app uses packages that aren’t installed locally, you’ll need to ensure your Python interpreter doesn’t try to load these packages locally.
Avoiding Import Errors
There are two ways to avoid import errors when using packages that aren’t installed locally.
Import Packages Inline
Importing packages inline is safe because the functions will only be invoked in the remote Beam environment that has these packages installed.
from beam import endpoint, Image
@endpoint(image=Image(python_packages=["torch", "pandas", "numpy"]))
def handler():
import torch
import pandas
import numpy
Use env.is_remote()
An alternative to using inline imports is to use a special check called env.is_remote()
to conditionally import packages only when inside the remote environment.
from beam import env
if env.is_remote():
import torch
import pandas
import numpy
This command checks whether the Python script is running remotely on Beam, and will only try to import the packages in its scope if it is.
While it might be tempting to use the env.is_remote()
flag for other logic
in your app, this command should only be used for package imports.
Bug Fixes
- Encrypted secret values no longer returned in
/task
status API - Fix nested list serialization in
**inputs
Was this page helpful?