diff --git a/feathr_project/feathr/_feature_registry.py b/feathr_project/feathr/_feature_registry.py index 727168a28..a88fa5e1a 100644 --- a/feathr_project/feathr/_feature_registry.py +++ b/feathr_project/feathr/_feature_registry.py @@ -581,12 +581,12 @@ def _extract_features(self, workspace_path: Path) -> RepoDefinitions: return definitions @classmethod - def save_to_feature_config(self, workspace_path: Path): + def save_to_feature_config(self, workspace_path: Path, config_save_dir: Path): """Save feature definition within the workspace into HOCON feature config files""" repo_definitions = self._extract_features(workspace_path) - self._save_request_feature_config(repo_definitions) - self._save_anchored_feature_config(repo_definitions) - self._save_derived_feature_config(repo_definitions) + self._save_request_feature_config(repo_definitions, config_save_dir) + self._save_anchored_feature_config(repo_definitions, config_save_dir) + self._save_derived_feature_config(repo_definitions, config_save_dir) @classmethod def save_to_feature_config_from_context(self, anchor_list, derived_feature_list, local_workspace_dir: Path): diff --git a/feathr_project/feathr/source.py b/feathr_project/feathr/source.py index fb991612e..0020e403e 100644 --- a/feathr_project/feathr/source.py +++ b/feathr_project/feathr/source.py @@ -103,7 +103,7 @@ def to_feature_config(self) -> str: tm = Template(""" {{source.name}}: { location: {path: "{{source.path}}"} - {% if source.event_timestamp_column is defined %} + {% if source.event_timestamp_column %} timeWindowParameters: { timestampColumn: "{{source.event_timestamp_column}}" timestampColumnFormat: "{{source.timestamp_format}}" diff --git a/feathr_project/feathrcli/cli.py b/feathr_project/feathrcli/cli.py index 1d34c0e52..82c0ea1b8 100644 --- a/feathr_project/feathrcli/cli.py +++ b/feathr_project/feathrcli/cli.py @@ -7,7 +7,7 @@ import subprocess import urllib.request from feathr.client import FeathrClient - +from feathr._feature_registry import _FeatureRegistry @click.group() @click.pass_context @@ -71,6 +71,18 @@ def init(name, git): click.echo(click.style('Feathr initialization completed.', fg='green')) +@cli.command() +@click.option('--save_to', default="./", help='Specify the path to save the output HOCON config(relative to current path).') +def hocon(save_to): + """ + Scan all Python-based feature definitions recursively under current directory, + convert them to HOCON config and save to a given path (relative to current directory). + """ + scan_dir = Path.cwd() + save_to = Path(os.path.join(scan_dir, save_to)) + _FeatureRegistry.save_to_feature_config(scan_dir, save_to) + + @cli.command() @click.argument('filepath', default='feature_join_conf/feature_join.conf', type=click.Path(exists=True)) def join(filepath):