code: def test_check_existing_artifact_before_download(
      wandb_init, tmp_path, monkeypatch
  ):
      """Don't re-download an artifact if it's already in the desired location."""
      cache_dir = tmp_path / "cache"
      monkeypatch.setenv("WANDB_CACHE_DIR", str(cache_dir))
  
      original_file = tmp_path / "test.txt"
      original_file.write_text("hello")
      with wandb_init() as run:
          artifact = wandb.Artifact("art", type="dataset")
          artifact.add_file(original_file)
          run.log_artifact(artifact)
  
      # Download the artifact
      with wandb_init() as run:
          artifact_path = run.use_artifact("art:latest").download()
          assert os.path.exists(artifact_path)
  
      # Delete the entire cache
      shutil.rmtree(cache_dir)
  
      def fail_copy(src, dst):
          raise RuntimeError(
              f"Should not be called, attempt to copy from {src} to {dst}"
          )
  
      # Monkeypatch the copy function to fail
      monkeypatch.setattr(shutil, "copy2", fail_copy)
  
      # Download the artifact again; it should be left in place despite the absent cache.
      with wandb_init() as run:
          artifact_path = Path(
              run.use_artifact("art:latest").download()
          )
          file1 = artifact_path / "test.txt"
          assert file1.is_file()
          assert file1.read_text() == "hello"
  
imports: import os
  import platform
  import shutil
  import time
  from datetime import datetime, timedelta, timezone
  from pathlib import Path
  from typing import Callable, Optional
  import numpy
  import pytest
  import wandb
  from wandb import Api
  from wandb.sdk.artifacts.artifact import Artifact
  from wandb.sdk.artifacts.exceptions import ArtifactFinalizedError, WaitTimeoutError
  from wandb.sdk.artifacts.staging import get_staging_dir
  from wandb.sdk.wandb_run import Run
label_desc: Use image node_id 16 for calling a global function with example usage: test_check_existing_artifact_before_download(wandb_init, tmp_path, monkeypatch) without return types