code: def test_partial_upload(tmp_dir, dvc, index, mocker):
      from dvc_objects.fs import generic
  
      tmp_dir.dvc_gen({"foo": "foo content"})
      baz = tmp_dir.dvc_gen({"bar": {"baz": "baz content"}})[0].outs[0]
  
      original = generic.transfer
      odb = dvc.cloud.get_remote_odb("upstream")
  
      def unreliable_upload(
          from_fs, from_info, to_fs, to_info, **kwargs
      ):
          on_error = kwargs["on_error"]
          assert on_error
          if isinstance(from_info, str):
              from_info = [from_info]
          else:
              from_info = list(from_info)
          if isinstance(to_info, str):
              to_info = [to_info]
          else:
              to_info = list(to_info)
          for i in range(len(from_info) - 1, -1, -1):
              from_i = from_info[i]
              to_i = to_info[i]
              if os.path.abspath(to_i) == os.path.abspath(
                  odb.get(baz.hash_info.value).path
              ):
                  if on_error:
                      on_error(from_i, to_i, Exception("stop baz"))
                  del from_info[i]
                  del to_info[i]
  
          return original(from_fs, from_info, to_fs, to_info, **kwargs)
  
      mocker.patch("dvc_objects.fs.generic.transfer", unreliable_upload)
      with pytest.raises(UploadError):
          dvc.push()
      assert not list(index.hashes())
  
file_path: dvc/tests/func/data/db/test_index.py
imports: import os
  import pytest
  from dvc.exceptions import DownloadError, UploadError
  from dvc.utils.fs import remove
  from dvc_data.hashfile.db import get_index
label_desc: Use image node_id 7 for calling a global function with example usage: test_partial_upload(tmp_dir, dvc, index, mocker) and returns: original