code: def run_non_automatic_experiment(
      exp_config, aup_folder, user=None, eid=None, start=True
  ):
      """
      Non-automatic experiment pipeline, separated into a different function for unit test purposes
      :param exp_config: experiment configuration
      :type exp_config: dict
      :param aup_folder: the folder containing the .aup files
      :type aup_folder: str
      :param user: the username
      :type user: str
      :param eid: eid of the experiment, if re-running
      :type eid: int
      :param start: whether or not to start the experiment immediately
      :type start: bool
      """
      user = get_default_username(user)
      create_only = False
  
      exp_config["parameter_config"] = []
      connector = get_default_connector(auppath=aup_folder, log=logger)
      if "resource_args" in exp_config:
          resource_manager = get_resource_manager(
              exp_config["resource"],
              connector,
              n_parallel=1,
              auppath=aup_folder,
              maximize=True,
              **exp_config["resource_args"],
              workingdir=exp_config["workingdir"],
              script=exp_config["script"],
              one_shot=True,
          )
      else:
          resource_manager = get_resource_manager(
              exp_config["resource"],
              connector,
              n_parallel=1,
              auppath=aup_folder,
              maximize=True,
              workingdir=exp_config["workingdir"],
              script=exp_config["script"],
              one_shot=True,
          )
  
      if eid is None:
          if start is True:
              eid = resource_manager.connector.start_experiment(
                  user, exp_config["name"], json.dumps(exp_config)
              )
          else:
              eid = resource_manager.connector.create_experiment(
                  user, exp_config["name"], json.dumps(exp_config)
              )
              create_only = True
      else:
          resource_manager.connector.start_experiment_by_eid(eid)
      resource_manager.eid = eid
      resource_manager.save_model = False
  
      if "runtime_args" in exp_config:
          runtime_args = exp_config["runtime_args"]
      else:
          runtime_args = {}
      logger.info("Experiment %d is created" % eid)
      logger.debug("Experiment config is %s" % json.dumps(exp_config))
  
      if create_only:
          connector.close()
          return eid, None
  
      def _check_status():
          if connector is None or eid is None:
              logger.warning(
                  "Could not start thread for checking external experiment stopping requests."
              )
              return
          while True:
              try:
                  if connector.is_closed():
                      logger.debug("Closing down clean-up thread.")
                      return
                  status = connector.maybe_get_experiment_status(eid)
                  if status == "REQUEST_STOP":
                      return _thread.interrupt_main()
              except Exception as ex:
                  logger.critical(
                      "Error in clean-up thread: {}".format(ex)
                  )
              finally:
                  time.sleep(5)
  
      request_stop_thr = threading.Thread(target=_check_status)
      request_stop_thr.start()
  
      rid = resource_manager.get_available(user, exp_config["resource"])
      if rid is None:
          logger.warning("Not enough resources to run compression")
          return eid
  
      finished = False
  
      def update(score, jid):
          nonlocal finished
          if score == "ERROR":
              logger.fatal("Compression job {} failed".format(job.jid))
              resource_manager.finish_job(job.jid, None, "FAILED")
          else:
              logger.critical(
                  "Compression job {} finished successfully with result {}".format(
                      job.jid, score
                  )
              )
              resource_manager.finish_job(job.jid, score, "FINISHED")
          finished = True
  
      logger.info(
          "# Running one-time compression experiment {}".format(eid)
      )
      job_config = BasicConfig(**exp_config["compression"])
      job_config["save_model"] = True
      job_config["folder_name"] = "models_{}".format(eid)
      job = Job(
          exp_config["script"],
          job_config,
          exp_config["workingdir"],
          retries=0,
      )
  
      def _suspend(sig, frame):
          logger.fatal("Compression ended at user's request")
          resource_manager.suspend()
          resource_manager.finish_job(job.jid, None)
          resource_manager.finish(status="STOPPED")
          connector.close()
          if request_stop_thr is not None:
              request_stop_thr.join()
          sys.exit(1)
  
      signal.signal(signal.SIGINT, lambda x, y: _suspend(x, y))
  
      def _force_refresh(sig, frame):
          # currently useful for async resource manager timers
          resource_manager.refresh()
  
      signal.signal(signal.SIGUSR1, lambda x, y: _force_refresh(x, y))
  
      job.jid = resource_manager.connector.job_started(
          eid, rid, job_config
      )
      resource_manager.run_job(
          job, rid, exp_config, update, **runtime_args
      )
  
      def _finish_callback():
          nonlocal finished
          while not finished:
              time.sleep(1)
          resource_manager.finish(status="FINISHED")
          connector.close()
          if request_stop_thr is not None:
              request_stop_thr.join()
  
      return eid, _finish_callback
  
file_path: auptimizer/src/aup/compression/utils.py
imports: import json
  import logging
  import signal
  import sys
  import _thread
  import threading
  import time
  from ..EE.Resource import get_resource_manager
  from ..aup import BasicConfig
  from ..EE.Job import Job
  from ..utils import get_default_username, get_default_connector, check_missing_key
label_desc: Use image node_id 2 for calling a global function with example usage: run_non_automatic_experiment(exp_config, aup_folder, user, eid, start) and returns: eid,  _finish_callback, eid,  None, eid, _thread