code: def download_artifacts(
      obj,
      job_name,
      target_dir,
      dry_run,
      fetch,
      validate_patterns,
      task_filters,
  ):
      """Download build artifacts from GitHub releases"""
      output = obj["output"]
  
      # fetch the queue repository
      queue = obj["queue"]
      if fetch:
          queue.fetch()
  
      # query the job's artifacts
      job = queue.get(job_name)
  
      # create directory to download the assets to
      target_dir = Path(target_dir).absolute() / job_name
      target_dir.mkdir(parents=True, exist_ok=True)
  
      # download the assets while showing the job status
      def asset_callback(task_name, task, asset):
          if asset is not None:
              path = target_dir / task_name / asset.name
              path.parent.mkdir(exist_ok=True)
              if not dry_run:
                  import github3
  
                  max_n_retries = 5
                  n_retries = 0
                  while True:
                      try:
                          asset.download(path)
                      except (
                          github3.exceptions.GitHubException
                      ) as error:
                          n_retries += 1
                          if n_retries == max_n_retries:
                              raise
                          wait_seconds = 60
                          click.echo(f"Failed to download {path}")
                          click.echo(
                              f"Retry #{n_retries} after {wait_seconds}s"
                          )
                          click.echo(error)
                          time.sleep(wait_seconds)
                      else:
                          break
  
      click.echo("Downloading {}'s artifacts.".format(job_name))
      click.echo("Destination directory is {}".format(target_dir))
      click.echo()
  
      report = ConsoleReport(job, task_filters=task_filters)
      report.show(
          output,
          asset_callback=asset_callback,
          validate_patterns=validate_patterns,
      )
  
imports: from datetime import date
  from pathlib import Path
  import time
  import sys
  import click
  from .core import Config, Repo, Queue, Target, Job, CrossbowError
  from .reports import ChatReport, Report, ReportUtils, ConsoleReport, EmailReport, CommentReport
  from ..utils.source import ArrowSources
label_desc: Use image node_id 12 for calling a global function with example usage: download_artifacts(obj, job_name, target_dir, dry_run, fetch, validate_patterns, task_filters) without return types