parameters: (self, override_scenario=None)
return_statement: return self._scenario
docstring: once a scenario has been chosen for a request for an instance (coverage), we cannot change it
docstring_summary: once a scenario has been chosen for a request for an instance (coverage), we cannot change it
docstring_tokens: once a scenario has been chosen for a request for an instance ( coverage ) we cannot change it
function: def scenario(self, override_scenario=None):
          """
          once a scenario has been chosen for a request for an instance (coverage), we cannot change it
          """
          if hasattr(g, 'scenario') and g.scenario.get(self.name):
              return g.scenario[self.name]
  
          def replace_experimental_scenario(s):
              return 'distributed' if s == 'experimental' else s
  
          if override_scenario:
              logger = logging.getLogger(__name__)
              logger.debug('overriding the scenario for %s with %s', self.name, override_scenario)
              try:
                  # for the sake of backwards compatibility... some users may still be using experimental...
                  override_scenario = replace_experimental_scenario(override_scenario)
                  module = import_module('jormungandr.scenarios.{}'.format(override_scenario))
              except ImportError:
                  logger.exception('scenario not found')
                  abort(404, message='invalid scenario: {}'.format(override_scenario))
              scenario = module.Scenario()
              # Save scenario_name and scenario
              self._scenario_name = override_scenario
              self._scenario = scenario
              if not hasattr(g, 'scenario'):
                  g.scenario = {}
              g.scenario[self.name] = scenario
              return scenario
  
          instance_db = self.get_models()
          scenario_name = instance_db.scenario if instance_db else 'new_default'
          # for the sake of backwards compatibility... some users may still be using experimental...
          scenario_name = replace_experimental_scenario(scenario_name)
          if not self._scenario or scenario_name != self._scenario_name:
              logger = logging.getLogger(__name__)
              logger.info('loading of scenario %s for instance %s', scenario_name, self.name)
              self._scenario_name = scenario_name
              module = import_module('jormungandr.scenarios.{}'.format(scenario_name))
              self._scenario = module.Scenario()
  
          # we save the used scenario for future use
          if not hasattr(g, 'scenario'):
              g.scenario = {}
          g.scenario[self.name] = self._scenario
          return self._scenario
function_tokens: def scenario ( self , override_scenario = None ) : if hasattr ( g , 'scenario' ) and g . scenario . get ( self . name ) : return g . scenario [ self . name ] def replace_experimental_scenario ( s ) : return 'distributed' if s == 'experimental' else s if override_scenario : logger = logging . getLogger ( __name__ ) logger . debug ( 'overriding the scenario for %s with %s' , self . name , override_scenario ) try : # for the sake of backwards compatibility... some users may still be using experimental... override_scenario = replace_experimental_scenario ( override_scenario ) module = import_module ( 'jormungandr.scenarios.{}' . format ( override_scenario ) ) except ImportError : logger . exception ( 'scenario not found' ) abort ( 404 , message = 'invalid scenario: {}' . format ( override_scenario ) ) scenario = module . Scenario ( ) # Save scenario_name and scenario self . _scenario_name = override_scenario self . _scenario = scenario if not hasattr ( g , 'scenario' ) : g . scenario = { } g . scenario [ self . name ] = scenario return scenario instance_db = self . get_models ( ) scenario_name = instance_db . scenario if instance_db else 'new_default' # for the sake of backwards compatibility... some users may still be using experimental... scenario_name = replace_experimental_scenario ( scenario_name ) if not self . _scenario or scenario_name != self . _scenario_name : logger = logging . getLogger ( __name__ ) logger . info ( 'loading of scenario %s for instance %s' , scenario_name , self . name ) self . _scenario_name = scenario_name module = import_module ( 'jormungandr.scenarios.{}' . format ( scenario_name ) ) self . _scenario = module . Scenario ( ) # we save the used scenario for future use if not hasattr ( g , 'scenario' ) : g . scenario = { } g . scenario [ self . name ] = self . _scenario return self . _scenario