-
Notifications
You must be signed in to change notification settings - Fork 243
Support 'hourly' resolution for 'timePartitionPattern' #844
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from all commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
47a5ba2
Fix avro files read failure under timePartitionPattern paths
1ea403b
quick change
1a41e86
modify test sources paths
9a686c6
quick revert change by mistake
179029d
modify data source path
c8c32d7
Add comments
6795c87
quick change
155212a
modify test cases
5384a6b
Merge branch 'main' into enya/tpp-fix
585e2ae
Revert "modify test cases"
d5316d8
Revert "Revert "modify test cases""
7f68162
Revert "Revert databricks example notebook until fixing issues (#814)"
05fa959
Revert "Fix passthrough feature reference in sql-based derived featur…
8c044c9
Merge branch 'main' into enya/tpp-fix
f6c5b6b
Revert "Revert "Fix passthrough feature reference in sql-based derive…
918936e
Revert "Revert "Revert databricks example notebook until fixing issue…
bc1946c
Support 'hourly' resolution in 'timePartitionPattern'
ae2b325
Solve conflicts
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -42,7 +42,7 @@ def test_feathr_materialize_to_offline(): | |
| if client.spark_runtime == 'databricks': | ||
| output_path = ''.join(['dbfs:/feathrazure_cijob_materialize_offline_','_', str(now.minute), '_', str(now.second), ""]) | ||
| else: | ||
| output_path = ''.join(['abfss://[email protected]/demo_data/feathrazure_cijob_materialize_offline_','_', str(now.minute), '_', str(now.second), ""]) | ||
| output_path = ''.join(['abfss://[email protected]/demo_data/feathrazure_cijob_materialize_offline_','_', str(now.minute), '_', str(now.second), ""]) | ||
| offline_sink = HdfsSink(output_path=output_path) | ||
| settings = MaterializationSettings("nycTaxiTable", | ||
| sinks=[offline_sink], | ||
|
|
@@ -430,7 +430,7 @@ def test_feathr_materialize_with_time_partition_pattern(): | |
| client_consumer: FeathrClient = time_partition_pattern_test_setup(os.path.join(test_workspace_dir, "feathr_config.yaml"), output_path+'/df0/daily') | ||
|
|
||
| backfill_time_tpp = BackfillTime(start=datetime( | ||
| 2020, 5, 20), end=datetime(2020, 5, 20), step=timedelta(days=1)) | ||
| 2020, 5, 21), end=datetime(2020, 5, 21), step=timedelta(days=1)) | ||
|
|
||
| now = datetime.now() | ||
| if client_consumer.spark_runtime == 'databricks': | ||
|
|
@@ -449,9 +449,65 @@ def test_feathr_materialize_with_time_partition_pattern(): | |
|
|
||
| # download result and just assert the returned result is not empty | ||
| # by default, it will write to a folder appended with date | ||
| res_df = get_result_df(client_consumer, "avro", output_path_tpp + "/df0/daily/2020/05/20") | ||
| res_df = get_result_df(client_consumer, "avro", output_path_tpp + "/df0/daily/2020/05/21") | ||
| assert res_df.shape[0] > 0 | ||
|
|
||
| def test_feathr_materialize_with_time_partition_pattern_hourly(): | ||
| """ | ||
| Test FeathrClient() using HdfsSource with 'timePartitionPattern'. | ||
| """ | ||
| test_workspace_dir = Path( | ||
| __file__).parent.resolve() / "test_user_workspace" | ||
| # os.chdir(test_workspace_dir) | ||
| # Create data source first | ||
| client_producer: FeathrClient = basic_test_setup(os.path.join(test_workspace_dir, "feathr_config.yaml")) | ||
|
|
||
| backfill_time = BackfillTime(start=datetime( | ||
| 2020, 5, 20), end=datetime(2020, 5, 20), step=timedelta(days=1)) | ||
|
|
||
| if client_producer.spark_runtime == 'databricks': | ||
| output_path = 'dbfs:/timePartitionPattern_hourly_sample' | ||
| else: | ||
| output_path = 'abfss://[email protected]/timePartitionPattern_hourly_sample' | ||
|
|
||
| offline_sink = HdfsSink(output_path=output_path) | ||
| settings = MaterializationSettings("nycTaxiTable", | ||
| sinks=[offline_sink], | ||
| feature_names=[ | ||
| "f_location_avg_fare", "f_location_max_fare"], | ||
| backfill_time=backfill_time,resolution='HOURLY') | ||
| client_producer.materialize_features(settings) | ||
| # assuming the job can successfully run; otherwise it will throw exception | ||
| client_producer.wait_job_to_finish(timeout_sec=Constants.SPARK_JOB_TIMEOUT_SECONDS) | ||
|
|
||
| res_df = get_result_df(client_producer, "avro", output_path + "/df0/daily/2020/05/20/00") | ||
| assert res_df.shape[0] > 0 | ||
|
|
||
| client_consumer: FeathrClient = time_partition_pattern_test_setup(os.path.join(test_workspace_dir, "feathr_config.yaml"), output_path+'/df0/daily', 'HOURLY') | ||
|
|
||
| backfill_time_tpp = BackfillTime(start=datetime( | ||
| 2020, 5, 21), end=datetime(2020, 5, 21), step=timedelta(days=1)) | ||
|
|
||
| now = datetime.now() | ||
| if client_consumer.spark_runtime == 'databricks': | ||
| output_path_tpp = ''.join(['dbfs:/feathrazure_cijob_materialize_offline_','_', str(now.minute), '_', str(now.second), ""]) | ||
| else: | ||
| output_path_tpp = ''.join(['abfss://[email protected]/demo_data/feathrazure_cijob_materialize_offline_','_', str(now.minute), '_', str(now.second), ""]) | ||
| offline_sink_tpp = HdfsSink(output_path=output_path_tpp) | ||
| settings_tpp = MaterializationSettings("nycTaxiTable", | ||
| sinks=[offline_sink_tpp], | ||
| feature_names=[ | ||
| "f_loc_avg_output", "f_loc_max_output"], | ||
| backfill_time=backfill_time_tpp, | ||
| resolution = 'HOURLY') | ||
| client_consumer.materialize_features(settings_tpp, allow_materialize_non_agg_feature=True) | ||
| # assuming the job can successfully run; otherwise it will throw exception | ||
| client_consumer.wait_job_to_finish(timeout_sec=Constants.SPARK_JOB_TIMEOUT_SECONDS) | ||
|
|
||
| # download result and just assert the returned result is not empty | ||
| # by default, it will write to a folder appended with date | ||
| res_df = get_result_df(client_consumer, "avro", output_path_tpp + "/df0/daily/2020/05/21/00") | ||
| assert res_df.shape[0] > 0 | ||
|
|
||
| if __name__ == "__main__": | ||
| test_feathr_materialize_to_aerospike() | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -380,28 +380,38 @@ def get_online_test_table_name(table_name: str): | |
| print("The online Redis table is", res_table) | ||
| return res_table | ||
|
|
||
| def time_partition_pattern_test_setup(config_path: str, data_source_path: str): | ||
| def time_partition_pattern_test_setup(config_path: str, data_source_path: str, resolution: str = 'DAILY'): | ||
| now = datetime.now() | ||
| # set workspace folder by time; make sure we don't have write conflict if there are many CI tests running | ||
| os.environ['SPARK_CONFIG__DATABRICKS__WORK_DIR'] = ''.join(['dbfs:/feathrazure_cijob','_', str(now.minute), '_', str(now.second), '_', str(now.microsecond)]) | ||
| os.environ['SPARK_CONFIG__AZURE_SYNAPSE__WORKSPACE_DIR'] = ''.join(['abfss://[email protected]/feathr_github_ci','_', str(now.minute), '_', str(now.second) ,'_', str(now.microsecond)]) | ||
| client = FeathrClient(config_path=config_path) | ||
|
|
||
| batch_source = HdfsSource(name="testTimePartitionSource", | ||
| if resolution == 'DAILY': | ||
| batch_source = HdfsSource(name="testTimePartitionSource", | ||
| path=data_source_path, | ||
| time_partition_pattern="yyyy/MM/dd" | ||
| ) | ||
| else: | ||
| batch_source = HdfsSource(name="testTimePartitionSource", | ||
| path=data_source_path, | ||
| time_partition_pattern="yyyy/MM/dd/HH" | ||
| ) | ||
| key = TypedKey(key_column="key0", | ||
| key_column_type=ValueType.INT32) | ||
| agg_features = [ | ||
| Feature(name="f_loc_avg_output", | ||
| key=[key], | ||
| feature_type=FLOAT, | ||
| transform="f_location_avg_fare"), | ||
| transform=WindowAggTransformation(agg_expr="f_location_avg_fare", | ||
| agg_func="AVG", | ||
| window="3d")), | ||
| Feature(name="f_loc_max_output", | ||
| feature_type=FLOAT, | ||
| key=[key], | ||
| transform="f_location_max_fare"), | ||
| transform=WindowAggTransformation(agg_expr="f_location_max_fare", | ||
| agg_func="MAX", | ||
| window="3d")), | ||
| ] | ||
|
|
||
| agg_anchor = FeatureAnchor(name="testTimePartitionFeatures", | ||
|
|
||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
better to add some time signature in the output path so each job's output can be unique
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is used as data source not the output we want to check so maybe we don't need to take extra space to save it