code: def stubtest_worker(
      testclass,
      experiment_name,
      runner_args,
      config_name,
      test_script,
      expected_output,
      script_args=[],
      queue=LocalQueue("test"),
      wait_for_experiment=True,
      delete_when_done=True,
      test_output=True,
      test_workspace=True,
  ):
      my_path = os.path.dirname(os.path.realpath(__file__))
      config_name = os.path.join(my_path, config_name)
      logger = logs.get_logger("stubtest_worker")
      logger.setLevel(10)
  
      queue.clean()
  
      with model.get_db_provider(model.get_config(config_name)) as db:
          try:
              db.delete_experiment(experiment_name)
          except Exception:
              pass
  
      os.environ["PYTHONUNBUFFERED"] = "True"
      p = subprocess.Popen(
          ["studio", "run"]
          + runner_args
          + [
              "--config=" + config_name,
              "--verbose=" + EXPERIMENT_VERBOSE_LEVEL,
              "--force-git",
              "--experiment=" + experiment_name,
              test_script,
          ]
          + script_args,
          stdout=subprocess.PIPE,
          stderr=subprocess.STDOUT,
          close_fds=True,
          cwd=my_path,
      )
  
      pout, _ = p.communicate()
  
      if pout:
          logger.debug("studio run output: \n" + sixdecode(pout))
          splitpout = sixdecode(pout).split("\n")
          experiments = [
              line.split(" ")[-1]
              for line in splitpout
              if "studio run: submitted experiment" in line
          ]
          logger.debug("added experiments: {}".format(experiments))
  
      db = model.get_db_provider(model.get_config(config_name))
      experiment_name = experiments[0]
  
      try:
          experiment = db.get_experiment(experiment_name)
          if wait_for_experiment:
              while (
                  not experiment or not experiment.status == "finished"
              ):
                  experiment = db.get_experiment(experiment_name)
  
          if test_output:
              with open(
                  db.get_artifact(experiment.artifacts["output"]), "r"
              ) as f:
                  data = f.read()
                  split_data = data.strip().split("\n")
                  print(data)
                  testclass.assertEqual(split_data[-1], expected_output)
  
          if test_workspace:
              check_workspace(testclass, db, experiment_name)
  
          if delete_when_done:
              retry(
                  lambda: db.delete_experiment(experiment_name),
                  sleep_time=10,
              )
  
          return db
  
      except Exception as e:
          print("Exception {} raised during test".format(e))
          print("worker output: \n {}".format(pout))
          print("Exception trace:")
          print(traceback.format_exc())
          raise e
  
imports: import unittest
  import os
  import shutil
  import tempfile
  import uuid
  import subprocess
  import time
  from timeout_decorator import timeout
  import traceback
  import numpy
  import glob
  from studio import model
  from studio.util import logs
  from studio.queues.local_queue import LocalQueue, get_local_queue_lock
  from studio.util.util import sixdecode, retry
  from studio.extra_util import has_aws_credentials
  from env_detect import on_gcp, on_aws
label_desc: Use image node_id 1 for calling a global function with example usage: stubtest_worker(testclass, experiment_name, runner_args, config_name, test_script, expected_output, script_args, queue, wait_for_experiment, delete_when_done, test_output, test_workspace) and returns: db