()
| 5 | |
| 6 | |
| 7 | def bootstrap(): |
| 8 | # Bootstrap() will automatically be called from the init_repo() during `feast init` |
| 9 | |
| 10 | import pathlib |
| 11 | from datetime import datetime, timedelta |
| 12 | |
| 13 | from feast.driver_test_data import create_driver_hourly_stats_df |
| 14 | |
| 15 | end_date = datetime.now().replace(microsecond=0, second=0, minute=0) |
| 16 | start_date = end_date - timedelta(days=15) |
| 17 | |
| 18 | driver_entities = [1001, 1002, 1003, 1004, 1005] |
| 19 | driver_df = create_driver_hourly_stats_df(driver_entities, start_date, end_date) |
| 20 | |
| 21 | aws_region = click.prompt("AWS Region (e.g. us-west-2)") |
| 22 | cluster_id = click.prompt("Redshift Cluster ID") |
| 23 | database = click.prompt("Redshift Database Name") |
| 24 | user = click.prompt("Redshift User Name") |
| 25 | s3_staging_location = click.prompt("Redshift S3 Staging Location (s3://*)") |
| 26 | iam_role = click.prompt("Redshift IAM Role for S3 (arn:aws:iam::*:role/*)") |
| 27 | |
| 28 | if click.confirm( |
| 29 | "Should I upload example data to Redshift (overwriting 'feast_driver_hourly_stats' table)?", |
| 30 | default=True, |
| 31 | ): |
| 32 | client = aws_utils.get_redshift_data_client(aws_region) |
| 33 | s3 = aws_utils.get_s3_resource(aws_region) |
| 34 | |
| 35 | aws_utils.execute_redshift_statement( |
| 36 | client, |
| 37 | cluster_id, |
| 38 | None, |
| 39 | database, |
| 40 | user, |
| 41 | "DROP TABLE IF EXISTS feast_driver_hourly_stats", |
| 42 | ) |
| 43 | |
| 44 | aws_utils.upload_df_to_redshift( |
| 45 | client, |
| 46 | cluster_id, |
| 47 | None, |
| 48 | database, |
| 49 | user, |
| 50 | s3, |
| 51 | f"{s3_staging_location}/data/feast_driver_hourly_stats.parquet", |
| 52 | iam_role, |
| 53 | "feast_driver_hourly_stats", |
| 54 | driver_df, |
| 55 | ) |
| 56 | |
| 57 | repo_path = pathlib.Path(__file__).parent.absolute() / "feature_repo" |
| 58 | example_py_file = repo_path / "feature_definitions.py" |
| 59 | replace_str_in_file(example_py_file, "%REDSHIFT_DATABASE%", database) |
| 60 | |
| 61 | config_file = repo_path / "feature_store.yaml" |
| 62 | replace_str_in_file(config_file, "%AWS_REGION%", aws_region) |
| 63 | replace_str_in_file(config_file, "%REDSHIFT_CLUSTER_ID%", cluster_id) |
| 64 | replace_str_in_file(config_file, "%REDSHIFT_DATABASE%", database) |
no test coverage detected