def feature_view_list(ctx: click.Context): """ List all feature views """ repo = ctx.obj["CHDIR"] cli_check_repo(repo) store = FeatureStore(repo_path=str(repo)) table = [] for feature_view in [ *store.list_feature_views(), *store.list_request_feature_views(), *store.list_on_demand_feature_views(), ]: entities = set() if isinstance(feature_view, FeatureView): entities.update(feature_view.entities) elif isinstance(feature_view, OnDemandFeatureView): for backing_fv in feature_view.inputs.values(): if isinstance(backing_fv, FeatureView): entities.update(backing_fv.entities) table.append([ feature_view.name, entities if len(entities) > 0 else "n/a", type(feature_view).__name__, ]) from tabulate import tabulate print( tabulate(table, headers=["NAME", "ENTITIES", "TYPE"], tablefmt="plain"))
def serve_transformations_command(ctx: click.Context, port: int): """[Experimental] Start a the feature consumption server locally on a given port.""" repo = ctx.obj["CHDIR"] cli_check_repo(repo) store = FeatureStore(repo_path=str(repo)) store.serve_transformations(port)
def apply_total_command(): """ Create or update a feature store deployment """ cli_check_repo(Path.cwd()) repo_config = load_repo_config(Path.cwd()) apply_total(repo_config, Path.cwd())
def teardown_command(): """ Tear down deployed feature store infrastructure """ cli_check_repo(Path.cwd()) repo_config = load_repo_config(Path.cwd()) teardown(repo_config, Path.cwd())
def registry_dump_command(): """ Print contents of the metadata registry """ cli_check_repo(Path.cwd()) repo_config = load_repo_config(Path.cwd()) registry_dump(repo_config)
def teardown_command(repo_path: str): """ Tear down infra for a feature repo """ cli_check_repo(Path(repo_path)) repo_config = load_repo_config(Path(repo_path)) teardown(repo_config, Path(repo_path).resolve())
def apply_total_command(repo_path: str): """ Applies a feature repo """ cli_check_repo(Path(repo_path)) repo_config = load_repo_config(Path(repo_path)) apply_total(repo_config, Path(repo_path).resolve())
def serve_command(ctx: click.Context, host: str, port: int, no_access_log: bool): """Start a feature server locally on a given port.""" repo = ctx.obj["CHDIR"] cli_check_repo(repo) store = FeatureStore(repo_path=str(repo)) store.serve(host, port, no_access_log)
def registry_dump_command(ctx: click.Context): """ Print contents of the metadata registry """ repo = ctx.obj["CHDIR"] cli_check_repo(repo) repo_config = load_repo_config(repo) registry_dump(repo_config, repo_path=repo)
def teardown_command(ctx: click.Context): """ Tear down deployed feature store infrastructure """ repo = ctx.obj["CHDIR"] cli_check_repo(repo) repo_config = load_repo_config(repo) teardown(repo_config, repo)
def apply_total_command(): """ Create or update a feature store deployment """ cli_check_repo(Path.cwd()) repo_config = load_repo_config(Path.cwd()) try: apply_total(repo_config, Path.cwd()) except FeastProviderLoginError as e: print(str(e))
def registry_dump_command(): """ Print contents of the metadata registry """ cli_check_repo(Path.cwd()) repo_config = load_repo_config(Path.cwd()) tele = Telemetry() tele.log("registry-dump") registry_dump(repo_config, repo_path=Path.cwd())
def apply_total_command(ctx: click.Context, skip_source_validation: bool): """ Create or update a feature store deployment """ repo = ctx.obj["CHDIR"] cli_check_repo(repo) repo_config = load_repo_config(repo) try: apply_total(repo_config, repo, skip_source_validation) except FeastProviderLoginError as e: print(str(e))
def disable_alpha_features(ctx: click.Context): """ Disables all alpha features """ repo = ctx.obj["CHDIR"] cli_check_repo(repo) repo_path = str(repo) store = FeatureStore(repo_path=repo_path) store.config.flags = None store.config.write_to_path(Path(repo_path))
def feature_view_list(): """ List all feature views """ cli_check_repo(Path.cwd()) store = FeatureStore(repo_path=str(Path.cwd())) table = [] for feature_view in store.list_feature_views(): table.append([feature_view.name, feature_view.entities]) from tabulate import tabulate print(tabulate(table, headers=["NAME", "ENTITIES"], tablefmt="plain"))
def apply_total_command(ctx: click.Context): """ Create or update a feature store deployment """ repo = ctx.obj["CHDIR"] cli_check_repo(repo) repo_config = load_repo_config(repo) tele = Telemetry() tele.log("apply") try: apply_total(repo_config, repo) except FeastProviderLoginError as e: print(str(e))
def endpoint(ctx: click.Context): """ Display feature server endpoints. """ repo = ctx.obj["CHDIR"] cli_check_repo(repo) store = FeatureStore(repo_path=str(repo)) endpoint = store.get_feature_server_endpoint() if endpoint is not None: _logger.info( f"Feature server endpoint: {Style.BRIGHT + Fore.GREEN}{endpoint}{Style.RESET_ALL}" ) else: _logger.info("There is no active feature server.")
def on_demand_feature_view_list(ctx: click.Context): """ [Experimental] List all on demand feature views """ repo = ctx.obj["CHDIR"] cli_check_repo(repo) store = FeatureStore(repo_path=str(repo)) table = [] for on_demand_feature_view in store.list_on_demand_feature_views(): table.append([on_demand_feature_view.name]) from tabulate import tabulate print(tabulate(table, headers=["NAME"], tablefmt="plain"))
def enable_alpha_features(ctx: click.Context): """ Enables all alpha features """ repo = ctx.obj["CHDIR"] cli_check_repo(repo) repo_path = str(repo) store = FeatureStore(repo_path=repo_path) if store.config.flags is None: store.config.flags = {} for flag_name in flags.FLAG_NAMES: store.config.flags[flag_name] = True store.config.write_to_path(Path(repo_path))
def feature_view_list(ctx: click.Context): """ List all feature views """ repo = ctx.obj["CHDIR"] cli_check_repo(repo) store = FeatureStore(repo_path=str(repo)) table = [] for feature_view in store.list_feature_views(): table.append([feature_view.name, feature_view.entities]) from tabulate import tabulate print(tabulate(table, headers=["NAME", "ENTITIES"], tablefmt="plain"))
def materialize_incremental_command(end_ts: str, views: List[str]): """ Run an incremental materialization job to ingest new data into the online store. Feast will read all data from the previously ingested point to END_TS from the offline store and write it to the online store. If you don't specify feature view names using --views, all registered Feature Views will be incrementally materialized. END_TS should be in ISO 8601 format, e.g. '2021-07-16T19:20:01' """ cli_check_repo(Path.cwd()) store = FeatureStore(repo_path=str(Path.cwd())) store.materialize_incremental( feature_views=None if not views else views, end_date=datetime.fromisoformat(end_ts), )
def materialize_command(start_ts: str, end_ts: str, views: List[str]): """ Run a (non-incremental) materialization job to ingest data into the online store. Feast will read all data between START_TS and END_TS from the offline store and write it to the online store. If you don't specify feature view names using --views, all registered Feature Views will be materialized. START_TS and END_TS should be in ISO 8601 format, e.g. '2021-07-16T19:20:01' """ cli_check_repo(Path.cwd()) store = FeatureStore(repo_path=str(Path.cwd())) store.materialize( feature_views=None if not views else views, start_date=datetime.fromisoformat(start_ts), end_date=datetime.fromisoformat(end_ts), )
def entity_list(): """ List all entities """ cli_check_repo(Path.cwd()) store = FeatureStore(repo_path=str(Path.cwd())) table = [] for entity in store.list_entities(): table.append([entity.name, entity.description, entity.value_type]) from tabulate import tabulate print( tabulate(table, headers=["NAME", "DESCRIPTION", "TYPE"], tablefmt="plain"))
def list_alpha_features(ctx: click.Context): """ Lists all alpha features """ repo = ctx.obj["CHDIR"] cli_check_repo(repo) repo_path = str(repo) store = FeatureStore(repo_path=repo_path) flags_to_show = flags.FLAG_NAMES.copy() flags_to_show.remove(flags.FLAG_ALPHA_FEATURES_NAME) print("Alpha features:") for flag in flags_to_show: enabled_string = ("enabled" if flags_helper.feature_flag_enabled( store.config, flag) else "disabled") print(f"{flag}: {enabled_string}")
def disable_alpha_feature(ctx: click.Context, name: str): """ Disables an alpha feature """ if name not in flags.FLAG_NAMES: raise ValueError(f"Flag name, {name}, not valid.") repo = ctx.obj["CHDIR"] cli_check_repo(repo) repo_path = str(repo) store = FeatureStore(repo_path=repo_path) if store.config.flags is None or name not in store.config.flags: return store.config.flags[name] = False store.config.write_to_path(Path(repo_path))
def feature_view_describe(name: str): """ Describe a feature view """ cli_check_repo(Path.cwd()) store = FeatureStore(repo_path=str(Path.cwd())) try: feature_view = store.get_feature_view(name) except FeastObjectNotFoundException as e: print(e) exit(1) print( yaml.dump(yaml.safe_load(str(feature_view)), default_flow_style=False, sort_keys=False))
def entity_describe(name: str): """ Describe an entity """ cli_check_repo(Path.cwd()) store = FeatureStore(repo_path=str(Path.cwd())) try: entity = store.get_entity(name) except FeastObjectNotFoundException as e: print(e) exit(1) print( yaml.dump(yaml.safe_load(str(entity)), default_flow_style=False, sort_keys=False))
def enable_alpha_feature(ctx: click.Context, name: str): """ Enables an alpha feature """ if name not in flags.FLAG_NAMES: raise ValueError(f"Flag name, {name}, not valid.") repo = ctx.obj["CHDIR"] cli_check_repo(repo) repo_path = str(repo) store = FeatureStore(repo_path=repo_path) if store.config.flags is None: store.config.flags = {} store.config.flags[flags.FLAG_ALPHA_FEATURES_NAME] = True store.config.flags[name] = True store.config.write_to_path(Path(repo_path))
def entity_list(ctx: click.Context): """ List all entities """ repo = ctx.obj["CHDIR"] cli_check_repo(repo) store = FeatureStore(repo_path=str(repo)) table = [] for entity in store.list_entities(): table.append([entity.name, entity.description, entity.value_type]) from tabulate import tabulate print( tabulate(table, headers=["NAME", "DESCRIPTION", "TYPE"], tablefmt="plain"))
def entity_describe(ctx: click.Context, name: str): """ Describe an entity """ repo = ctx.obj["CHDIR"] cli_check_repo(repo) store = FeatureStore(repo_path=str(repo)) try: entity = store.get_entity(name) except FeastObjectNotFoundException as e: print(e) exit(1) print( yaml.dump(yaml.safe_load(str(entity)), default_flow_style=False, sort_keys=False))