Tool to download Weights & Biases (W&B) run logs to local JSON files.

class ml_research_tools.exp.wandb_downloader_tool.WandbDownloaderTool(services)[source]#

Bases: BaseTool

Tool for downloading W&B run logs to local JSON files.

Initialize the W&B downloader tool.

name: str = 'wandb-downloader'#
description: str = 'Download artifacts and runs from Weights & Biases'#
__init__(services)[source]#

Initialize the W&B downloader tool.

Return type:

None

classmethod add_arguments(parser)[source]#

Add tool-specific arguments to the parser.

Return type:

None

Parameters:

parser (ArgumentParser)

download_wandb_logs(entity, project, output_dir='wandb_logs', timeout=30, quiet=False, delete_outdated=True)[source]#

Download W&B logs for a specified project to local JSON files.

Parameters:
  • entity (str) – The W&B entity (username or team name)

  • project (str) – The W&B project name

  • output_dir (str) – Directory where log files will be saved

  • timeout (int) – API timeout in seconds

  • quiet (bool) – If True, suppress progress bar

  • delete_outdated (bool) – If True, delete logs for runs that no longer exist

Return type:

int

execute(config, args)[source]#

Execute the W&B log download with the provided arguments.

Parameters:

args (Namespace) – Parsed command-line arguments

Return type:

int

Returns:

Exit code (0 for success, non-zero for error)

static sanitize_filename(name)[source]#

Sanitize the run name to create a valid filename.

Parameters:

name (str) – The original run name

Return type:

str

Returns:

A sanitized string suitable for use as a filename

delete_outdated_logs(output_dir, current_run_ids)[source]#

Delete log files that do not correspond to any current run ID.

Parameters:
  • output_dir (str) – Directory containing log files

  • current_run_ids (Set[str]) – Set of valid run IDs from W&B

Return type:

int

Returns:

Number of files deleted

process_run(run, output_dir)[source]#

Process a single W&B run and save its history to a JSON file.

Parameters:
  • run (Run) – W&B run object

  • output_dir (str) – Directory where the log file will be saved

Return type:

None