code: def run(
      flow_script,
      r_functions,
      rds_file,
      metaflow_args,
      full_cmdline,
      r_paths,
      r_container_image,
      metaflow_r_version,
      r_version,
      r_version_code,
  ):
      global R_FUNCTIONS, R_PACKAGE_PATHS, RDS_FILE_PATH, R_CONTAINER_IMAGE, METAFLOW_R_VERSION, R_VERSION, R_VERSION_CODE
  
      R_FUNCTIONS = r_functions
      R_PACKAGE_PATHS = r_paths
      RDS_FILE_PATH = rds_file
      R_CONTAINER_IMAGE = r_container_image
      METAFLOW_R_VERSION = metaflow_r_version
      R_VERSION = r_version
      R_VERSION_CODE = r_version_code
  
      # there's some reticulate(?) sillyness which causes metaflow_args
      # not to be a list if it has only one item. Here's a workaround
      if not isinstance(metaflow_args, list):
          metaflow_args = [metaflow_args]
      # remove any reference to local path structure from R
      full_cmdline[0] = os.path.basename(full_cmdline[0])
      with NamedTemporaryFile(prefix="metaflowR.", delete=False) as tmp:
          tmp.write(to_bytes(flow_script))
      module = load_module_from_path("metaflowR", tmp.name)
      flow = module.FLOW(use_cli=False)
  
      from . import exception
      from . import cli
  
      try:
          cli.main(
              flow,
              args=metaflow_args,
              handle_exceptions=False,
              entrypoint=full_cmdline[: -len(metaflow_args)],
          )
      except exception.MetaflowException as e:
          cli.print_metaflow_exception(e)
          os.remove(tmp.name)
          os._exit(1)
      except Exception as e:
          import sys
  
          print(e)
          sys.stdout.flush()
          os.remove(tmp.name)
          os._exit(1)
      finally:
          os.remove(tmp.name)
  
file_path: metaflow/metaflow/R.py
imports: import os
  import sys
  from importlib import util, machinery
  from tempfile import NamedTemporaryFile
  from .util import to_bytes
label_desc: Use image node_id 12 for calling a global function with example usage: run(flow_script, r_functions, rds_file, metaflow_args, full_cmdline, r_paths, r_container_image, metaflow_r_version, r_version, r_version_code) without return types