class_docstr: A WBValue stored as a file outside JSON that can be rendered in a media panel.
  
  If necessary, we move or copy the file into the Run's media directory so that it
  gets uploaded.
class_docstr_tok: ["A","WBValue","stored","as","a","file","outside","JSON","that","can","be","rendered","in","a","media","panel",".","If","necessary",",","we","move","or","copy","the","file","into","the","Run","'s","media","directory","so","that","it","gets","uploaded","."]
docstr: Bind this object to a particular Run.
  
  Calling this function is necessary so that we have somewhere specific to put the
  file associated with this object, from which other Runs can refer to it.
docstr_tok: ["Bind","this","object","to","a","particular","Run",".","Calling","this","function","is","necessary","so","that","we","have","somewhere","specific","to","put","the","file","associated","with","this","object",",","from","which","other","Runs","can","refer","to","it","."]
code: def bind_to_run(
      self,
      run: "LocalRun",
      key: Union[int, str],
      step: Union[int, str],
      id_: Optional[Union[int, str]] = None,
      ignore_copy_err: Optional[bool] = None,
  ) -> None:
      """Bind this object to a particular Run.
  
      Calling this function is necessary so that we have somewhere specific to put the
      file associated with this object, from which other Runs can refer to it.
      """
      assert self.file_is_set(), "bind_to_run called before _set_file"
  
      if (
          SYS_PLATFORM == "Windows"
          and not util.check_windows_valid_filename(key)
      ):
          raise ValueError(
              f"Media {key} is invalid. Please remove invalid filename characters"
          )
  
      # The following two assertions are guaranteed to pass
      # by definition file_is_set, but are needed for
      # mypy to understand that these are strings below.
      assert isinstance(self._path, str)
      assert isinstance(self._sha256, str)
  
      assert run is not None, 'Argument "run" must not be None.'
      self._run = run
  
      if self._extension is None:
          _, extension = os.path.splitext(os.path.basename(self._path))
      else:
          extension = self._extension
  
      if id_ is None:
          id_ = self._sha256[:20]
  
      file_path = _wb_filename(key, step, id_, extension)
      media_path = os.path.join(self.get_media_subdir(), file_path)
      new_path = os.path.join(self._run.dir, media_path)
      filesystem.mkdir_exists_ok(os.path.dirname(new_path))
  
      if self._is_tmp:
          shutil.move(self._path, new_path)
          self._path = new_path
          self._is_tmp = False
          _datatypes_callback(media_path)
      else:
          try:
              shutil.copy(self._path, new_path)
          except shutil.SameFileError as e:
              if not ignore_copy_err:
                  raise e
          self._path = new_path
          _datatypes_callback(media_path)
  
imports: import hashlib
  import os
  import platform
  import re
  import shutil
  from typing import TYPE_CHECKING, Optional, Sequence, Type, Union, cast
  import wandb
  from wandb import util
  from wandb._globals import _datatypes_callback
  from wandb.sdk.lib import filesystem
  from wandb.sdk.lib.paths import LogicalPath
  from .wb_value import WBValue
label_desc: Use image node_id 7 for calling the Media obj's underlying member method code with example usage: obj.bind_to_run(run, key, step, id_, ignore_copy_err) without return types