Skip to content

Commit

Permalink
Comments
Browse files Browse the repository at this point in the history
Signed-off-by: Danny Chiao <danny@tecton.ai>
  • Loading branch information
adchia committed Sep 16, 2021
1 parent 58303b7 commit ca8707d
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 19 deletions.
18 changes: 15 additions & 3 deletions sdk/python/feast/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
import pkg_resources
import yaml

from feast import flags, utils
from feast import flags, flags_helper, utils
from feast.errors import FeastObjectNotFoundException, FeastProviderLoginError
from feast.feature_store import FeatureStore
from feast.repo_config import load_repo_config
Expand Down Expand Up @@ -432,14 +432,26 @@ def alpha_cmd():


@alpha_cmd.command("list")
def list_alpha_features():
@click.pass_context
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:")
print(*flags_to_show, sep="\n")
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}")


@alpha_cmd.command("enable-all")
Expand Down
3 changes: 2 additions & 1 deletion sdk/python/feast/errors.py
Original file line number Diff line number Diff line change
Expand Up @@ -263,5 +263,6 @@ def __init__(self, feature_view_name: str):
class ExperimentalFeatureNotEnabled(Exception):
def __init__(self, feature_flag_name: str):
super().__init__(
f"You are attempting to use an experimental feature. Please run `feast alpha enable {feature_flag_name}`"
f"You are attempting to use an experimental feature that is not enabled. Please run "
f"`feast alpha enable {feature_flag_name}` "
)
6 changes: 3 additions & 3 deletions sdk/python/feast/flags.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
FLAG_ALPHA_FEATURES_NAME = "enable_alpha_features"
FLAG_ON_DEMAND_TRANSFORM_NAME = "enable_on_demand_transforms"
FLAG_PYTHON_FEATURE_SERVER_NAME = "enable_python_feature_server"
FLAG_ALPHA_FEATURES_NAME = "alpha_features"
FLAG_ON_DEMAND_TRANSFORM_NAME = "on_demand_transforms"
FLAG_PYTHON_FEATURE_SERVER_NAME = "python_feature_server"
ENV_FLAG_IS_TEST = "IS_TEST"

FLAG_NAMES = {
Expand Down
19 changes: 7 additions & 12 deletions sdk/python/feast/flags_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,12 @@ def _env_flag_enabled(name: str) -> bool:
return os.getenv(name, default="False") == "True"


def _feature_flag_enabled(repo_config: RepoConfig, flag_name: str) -> bool:
def feature_flag_enabled(repo_config: RepoConfig, flag_name: str) -> bool:
if is_test():
return True
return (
repo_config.flags is not None
_alpha_feature_flag_enabled(repo_config)
and repo_config.flags is not None
and flag_name in repo_config.flags
and repo_config.flags[flag_name]
)
Expand All @@ -29,16 +32,8 @@ def is_test() -> bool:


def enable_on_demand_feature_views(repo_config: RepoConfig) -> bool:
if is_test():
return True
return _alpha_feature_flag_enabled(repo_config) and _feature_flag_enabled(
repo_config, flags.FLAG_ON_DEMAND_TRANSFORM_NAME
)
return feature_flag_enabled(repo_config, flags.FLAG_ON_DEMAND_TRANSFORM_NAME)


def enable_python_feature_server(repo_config: RepoConfig) -> bool:
if is_test():
return True
return _alpha_feature_flag_enabled(repo_config) and _feature_flag_enabled(
repo_config, flags.FLAG_PYTHON_FEATURE_SERVER_NAME
)
return feature_flag_enabled(repo_config, flags.FLAG_PYTHON_FEATURE_SERVER_NAME)

0 comments on commit ca8707d

Please sign in to comment.