Dataset:v1
id
question
ground_truth
notes
Hey I have a question about using wandb with fastapi in a prod environment. is it recommended to initialize wandb within a specific route function, ie
`@app.route('/')
def my_function():
wandb.init(...)
`
or should i initialize beforehand:
`wandb.init(...)
@app.route('/')
def my_function():
...`
I'm getting a long list of log items in the console and many of them are empty.
When integrating `wandb` (Weights & Biases) with a FastAPI application, it's important to consider the nature of your application and how you're using `wandb`. FastAPI is an asynchronous web framework, and initializing `wandb` within a route function could lead to multiple initializations if the route is hit multiple times, which is not ideal.
Here are some guidelines to help you decide where to place the `wandb.init()` call:
1. **One-time Initialization**: If you need to track metrics across ...
The answer clearly explains the recommended practices for integrating wandb with a FastAPI application, offering both one-time initialization at the application start and per-request initialization within a route function, if necessary. The answer also mentions the possible reasons for seeing many empty log items in the console, such as multiple initializations or incorrect usage within an asynchronous environment, which directly corresponds to the user's observations.
1–1 of 1