code: def naive_test(args):
      """run naive integration test"""
      to_remove = [
          "tuner_search_space.json",
          "tuner_result.txt",
          "assessor_result.txt",
      ]
      to_remove = list(
          map(
              lambda file: osp.join(NAIVE_TEST_CONFIG_DIR, file),
              to_remove,
          )
      )
      remove_files(to_remove)
  
      proc = subprocess.run(
          ["nnictl", "create", "--config", args.config]
      )
      assert proc.returncode == 0, (
          "`nnictl create` failed with code %d" % proc.returncode
      )
  
      print("Spawning trials...")
  
      nnimanager_log_path = get_nni_log_path(EXPERIMENT_URL)
      current_trial = 0
  
      for _ in range(120):
          time.sleep(1)
  
          tuner_status = read_last_line(
              osp.join(NAIVE_TEST_CONFIG_DIR, "tuner_result.txt")
          )
          assessor_status = read_last_line(
              osp.join(NAIVE_TEST_CONFIG_DIR, "assessor_result.txt")
          )
          experiment_status = is_experiment_done(nnimanager_log_path)
  
          assert tuner_status != "ERROR", "Tuner exited with error"
          assert (
              assessor_status != "ERROR"
          ), "Assessor exited with error"
  
          if experiment_status:
              break
  
          if tuner_status is not None:
              for line in open(
                  osp.join(NAIVE_TEST_CONFIG_DIR, "tuner_result.txt")
              ):
                  if line.strip() == "ERROR":
                      break
                  trial = int(line.split(" ")[0])
                  if trial > current_trial:
                      current_trial = trial
                      print("Trial #%d done" % trial)
  
      assert experiment_status, "Failed to finish in 2 min"
  
      ss1 = json.load(
          open(osp.join(NAIVE_TEST_CONFIG_DIR, "search_space.json"))
      )
      ss2 = json.load(
          open(
              osp.join(NAIVE_TEST_CONFIG_DIR, "tuner_search_space.json")
          )
      )
      assert ss1 == ss2, "Tuner got wrong search space"
  
      tuner_result = set(
          open(osp.join(NAIVE_TEST_CONFIG_DIR, "tuner_result.txt"))
      )
      expected = set(
          open(
              osp.join(
                  NAIVE_TEST_CONFIG_DIR, "expected_tuner_result.txt"
              )
          )
      )
      # Trials may complete before NNI gets assessor's result,
      # so it is possible to have more final result than expected
      print("Tuner result:", tuner_result)
      print("Expected tuner result:", expected)
      assert tuner_result.issuperset(expected), "Bad tuner result"
  
      assessor_result = set(
          open(osp.join(NAIVE_TEST_CONFIG_DIR, "assessor_result.txt"))
      )
      expected = set(
          open(
              osp.join(
                  NAIVE_TEST_CONFIG_DIR, "expected_assessor_result.txt"
              )
          )
      )
      assert assessor_result == expected, "Bad assessor result"
  
      subprocess.run(["nnictl", "stop"])
      wait_for_port_available(8080, 10)
  
file_path: nni/test/training_service/nnitest/naive_test.py
imports: import sys
  import os.path
  import argparse
  import json
  import subprocess
  import sys
  import time
  import traceback
  from utils import is_experiment_done, get_experiment_id, get_nni_log_path, read_last_line, remove_files, setup_experiment, detect_port, wait_for_port_available
  from utils import GREEN, RED, CLEAR, EXPERIMENT_URL
label_desc: Use image node_id 1 for calling a global function with example usage: naive_test(args) without return types