code: def test_travel(tmp_path, ignore_gitignore, monkeypatch):
      dir_paths = set()
      file_paths = set()
      item_num = 0
      excludes = []
      root = tmp_path / "test"
  
      if ignore_gitignore:
          monkeypatch.setenv(RAY_RUNTIME_ENV_IGNORE_GITIGNORE, "1")
      else:
          monkeypatch.delenv(
              RAY_RUNTIME_ENV_IGNORE_GITIGNORE, raising=False
          )
  
      def construct(path, excluded=False, depth=0):
          nonlocal item_num
          path.mkdir(parents=True)
          if not excluded:
              dir_paths.add(str(path))
          if depth > 8:
              return
          if item_num > 500:
              return
          dir_num = random.randint(0, 10)
          file_num = random.randint(0, 10)
          for _ in range(dir_num):
              uid = str(uuid.uuid4()).split("-")[0]
              dir_path = path / uid
              exclud_sub = random.randint(0, 5) == 0
              if not excluded and exclud_sub:
                  excludes.append(str(dir_path.relative_to(root)))
              if not excluded:
                  construct(dir_path, exclud_sub or excluded, depth + 1)
              item_num += 1
          if item_num > 1000:
              return
  
          for _ in range(file_num):
              uid = str(uuid.uuid4()).split("-")[0]
              v = random.randint(0, 1000)
              with (path / uid).open("w") as f:
                  f.write(str(v))
              if not excluded:
                  if random.randint(0, 5) == 0:
                      excludes.append(
                          str((path / uid).relative_to(root))
                      )
                  else:
                      file_paths.add((str(path / uid), str(v)))
              item_num += 1
  
          # Add gitignore file
          gitignore = root / ".gitignore"
          gitignore.write_text("*.pyc")
          file_paths.add((str(gitignore), "*.pyc"))
  
          # Add file that should be ignored by gitignore
          with (root / "foo.pyc").open("w") as f:
              f.write("foo")
          if ignore_gitignore:
              # If ignore_gitignore is True, then the file should be visited
              file_paths.add((str(root / "foo.pyc"), "foo"))
  
      construct(root)
      exclude_spec = _get_excludes(root, excludes)
      visited_dir_paths = set()
      visited_file_paths = set()
  
      def handler(path):
          if path.is_dir():
              visited_dir_paths.add(str(path))
          else:
              with open(path) as f:
                  visited_file_paths.add((str(path), f.read()))
  
      _dir_travel(root, [exclude_spec], handler)
      assert file_paths == visited_file_paths
      assert dir_paths == visited_dir_paths
  
imports: import os
  import random
  import shutil
  import socket
  import string
  import sys
  import tempfile
  import uuid
  from filecmp import dircmp
  from pathlib import Path
  from shutil import copytree, make_archive, rmtree
  import zipfile
  import ray
  import pytest
  from ray._private.gcs_utils import GcsAioClient
  from ray._private.ray_constants import KV_NAMESPACE_PACKAGE, RAY_RUNTIME_ENV_IGNORE_GITIGNORE
  from ray._private.runtime_env.packaging import GCS_STORAGE_MAX_SIZE, MAC_OS_ZIP_HIDDEN_DIR_NAME, Protocol, _dir_travel, _get_excludes, _store_package_in_gcs, download_and_unpack_package, get_local_dir_from_uri, get_top_level_dir_from_compressed_package, get_uri_for_directory, get_uri_for_package, is_whl_uri, is_zip_uri, parse_uri, remove_dir_from_filepaths, unzip_package, upload_package_if_needed, _get_gitignore, upload_package_to_gcs
  from ray.experimental.internal_kv import _initialize_internal_kv, _internal_kv_del, _internal_kv_exists, _internal_kv_get, _internal_kv_reset
label_desc: Use image node_id 7 for calling a global function with example usage: test_travel(tmp_path, ignore_gitignore, monkeypatch) without return types