def test_instantiate_from_config(self): test_instance = instantiate_from_config('proso_tests', 'instantiate_ok.inner') self.assertIsNotNone(test_instance) self.assertEqual(test_instance.dummy, 'ok') with self.assertRaises(Exception): instantiate_from_config('proso_tests', 'instantiate') test_instance = instantiate_from_config( 'proso_tests', 'unknown', default_class='proso_common.config_test.TestClass', default_parameters={'dummy': 'ok'}) self.assertIsNotNone(test_instance) self.assertEqual(test_instance.dummy, 'ok')
def load_environment(self, info): return instantiate_from_config( 'proso_models', 'recompute_environment', default_class= 'proso_models.models.InMemoryDatabaseFlushEnvironment', pass_parameters=[info])
def get_option_selector(item_selector, options_number=None): if options_number is None: options_number = get_options_number() return instantiate_from_config( 'proso_models', 'option_selector', default_class='proso.models.option_selection.CompetitiveOptionSelection', pass_parameters=[item_selector, options_number] )
def get_item_selector(): cached = get_from_request_permenent_cache(ITEM_SELECTOR_CACHE_KEY) if cached is None: item_selector = instantiate_from_config( 'proso_models', 'item_selector', default_class='proso.models.item_selection.ScoreItemSelection', pass_parameters=[get_predictive_model()] ) nth = get_config('proso_models', 'random_test.nth') if nth is not None and nth > 0: item_selector = TestWrapperItemSelection(item_selector, nth) cached = item_selector set_to_request_permanent_cache(ITEM_SELECTOR_CACHE_KEY, cached) return cached
def get_option_set(): return instantiate_from_config( 'proso_flashcards', 'option_set', default_class='proso_flashcards.flashcard_construction.ContextOptionSet' )
def get_direction(): return instantiate_from_config( 'proso_flashcards', 'direction', default_class='proso_flashcards.flashcard_construction.RandomDirection' )
def load_environment(self, info): return instantiate_from_config( 'proso_models', 'recompute_environment', default_class='proso_models.environment.InMemoryDatabaseFlushEnvironment', pass_parameters=[info])
def get_options_number(): return instantiate_from_config( 'proso_models', 'options_count', default_class='proso.models.option_selection.AdjustedOptionsNumber' )
def get_environment(): return instantiate_from_config( 'proso_models', 'environment', default_class='proso_models.environment.DatabaseEnvironment', pass_parameters=[get_active_environment_info()['id']] )