def config(binder: inject.Binder) -> None: if c.use_memory_cache: instance = MemoryGameCacheAdapter() players = [Player('1', '1', None), Player('2', '2', None)] instance.add_new_game(Game(123, players, True, 0)) binder.bind(GameCacheInterface, instance) else: binder.bind(GameCacheInterface, DynamoGameCacheAdapter(c.game_dynamo_table))
def configuration(binder: inject.Binder): env = os.environ.get('ENV') or "dev" if env == "dev": binder.bind(TicketRepository, InMemoryTicketRepository()) binder.bind(AccountRepository, InMemoryAccountRepository()) elif env == "prod": pass elif env == "test": pass else: raise ValueError("Invalid env")
def dependencies(binder: inject.Binder) -> None: binder.bind(SuiteSplitService, None) binder.bind(GenTaskOptions, evg_expansions.gen_task_options()) binder.bind(EvergreenApi, RetryingEvergreenApi.get_api(config_file=evergreen_config)) binder.bind( GenerationConfiguration, GenerationConfiguration.from_yaml_file(GENERATE_CONFIG_FILE)) binder.bind( ResmokeProxyConfig, ResmokeProxyConfig(resmoke_suite_dir=DEFAULT_TEST_SUITE_DIR))
def conf(binder: Binder) -> None: binder.bind( FieldSolver, FieldSolverPyamgx if solver == 'amgx' else FieldSolverPyamg) if backend == 'cupy': import cupy binder.bind(ArrayOnGrid, ArrayOnGridCupy) binder.bind(numpy, cupy) else: binder.bind(ArrayOnGrid, ArrayOnGrid) binder.bind(numpy, numpy)
def inject_config(binder: inject.Binder) -> None: from users.application.repositories import UsersRepository, VolunteerProfilesRepository, \ SkillsRepository, OrganizationAreasRepository, OrganizationProfilesRepository from users.infrastructure.repositories import DjangoORMUsersRepository, \ DjangoORMVolunteerProfilesRepository, DjangoORMSkillsRepository, \ DjangoORMOrganizationAreasRepository, DjangoORMOrganizationProfilesRepository binder.bind(UsersRepository, DjangoORMUsersRepository()) binder.bind(VolunteerProfilesRepository, DjangoORMVolunteerProfilesRepository()) binder.bind(OrganizationProfilesRepository, DjangoORMOrganizationProfilesRepository()) binder.bind(SkillsRepository, DjangoORMSkillsRepository()) binder.bind(OrganizationAreasRepository, DjangoORMOrganizationAreasRepository())
def injection_config(binder: inject.Binder): binder.bind(plugins.PluginProxy, plugin_proxy) binder.bind(thread.ThreadManager, thread_manager) binder.bind(journal.JournalReader, journal_reader) for cls, obj in plugin_manager._plugins_cls_map.items(): binder.bind(cls, obj)
def configure(binder: inject.Binder) -> None: binder.bind(DbConfigProvider, DbConfigProvider(s.VAULT_DB_NAME)) binder.bind_to_constructor(Db, lambda: SqliteDb()) binder.bind_to_constructor(SqliteDb, lambda: SqliteDb()) print(s.DATA_PATH) binder.bind( DataRepo, S3DataRepo() if s.DATA_PATH.startswith("s3") else LocalDataRepo())
def check_and_bind(binder: Binder, cls: Type[T], ins: Union[Type[T], T]): exp = None try: is_sub = issubclass(ins, cls) except TypeError as e: is_sub = False exp = e try: is_ins = isinstance(ins, cls) except TypeError as e: is_ins = False exp = e if is_ins or is_sub: binder.bind(cls, ins) else: raise exp or TypeError( f"{ins} is neither subclass or instance of {cls}")
def dependencies(binder: inject.Binder) -> None: binder.bind( EvergreenApi, RetryingEvergreenApi.get_api( config_file=os.path.expanduser(options.evg_api_config))) binder.bind(TimeoutSettings, TimeoutSettings(start_date=start_date, end_date=end_date)) binder.bind(TimeoutOverrides, timeout_overrides) binder.bind( EvergreenProjectConfig, parse_evergreen_file(os.path.expanduser( options.evg_project_config))) binder.bind( ResmokeProxyService, ResmokeProxyService( run_options=f"--installDir={shlex.quote(options.install_dir)}") )
def config(binder: inject.Binder) -> None: binder.bind(RaidRepository, MySQLRaidRepository( application.config['DATABASE_URI'], application.config['METADATA'], application.config['RAID_TABLE'])) binder.bind(GangRepository, MySQLGangRepository( application.config['DATABASE_URI'], application.config['METADATA'], application.config['GANG_TABLE'])) binder.bind(OutlawRepository, MySQLOutlawRepository( application.config['DATABASE_URI'], application.config['METADATA'], application.config['OUTLAW_TABLE'])) binder.bind(MailNotifier, SMTPMailNotifier())
def config(binder: inject.Binder) -> None: binder.bind(PlayerCacheInterface, DynamoPlayerCacheAdapter(c.player_table)) binder.bind(GameCacheInterface, DynamoGameCacheAdapter(c.game_table)) binder.bind(GameQueueInterface, SQSGameQueueAdapter(c.match_queue_name))
def inject_config(binder: inject.Binder) -> None: # Queries binder.bind(queries.GettingRssPageQuery, orm_queries.ORMGettingRssPageQuery(session)) binder.bind(queries.GettingRssPagesQuery, orm_queries.ORMGettingRssPagesQuery(session)) # Repositories binder.bind(repositories.RssPageRepo, orm_repositories.RssPageRepo(session))
def test_bind_provider(self): provider = lambda: 123 binder = Binder() binder.bind_to_provider(int, provider) assert binder._bindings[int] is provider
def test_bind__duplicate_binding(self): binder = Binder() binder.bind(int, 123) self.assertRaisesRegexp(InjectorException, 'Duplicate binding', binder.bind, int, 456)
def configure(binder: inject.Binder) -> None: binder.bind(list, [1, 2, 3])
def test_bind_constructor__constructor_required(self): binder = Binder() self.assertRaisesRegex(InjectorException, "Constructor cannot be None", binder.bind_to_constructor, int, None)
def dependencies(binder: inject.Binder) -> None: binder.bind(EvgExpansions, evg_expansions) binder.bind( SuiteSplitConfig, evg_expansions.build_suite_split_config(start_date, end_date)) binder.bind(SplitStrategy, greedy_division) binder.bind(FallbackStrategy, round_robin_fallback) binder.bind(GenTaskOptions, evg_expansions.build_evg_config_gen_options()) binder.bind(EvergreenApi, RetryingEvergreenApi.get_api(config_file=evg_api_config)) binder.bind(EvergreenProjectConfig, parse_evergreen_file(evg_project_config)) binder.bind(GenerationConfiguration, GenerationConfiguration.from_yaml_file()) binder.bind(ResmokeProxyService, ResmokeProxyService(" ".join(resmoke_run_args)))
def inject_config(binder: inject.Binder) -> None: binder.bind(EmailGateway, DummyEmailGateway()) binder.bind(AuctionsRepository, DjangoORMAuctionsRepository())
def bind(binder: Binder) -> None: binder.bind_to_provider(TaskRepository, TaskRepository) binder.bind_to_provider(AuthenticationRepository, AuthenticationRepository)
def config(binder: inject.Binder) -> None: from .pdf2text import inject_configuration binder.install(inject_configuration)
def config(binder: inject.Binder) -> None: binder.bind(GameQueueInterface, SQSGameQueueAdapter(sqs_match_making_queue_name))
def configure(binder: inject.Binder) -> None: binder.bind(UsersRepository, users_repo_mock) binder.bind(VolunteerProfilesRepository, volunteer_profiles_repo_mock) binder.bind(RemoveUserOutputBoundary, remove_user_output_boundary_mock)
def test_bind_constructor(self): constructor = lambda: 123 binder = Binder() binder.bind_to_constructor(int, constructor) assert binder._bindings[int]._constructor is constructor
def dependencies(binder: inject.Binder) -> None: binder.bind( SuiteSplitConfig, evg_expansions.get_suite_split_config(start_date, end_date)) binder.bind(SplitStrategy, greedy_division) binder.bind(FallbackStrategy, round_robin_fallback) binder.bind(GenTaskOptions, evg_expansions.get_evg_config_gen_options(config_dir)) binder.bind(EvergreenApi, evg_api) binder.bind( GenerationConfiguration, GenerationConfiguration.from_yaml_file( under_test.GENERATE_CONFIG_FILE)) binder.bind(ResmokeProxyConfig, ResmokeProxyConfig(resmoke_suite_dir=test_suites_dir))
def test_bind(self): binder = Binder() binder.bind(int, 123) assert int in binder._bindings
def dependencies(binder: inject.Binder) -> None: evg_api = RetryingEvergreenApi.get_api(config_file=evg_api_config) binder.bind(SuiteSplitConfig, split_task_options) binder.bind(SplitStrategy, greedy_division) binder.bind(FallbackStrategy, round_robin_fallback) binder.bind(EvergreenProjectConfig, evg_conf) binder.bind(GenTaskOptions, gen_task_options) binder.bind(EvergreenApi, evg_api) binder.bind(GenerationConfiguration, GenerationConfiguration.from_yaml_file()) binder.bind( ResmokeProxyConfig, ResmokeProxyConfig(resmoke_suite_dir=DEFAULT_TEST_SUITE_DIR)) binder.bind(EvergreenFileChangeDetector, EvergreenFileChangeDetector(task_id, evg_api)) binder.bind(BurnInConfig, burn_in_config)
def storage_provider_config(binder: inject.Binder): binder.bind(Storage, Storage())
def dependencies(binder: inject.Binder) -> None: binder.bind(ResmokeProxyService, ResmokeProxyService())
def configure(binder: inject.Binder): binder.bind(HaxGlobalState, hax_state)
def dependencies(binder: inject.Binder) -> None: binder.bind(EvgExpansions, evg_expansions) binder.bind(EvergreenApi, RetryingEvergreenApi.get_api(config_file=evg_api_config)) binder.bind(EvergreenProjectConfig, parse_evergreen_file(EVERGREEN_FILE)) binder.bind(SelectedTestsClient, SelectedTestsClient.from_file(selected_tests_config)) binder.bind(SuiteSplitConfig, evg_expansions.build_suite_split_config(start_date, end_date)) binder.bind(SplitStrategy, greedy_division) binder.bind(FallbackStrategy, round_robin_fallback) binder.bind(GenTaskOptions, evg_expansions.build_gen_task_options()) binder.bind(GenerationConfiguration, GenerationConfiguration.from_yaml_file())
def config(binder: inject.Binder) -> None: binder.bind(PlayerCacheInterface, DynamoPlayerCacheAdapter(player_table_name))
def config(binder: inject.Binder): binder.bind(PostsRepository, post_repo_mock)