|
6 | 6 |
|
7 | 7 | from feast.config import Config |
8 | 8 | from feast.constants import ( |
| 9 | + CONFIG_REDIS_HOST, |
| 10 | + CONFIG_REDIS_PORT, |
| 11 | + CONFIG_REDIS_SSL, |
9 | 12 | CONFIG_SPARK_DATAPROC_CLUSTER_NAME, |
10 | 13 | CONFIG_SPARK_DATAPROC_PROJECT, |
11 | 14 | CONFIG_SPARK_DATAPROC_REGION, |
12 | 15 | CONFIG_SPARK_DATAPROC_STAGING_LOCATION, |
| 16 | + CONFIG_SPARK_EMR_CLUSTER_ID, |
| 17 | + CONFIG_SPARK_EMR_CLUSTER_TEMPLATE_PATH, |
| 18 | + CONFIG_SPARK_EMR_LOG_LOCATION, |
| 19 | + CONFIG_SPARK_EMR_REGION, |
| 20 | + CONFIG_SPARK_EMR_STAGING_LOCATION, |
13 | 21 | CONFIG_SPARK_HOME, |
14 | 22 | CONFIG_SPARK_INGESTION_JOB_JAR, |
15 | 23 | CONFIG_SPARK_LAUNCHER, |
@@ -50,7 +58,27 @@ def _dataproc_launcher(config: Config) -> JobLauncher: |
50 | 58 | ) |
51 | 59 |
|
52 | 60 |
|
53 | | -_launchers = {"standalone": _standalone_launcher, "dataproc": _dataproc_launcher} |
| 61 | +def _emr_launcher(config: Config) -> JobLauncher: |
| 62 | + from feast.pyspark.launchers import aws |
| 63 | + |
| 64 | + def _get_optional(option): |
| 65 | + if config.exists(option): |
| 66 | + return config.get(option) |
| 67 | + |
| 68 | + return aws.EmrClusterLauncher( |
| 69 | + region=config.get(CONFIG_SPARK_EMR_REGION), |
| 70 | + existing_cluster_id=_get_optional(CONFIG_SPARK_EMR_CLUSTER_ID), |
| 71 | + new_cluster_template_path=_get_optional(CONFIG_SPARK_EMR_CLUSTER_TEMPLATE_PATH), |
| 72 | + staging_location=config.get(CONFIG_SPARK_EMR_STAGING_LOCATION), |
| 73 | + emr_log_location=config.get(CONFIG_SPARK_EMR_LOG_LOCATION), |
| 74 | + ) |
| 75 | + |
| 76 | + |
| 77 | +_launchers = { |
| 78 | + "standalone": _standalone_launcher, |
| 79 | + "dataproc": _dataproc_launcher, |
| 80 | + "emr": _emr_launcher, |
| 81 | +} |
54 | 82 |
|
55 | 83 |
|
56 | 84 | def resolve_launcher(config: Config) -> JobLauncher: |
@@ -177,5 +205,17 @@ def start_offline_to_online_ingestion( |
177 | 205 | feature_table=_feature_table_to_argument(client, feature_table), |
178 | 206 | start=start, |
179 | 207 | end=end, |
| 208 | + redis_host=client._config.get(CONFIG_REDIS_HOST), |
| 209 | + redis_port=client._config.getint(CONFIG_REDIS_PORT), |
| 210 | + redis_ssl=client._config.getboolean(CONFIG_REDIS_SSL), |
180 | 211 | ) |
181 | 212 | ) |
| 213 | + |
| 214 | + |
| 215 | +def stage_dataframe( |
| 216 | + df, event_timestamp_column: str, created_timestamp_column: str, client: "Client" |
| 217 | +) -> FileSource: |
| 218 | + launcher = resolve_launcher(client._config) |
| 219 | + return launcher.stage_dataframe( |
| 220 | + df, event_timestamp_column, created_timestamp_column, |
| 221 | + ) |
0 commit comments