Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
75 changes: 21 additions & 54 deletions examples/minimal/Feast 101.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -59,47 +59,6 @@
"### Configuration"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"import os"
]
},
{
"cell_type": "code",
"execution_count": 54,
"metadata": {},
"outputs": [],
"source": [
"# os.environ['FEAST_SPARK_LAUNCHER'] = 'standalone'\n",
"# os.environ['FEAST_SPARK_STANDALONE_MASTER'] = 'local[*]'\n",
"# os.environ['FEAST_SPARK_HOME'] = os.path.dirname(pyspark.__file__)\n",
"# os.environ['FEAST_SPARK_EXTRA_OPTIONS'] = '--jars https://storage.googleapis.com/hadoop-lib/gcs/gcs-connector-hadoop2-latest.jar'\\\n",
"# ' --conf spark.hadoop.fs.gs.impl=com.google.cloud.hadoop.fs.gcs.GoogleHadoopFileSystem'"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"os.environ['FEAST_SPARK_STAGING_LOCATION'] = \"gs://feast-templocation-kf-feast/demo/staging/\"\n",
"os.environ['FEAST_HISTORICAL_FEATURE_OUTPUT_LOCATION'] = \"gs://feast-templocation-kf-feast/demo/output\""
]
},
{
"cell_type": "code",
"execution_count": 4,
"metadata": {},
"outputs": [],
"source": [
"# os.environ['GOOGLE_APPLICATION_CREDENTIALS'] = \"/path/to/key\""
]
},
{
"cell_type": "markdown",
"metadata": {},
Expand All @@ -126,13 +85,13 @@
"metadata": {},
"outputs": [],
"source": [
"CORE_HOST = os.getenv(\"DEMO_FEAST_CORE_SERVICE_HOST\", \"localhost\")\n",
"SERVING_HOST = os.getenv(\"DEMO_FEAST_ONLINE_SERVING_SERVICE_HOST\", \"localhost\")\n",
"REDIS_HOST = os.getenv('DEMO_REDIS_MASTER_SERVICE_HOST', 'localhost')\n",
"REDIS_HOST = os.getenv('DEMO_REDIS_MASTER_SERVICE_HOST', os.getenv('FEAST_REDIS_HOST'))\n",
"DEMO_DATA_LOCATION = os.getenv(\"DEMO_DATA_LOCATION\")\n",

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we rename this from demo to something more generic? demo seems specific to our demos whereas this notebook is version controlled for use as a tutorial.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have already moved the demo variable in #1086.

So perhaps we can #1086 merged first?

"# os.environ['GOOGLE_APPLICATION_CREDENTIALS'] = \"/path/to/key\"\n",
"\n",
"client = Client(\n",
" core_url=f\"{CORE_HOST}:6565\",\n",
" serving_url=f\"{SERVING_HOST}:6566\", \n",
" core_url=os.getenv('FEAST_CORE_URL', \"localhost:6565\"),\n",
" serving_url=os.getenv('FEAST_ONLINE_SERVING_URL', \"localhost:6566\"),\n",
" redis_host=REDIS_HOST\n",
")"
]
Expand Down Expand Up @@ -251,7 +210,7 @@
" event_timestamp_column=\"datetime\",\n",
" created_timestamp_column=\"created\",\n",
" file_format=ParquetFormat(),\n",
" file_url=\"gs://feast-demo-data-lake/driver_statistics\",\n",
" file_url=os.path.join(DEMO_DATA_LOCATION, \"driver_statistics\"),\n",
" date_partition_column=\"date\"\n",
" )\n",
")"
Expand All @@ -273,7 +232,7 @@
" event_timestamp_column=\"datetime\",\n",
" created_timestamp_column=\"created\",\n",
" file_format=ParquetFormat(),\n",
" file_url=\"gs://feast-demo-data-lake/driver_trips\",\n",
" file_url=os.path.join(DEMO_DATA_LOCATION, \"driver_trips\"),\n",
" date_partition_column=\"date\"\n",
" )\n",
")"
Expand Down Expand Up @@ -563,7 +522,7 @@
"metadata": {},
"outputs": [],
"source": [
"import gcsfs\n",
"\n",
"from pyarrow.parquet import ParquetDataset"
]
},
Expand All @@ -574,8 +533,16 @@
"outputs": [],
"source": [
"def read_remote_parquet(path):\n",
" fs = gcsfs.GCSFileSystem()\n",
" files = [\"gs://\" + path for path in gcsfs.GCSFileSystem().glob(path)]\n",
" prefix = path[:5]\n",
" if prefix == 'gs://':\n",
" import gcsfs\n",
" fs = gcsfs.GCSFileSystem()\n",
" elif prefix == 's3://':\n",
" import s3fs\n",
" fs = s3fs.S3FileSystem()\n",
" else:\n",
" raise Exception(f'Unsupported fs {prefix}')\n",
" files = [prefix + path for path in fs.glob(path)]\n",
" ds = ParquetDataset(files, filesystem=fs)\n",
" return ds.read().to_pandas()"
]
Expand Down Expand Up @@ -1138,7 +1105,7 @@
"metadata": {},
"outputs": [],
"source": [
"KAFKA_BROKER = \"kafka:9092\""
"KAFKA_BROKER = os.getenv(\"DEMO_KAFKA_BROKERS\", \"kafka:9092\")"

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it make sense to hoist these variables to the top so that we know which env vars to set outside the notebook?

]
},
{
Expand Down Expand Up @@ -1235,7 +1202,7 @@
"metadata": {},
"outputs": [],
"source": [
"entities_sample = np.random.choice(entities, 10)\n",
"entities_sample = np.random.choice(entities, 10, replace=False)\n",
"entities_sample = [{\"driver_id\": e} for e in entities_sample]\n",
"entities_sample"
]
Expand Down Expand Up @@ -1298,4 +1265,4 @@
},
"nbformat": 4,
"nbformat_minor": 4
}
}