()
| 9 | |
| 10 | |
| 11 | def bootstrap(): |
| 12 | # Bootstrap() will automatically be called from the init_repo() during `feast init` |
| 13 | |
| 14 | import pathlib |
| 15 | from datetime import datetime, timedelta |
| 16 | |
| 17 | from feast.driver_test_data import create_driver_hourly_stats_df |
| 18 | |
| 19 | repo_path = pathlib.Path(__file__).parent.absolute() |
| 20 | project_name = str(repo_path)[str(repo_path).rfind("/") + 1 :] |
| 21 | repo_path = repo_path / "feature_repo" |
| 22 | |
| 23 | end_date = datetime.now().replace(microsecond=0, second=0, minute=0) |
| 24 | start_date = end_date - timedelta(days=15) |
| 25 | |
| 26 | driver_entities = [1001, 1002, 1003, 1004, 1005] |
| 27 | driver_df = create_driver_hourly_stats_df(driver_entities, start_date, end_date) |
| 28 | |
| 29 | data_path = repo_path / "data" |
| 30 | data_path.mkdir(exist_ok=True) |
| 31 | driver_stats_path = data_path / "driver_stats.parquet" |
| 32 | driver_df.to_parquet(path=str(driver_stats_path), allow_truncated_timestamps=True) |
| 33 | |
| 34 | snowflake_deployment_url = click.prompt( |
| 35 | "Snowflake Deployment URL (exclude .snowflakecomputing.com):" |
| 36 | ) |
| 37 | snowflake_user = click.prompt("Snowflake User Name:") |
| 38 | snowflake_password = click.prompt("Snowflake Password:", hide_input=True) |
| 39 | snowflake_role = click.prompt("Snowflake Role Name (Case Sensitive):") |
| 40 | snowflake_warehouse = click.prompt("Snowflake Warehouse Name (Case Sensitive):") |
| 41 | snowflake_database = click.prompt("Snowflake Database Name (Case Sensitive):") |
| 42 | |
| 43 | config_file = repo_path / "feature_store.yaml" |
| 44 | for i in range(3): |
| 45 | replace_str_in_file( |
| 46 | config_file, "SNOWFLAKE_DEPLOYMENT_URL", snowflake_deployment_url |
| 47 | ) |
| 48 | replace_str_in_file(config_file, "SNOWFLAKE_USER", snowflake_user) |
| 49 | replace_str_in_file(config_file, "SNOWFLAKE_PASSWORD", snowflake_password) |
| 50 | replace_str_in_file(config_file, "SNOWFLAKE_ROLE", snowflake_role) |
| 51 | replace_str_in_file(config_file, "SNOWFLAKE_WAREHOUSE", snowflake_warehouse) |
| 52 | replace_str_in_file(config_file, "SNOWFLAKE_DATABASE", snowflake_database) |
| 53 | |
| 54 | if click.confirm( |
| 55 | f'Should I upload example data to Snowflake (overwriting "{project_name}_feast_driver_hourly_stats" table)?', |
| 56 | default=True, |
| 57 | ): |
| 58 | snowflake_conn = snowflake.connector.connect( |
| 59 | account=snowflake_deployment_url, |
| 60 | user=snowflake_user, |
| 61 | password=snowflake_password, |
| 62 | role=snowflake_role, |
| 63 | warehouse=snowflake_warehouse, |
| 64 | application="feast", |
| 65 | ) |
| 66 | |
| 67 | with snowflake_conn as conn: |
| 68 | execute_snowflake_statement( |
no test coverage detected