def test_raise_on_missing_attr(self): @dataclass class InvalidConfig: support_emails: List[str] with pytest.raises(AttributeError): bind(InvalidConfig, {"support_emails": ["something"], "api_key": "abcd"})
def test_forbid_unspecialized_generic(self): @dataclass class InvalidConfig: support_emails: List with pytest.raises(TypeError): bind(InvalidConfig, {"support_emails": ["something"]})
def test_bind_named_tuple( self, Config, config_dict, s3_settings_dict, sms_providers ): assert Config( config_dict["support_emails"], config_dict["api-key"], config_dict["timeout ms"], config_dict["pi"], [ Config.SMSServiceConfig( sms_providers[0]["host"], sms_providers[0]["port"], sms_providers[0]["username"], sms_providers[0]["password"], ) ], Config.S3Config( s3_settings_dict["default_bucket"], s3_settings_dict["default_region"], s3_settings_dict["max_item_size"], ), config_dict["accounts"], config_dict["backup_db_hostname"], config_dict["db-region"], config_dict["db-credentials"], ) == bind(Config, config_dict)
def load_repo_config(repo_path: Path) -> RepoConfig: config_path = repo_path / "feature_store.yaml" with open(config_path) as f: raw_config = yaml.safe_load(f) try: validate(raw_config, config_schema) return bind(RepoConfig, raw_config) except ValidationError as e: raise FeastConfigError(e.message, e.absolute_path, config_path)
def test_allow_missing_attr(self): class InvalidConfig(NamedTuple): support_emails: List[str] assert InvalidConfig(["something"]) == bind( InvalidConfig, {"support_emails": ["something"], "api_key": "abcd"}, raise_if_missing_attr=False, )
def load_repo_config(repo_path: Path) -> RepoConfig: with open(repo_path / "feature_store.yaml") as f: raw_config = yaml.safe_load(f) return bind(RepoConfig, raw_config)