code: def _create_docker_build_ctx(
      launch_project: LaunchProject,
      dockerfile_contents: str,
  ) -> str:
      """Create a build context temp dir for a Dockerfile and project code."""
      directory = tempfile.mkdtemp()
      dst_path = os.path.join(directory, "src")
      assert launch_project.project_dir is not None
      shutil.copytree(
          src=launch_project.project_dir,
          dst=dst_path,
          symlinks=True,
          ignore=shutil.ignore_patterns("fsmonitor--daemon.ipc"),
      )
      shutil.copy(
          os.path.join(
              os.path.dirname(__file__),
              "templates",
              "_wandb_bootstrap.py",
          ),
          os.path.join(directory),
      )
      if launch_project.python_version:
          runtime_path = os.path.join(dst_path, "runtime.txt")
          with open(runtime_path, "w") as fp:
              fp.write(f"python-{launch_project.python_version}")
      # TODO: we likely don't need to pass the whole git repo into the container
      # with open(os.path.join(directory, ".dockerignore"), "w") as f:
      #    f.write("**/.git")
      with open(
          os.path.join(directory, _GENERATED_DOCKERFILE_NAME), "w"
      ) as handle:
          handle.write(dockerfile_contents)
      return directory
  
imports: import hashlib
  import json
  import logging
  import os
  import shlex
  import shutil
  import sys
  import tempfile
  from typing import Any, Dict, List, Optional, Tuple
  import pkg_resources
  import yaml
  from dockerpycreds.utils import find_executable
  from six.moves import shlex_quote
  import wandb
  import wandb.docker
  import wandb.env
  from wandb.apis.internal import Api
  from wandb.sdk.launch.loader import builder_from_config, environment_from_config, registry_from_config
  from .._project_spec import EntryPoint, EntrypointDefaults, LaunchProject, fetch_and_validate_project
  from ..errors import ExecutionError, LaunchError
  from ..registry.abstract import AbstractRegistry
  from ..utils import AZURE_CONTAINER_REGISTRY_URI_REGEX, ELASTIC_CONTAINER_REGISTRY_URI_REGEX, GCP_ARTIFACT_REGISTRY_URI_REGEX, LAUNCH_CONFIG_FILE, LOG_PREFIX, event_loop_thread_exec, resolve_build_and_registry_config
label_desc: Use image node_id 12 for calling a global function with example usage: _create_docker_build_ctx(launch_project, dockerfile_contents) and returns: directory