Comments (3)
Jason Davenport commented:
When dealing with a large number of runs, running into rate limits (HTTP 429 errors) is a common issue. Here are some strategies to handle this more efficiently:
- Batch Requests: Instead of querying histories sequentially, use batching to minimize the number of API calls.
- Retry Logic with Exponential Backoff: Implement a retry mechanism that waits for progressively longer periods before retrying a request.
- Throttle Requests: Implement a throttle mechanism to ensure you stay within the API rate limits.
Here’s an example implementation:
import wandbimport timeimport pandas as pdfrom wandb.apis.public import Apifrom requests.exceptions import HTTPErrorInitialize W&B APIapi = Api()Function to fetch history of a single run with retries and exponential backoffdef fetch_run_history(run, max_retries=5, backoff_factor=1):for attempt in range(max_retries):try:return run.history()except HTTPError as e:if e.response.status_code == 429:# Too many requests, wait before retryingwait = backoff_factor * (2 ** attempt)print(f"Rate limit exceeded. Retrying in {wait} seconds…")time.sleep(wait)else:raise eraise Exception("Max retries exceeded")Function to fetch histories of all runs in a projectdef fetch_all_histories(project_name, max_retries=5, backoff_factor=1, batch_size=100):runs = api.runs(project_name)histories = []for i in range(0, len(runs), batch_size): batch = runs[i:i + batch_size] for run in batch: try: history = fetch_run_history(run, max_retries, backoff_factor) histories.append((run.name, history)) except Exception as e: print(f"Failed to fetch history for run {run.name}: {e}")return historiesFetch all histories for the projectproject_name = "your_project_name"histories = fetch_all_histories(project_name)Combine histories into a single DataFramecombined_histories = []for run_name, history in histories:history['run_name'] = run_namecombined_histories.append(history)df_combined = pd.concat(combined_histories, ignore_index=True)Save to CSV or handle as neededdf_combined.to_csv("combined_histories.csv", index=False)
The fetch_run_history function includes a retry mechanism with exponential backoff. If a rate limit error (HTTP 429) occurs, it waits for a progressively longer time before retrying. The fetch_all_histories
function processes runs in batches to reduce the number of API calls made simultaneously. After fetching histories, they are combined into a single DataFrame.
This approach should help you download run histories more efficiently without excessively hitting API rate limits.
from wandb.
Jason Davenport commented:
Hi there, I wanted to follow up on this request. Please let us know if we can be of further assistance or if your issue has been resolved.
from wandb.
Related Issues (20)
- [Q] How to rename the specific logged metrics in the whole projects. HOT 4
- [Q] Fetch all projects and reports of a user HOT 6
- [Q] How to directly obtain a figure with grey grid background and manually set label name HOT 2
- [CLI]: TypeError: ModelCheckpoint.__init__() got an unexpected keyword argument 'options' HOT 1
- [App]: Overlapping Sweep Name Column and Status Column on Sweep List Page HOT 1
- [Feature]: Don't capture KeyboardInterrupt on sweeps HOT 1
- [Q] How to sweep parameters that is defined in config.yaml file HOT 5
- Cannot create datamodule HOT 4
- Feedback HOT 1
- [App]: Duplicate Runs in the Sweep with Parallel Agents HOT 7
- TypeError: __name__ must be set to a string object when using wandb.integration.openai.autolog HOT 1
- [Q] Transfer wandb-local data between servers HOT 5
- [langchain] WandbTracer incompatible with langchain V2 Tracer API HOT 6
- [Q] UnicodeDecodeError: 'utf-8' codec can't decode byte 0xf8 in position 0: invalid start byte HOT 11
- [App]: Please replace OS-specific _reflink_linux using FICLONE = 0x40049409 with Python-supported os.copy_file_range HOT 3
- [App]: Line plots not rendered correctly HOT 6
- [App]: I cannot see the query charts HOT 2
- [Q] Cant login, not authorized despite using the correct API key HOT 3
- [CLI]: ERROR Internal wandb error: file data was not synced When using sync_tensorboard with Jupyter notebook HOT 11
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from wandb.