code: def load_experiment(args):
      """load experiment data"""
      package_path = os.path.expanduser(args.path)
      if not os.path.exists(args.path):
          print_error("file path %s does not exist!" % args.path)
          exit(1)
      if args.searchSpacePath and os.path.isdir(args.searchSpacePath):
          print_error(
              "search space path should be a full path with filename, not a directory!"
          )
          exit(1)
      temp_root_dir = generate_temp_dir()
      shutil.unpack_archive(package_path, temp_root_dir)
      print_normal("Loading...")
      # Step1. Validation
      if not os.path.exists(args.codeDir):
          print_error("Invalid: codeDir path does not exist!")
          exit(1)
      if args.logDir:
          if not os.path.exists(args.logDir):
              print_error("Invalid: logDir path does not exist!")
              exit(1)
      experiment_temp_dir = os.path.join(temp_root_dir, "experiment")
      if not os.path.exists(os.path.join(experiment_temp_dir, "db")):
          print_error("Invalid archive file: db file does not exist!")
          shutil.rmtree(temp_root_dir)
          exit(1)
      nnictl_temp_dir = os.path.join(temp_root_dir, "nnictl")
      if not os.path.exists(
          os.path.join(nnictl_temp_dir, ".experiment")
      ):
          print_error(
              "Invalid archive file: nnictl metadata file does not exist!"
          )
          shutil.rmtree(temp_root_dir)
          exit(1)
      try:
          with open(
              os.path.join(nnictl_temp_dir, ".experiment"), "r"
          ) as file:
              experiment_metadata = json.load(file)
      except ValueError as err:
          print_error("Invalid nnictl metadata file: %s" % err)
          shutil.rmtree(temp_root_dir)
          exit(1)
      experiments_config = Experiments()
      experiments_dict = experiments_config.get_all_experiments()
      experiment_id = experiment_metadata.get("id")
      if experiment_id in experiments_dict:
          print_error("Invalid: experiment id already exist!")
          shutil.rmtree(temp_root_dir)
          exit(1)
      if not os.path.exists(
          os.path.join(nnictl_temp_dir, experiment_id)
      ):
          print_error("Invalid: experiment metadata does not exist!")
          shutil.rmtree(temp_root_dir)
          exit(1)
  
      # Step2. Copy nnictl metadata
      src_path = os.path.join(nnictl_temp_dir, experiment_id)
      dest_path = os.path.join(NNI_HOME_DIR, experiment_id)
      if os.path.exists(dest_path):
          shutil.rmtree(dest_path)
      shutil.copytree(src_path, dest_path)
  
      # Step3. Copy experiment data
      os.rename(
          os.path.join(temp_root_dir, "experiment"),
          os.path.join(temp_root_dir, experiment_id),
      )
      src_path = os.path.join(
          os.path.join(temp_root_dir, experiment_id)
      )
      experiment_config = Config(
          experiment_id, temp_root_dir
      ).get_config()
      if args.logDir:
          logDir = args.logDir
          experiment_config["logDir"] = logDir
      else:
          if experiment_config.get("logDir"):
              logDir = experiment_config["logDir"]
          else:
              logDir = NNI_HOME_DIR
  
      dest_path = os.path.join(logDir, experiment_id)
      if os.path.exists(dest_path):
          shutil.rmtree(dest_path)
      shutil.copytree(src_path, dest_path)
  
      # Step4. Copy code dir
      codeDir = os.path.expanduser(args.codeDir)
      if not os.path.isabs(codeDir):
          codeDir = os.path.join(os.getcwd(), codeDir)
          print_normal("Expand codeDir to %s" % codeDir)
      experiment_config["trial"]["codeDir"] = codeDir
      archive_code_dir = os.path.join(temp_root_dir, "code")
      if os.path.exists(archive_code_dir):
          file_list = os.listdir(archive_code_dir)
          for file_name in file_list:
              src_path = os.path.join(archive_code_dir, file_name)
              target_path = os.path.join(codeDir, file_name)
              if os.path.exists(target_path):
                  print_error(
                      "Copy %s failed, %s exist!"
                      % (file_name, target_path)
                  )
                  continue
              if os.path.isdir(src_path):
                  shutil.copytree(src_path, target_path)
              else:
                  shutil.copy(src_path, target_path)
  
      # Step5. Create experiment metadata
      experiments_config.add_experiment(
          experiment_id,
          experiment_metadata.get("port"),
          experiment_metadata.get("startTime"),
          experiment_metadata.get("platform"),
          experiment_metadata.get("experimentName"),
          experiment_metadata.get("endTime"),
          experiment_metadata.get("status"),
          experiment_metadata.get("tag"),
          experiment_metadata.get("pid"),
          experiment_metadata.get("webUrl"),
          logDir,
      )
      print_normal("Load experiment %s succsss!" % experiment_id)
  
      # Step6. Cleanup temp data
      shutil.rmtree(temp_root_dir)
  
imports: import csv
  import os
  import sys
  import json
  import time
  import shutil
  import subprocess
  from functools import cmp_to_key
  import traceback
  from datetime import datetime, timezone
  from subprocess import Popen
  from .rest_utils import rest_get, rest_delete, check_rest_server_quick, check_response
  from .url_utils import trial_jobs_url, experiment_url, trial_job_id_url, export_data_url, metric_data_url
  from .config_utils import Config, Experiments
  from .constants import NNI_HOME_DIR, EXPERIMENT_INFORMATION_FORMAT, EXPERIMENT_DETAIL_FORMAT, EXPERIMENT_MONITOR_INFO, TRIAL_MONITOR_HEAD, TRIAL_MONITOR_CONTENT, TRIAL_MONITOR_TAIL, REST_TIME_OUT
  from .common_utils import print_normal, print_error, print_warning, detect_process, get_yml_content, generate_temp_dir
  from .common_utils import print_green
  from .command_utils import check_output_command, kill_command
  from .ssh_utils import create_ssh_sftp_client, remove_remote_directory
label_desc: Use image node_id 35 for calling a global function with example usage: load_experiment(args) without return types