class_docstr: Consume a trial by using it to initialize a black-box box to evaluate it.
  
  It uses an `Experiment` object to push an evaluated trial, if results are
  delivered to the worker process successfully.
  
  It forks another process which executes user's script with the suggested
  options. It expects results to be written in a **JSON** file, whose path
  has been defined in a special orion environmental variable which is set
  into the child process' environment.
  
  Parameters
  ----------
  experiment: `orion.core.worker.experiment.Experiment`
      Manager of this experiment, provides convenient interface for interacting with
      the database.
  
  heartbeat: int, optional
      Frequency (seconds) at which the heartbeat of the trial is updated.
      If the heartbeat of a `reserved` trial is larger than twice the configured
      heartbeat, Oríon will reset the status of the trial to `interrupted`.
      This allows restoring lost trials (ex: due to killed worker).
      Defaults to ``orion.core.config.worker.heartbeat``.
  
  user_script_config: str, optional
      Config argument name of user's script (--config).
      Defaults to ``orion.core.config.worker.user_script_config``.
  
  interrupt_signal_code: int, optional
      Signal returned by user script to signal to Oríon that it was interrupted.
      Defaults to ``orion.core.config.worker.interrupt_signal_code``.
docstr: Set a few environment variables to allow users and
  underlying processes to know if they are running under orion.
  
  Parameters
  ----------
  results_file: str
     file used to store results, this is only used by the legacy protocol
  
  trial: Trial
     reference to the trial object that is going to be run
  
  Notes
  -----
  This function defines the environment variables described below
  
  .. envvar:: ORION_EXPERIMENT_ID
     :noindex:
  
     Current experiment that is being ran.
  
  .. envvar::  ORION_EXPERIMENT_NAME
     :noindex:
  
     Name of the experiment the worker is currently working on.
  
  .. envvar::  ORION_EXPERIMENT_VERSION
     :noindex:
  
     Version of the experiment the worker is currently working on.
  
  .. envvar:: ORION_TRIAL_ID
     :noindex:
  
     Current trial id that is currently being executed in this process.
  
  .. envvar:: ORION_WORKING_DIRECTORY
     :noindex:
  
     Trial's current working directory.
  
  .. envvar:: ORION_RESULTS_PATH
     :noindex:
  
     Trial's results file that is read by the legacy protocol to get the results of the trial
     after a successful run.
docstr_tok: ["Set","a","few","environment","variables","to","allow","users","and","underlying","processes","to","know","if","they","are","running","under","orion",".","Parameters","--","--","--","--","--","results_file",":","str","file","used","to","store","results",",","this","is","only","used","by","the","legacy","protocol","trial",":","Trial","reference","to","the","trial","object","that","is","going","to","be","run","Notes","--","--","-","This","function","defines","the","environment","variables","described","below","..","envvar",":",":","ORION_EXPERIMENT_ID",":","noindex",":","Current","experiment","that","is","being","ran",".","..","envvar",":",":","ORION_EXPERIMENT_NAME",":","noindex",":","Name","of","the","experiment","the","worker","is","currently","working","on",".","..","envvar",":",":","ORION_EXPERIMENT_VERSION",":","noindex",":","Version","of","the","experiment","the","worker","is","currently","working","on",".","..","envvar",":",":","ORION_TRIAL_ID",":","noindex",":","Current","trial","id","that","is","currently","being","executed","in","this","process",".","..","envvar",":",":","ORION_WORKING_DIRECTORY",":","noindex",":","Trial","'s","current","working","directory",".","..","envvar",":",":","ORION_RESULTS_PATH",":","noindex",":","Trial","'s","results","file","that","is","read","by","the","legacy","protocol","to","get","the","results","of","the","trial","after","a","successful","run","."]
code: def get_execution_environment(
      self, trial, results_file="results.log"
  ):
      """Set a few environment variables to allow users and
      underlying processes to know if they are running under orion.
  
      Parameters
      ----------
      results_file: str
         file used to store results, this is only used by the legacy protocol
  
      trial: Trial
         reference to the trial object that is going to be run
  
      Notes
      -----
      This function defines the environment variables described below
  
      .. envvar:: ORION_EXPERIMENT_ID
         :noindex:
  
         Current experiment that is being ran.
  
      .. envvar::  ORION_EXPERIMENT_NAME
         :noindex:
  
         Name of the experiment the worker is currently working on.
  
      .. envvar::  ORION_EXPERIMENT_VERSION
         :noindex:
  
         Version of the experiment the worker is currently working on.
  
      .. envvar:: ORION_TRIAL_ID
         :noindex:
  
         Current trial id that is currently being executed in this process.
  
      .. envvar:: ORION_WORKING_DIRECTORY
         :noindex:
  
         Trial's current working directory.
  
      .. envvar:: ORION_RESULTS_PATH
         :noindex:
  
         Trial's results file that is read by the legacy protocol to get the results of the trial
         after a successful run.
  
      """
      env = dict(os.environ)
      env["ORION_EXPERIMENT_ID"] = str(self.experiment.id)
      env["ORION_EXPERIMENT_NAME"] = str(self.experiment.name)
      env["ORION_EXPERIMENT_VERSION"] = str(self.experiment.version)
      env["ORION_TRIAL_ID"] = str(trial.id)
  
      env["ORION_WORKING_DIR"] = str(trial.working_dir)
      env["ORION_RESULTS_PATH"] = str(results_file)
      env["ORION_INTERRUPT_CODE"] = str(self.interrupt_signal_code)
  
      return env
  
imports: import copy
  import json
  import logging
  import os
  import subprocess
  import tempfile
  import orion.core
  from orion.core.io.convert import JSONConverter
  from orion.core.io.orion_cmdline_parser import OrionCmdlineParser
  from orion.core.io.resolve_config import infer_versioning_metadata
  from orion.core.utils.exceptions import BranchingEvent, InexecutableUserScript, MissingResultFile
label_desc: Use image node_id 4 for calling the Consumer obj's underlying member method code with example usage: obj.get_execution_environment(trial, results_file) and returns: env