From 33141f816550d70e1b99b31d7ea104019259e4b1 Mon Sep 17 00:00:00 2001 From: Danny Chiao Date: Tue, 14 Jun 2022 16:10:36 -0400 Subject: [PATCH] docs: Make quickstart docs consistent and add Web UI to colab (#2794) Signed-off-by: Danny Chiao --- docs/getting-started/quickstart.md | 11 +- examples/quickstart/quickstart.ipynb | 577 ++++++++++++++++----------- 2 files changed, 359 insertions(+), 229 deletions(-) diff --git a/docs/getting-started/quickstart.md b/docs/getting-started/quickstart.md index 1b926eeca5..b5fe7bad4b 100644 --- a/docs/getting-started/quickstart.md +++ b/docs/getting-started/quickstart.md @@ -377,6 +377,14 @@ pprint(feature_vector) You can also use feature services to manage multiple features, and decouple feature view definitions and the features needed by end applications. The feature store can also be used to fetch either online or historical features using the same api below. More information can be found [here](https://docs.feast.dev/getting-started/concepts/feature-retrieval). +The `driver_activity` feature service pulls all features from the `driver_hourly_stats` feature view: + +```python +driver_stats_fs = FeatureService( + name="driver_activity", features=[driver_hourly_stats_view] +) +``` + {% tabs %} {% tab title="Python" %} ```python @@ -384,7 +392,7 @@ from feast import FeatureStore feature_store = FeatureStore('.') # Initialize the feature store feature_service = feature_store.get_feature_service("driver_activity") -features = feature_store.get_online_features( +feature_vector = feature_store.get_online_features( features=feature_service, entity_rows=[ # {join_key: entity_value} @@ -392,6 +400,7 @@ features = feature_store.get_online_features( {"driver_id": 1005}, ], ).to_dict() +pprint(feature_vector) ``` {% tabs %} diff --git a/examples/quickstart/quickstart.ipynb b/examples/quickstart/quickstart.ipynb index 60974d2751..d29ee4fa35 100644 --- a/examples/quickstart/quickstart.ipynb +++ b/examples/quickstart/quickstart.ipynb @@ -1,20 +1,4 @@ { - "nbformat": 4, - "nbformat_minor": 0, - "metadata": { - "colab": { - "name": "Feast Codelab", - "provenance": [], - "collapsed_sections": [] - }, - "kernelspec": { - "name": "python3", - "display_name": "Python 3" - }, - "language_info": { - "name": "python" - } - }, "cells": [ { "cell_type": "markdown", @@ -54,28 +38,20 @@ }, { "cell_type": "code", + "execution_count": null, "metadata": { "colab": { "base_uri": "https://localhost:8080/" }, "id": "rXNMAAJKQPG5", - "outputId": "52297709-380b-4200-8e7c-3d0102a82ea4" + "outputId": "94fb2260-4453-45c9-ba77-5b384823a621" }, + "outputs": [], "source": [ "%%sh\n", "pip install feast -U -q\n", "pip install Pygments -q\n", "echo \"Please restart your runtime now (Runtime -> Restart runtime). This ensures that the correct dependencies are loaded.\"" - ], - "execution_count": 1, - "outputs": [ - { - "output_type": "stream", - "name": "stdout", - "text": [ - "Please restart your runtime now (Runtime -> Restart runtime). This ensures that the correct dependencies are loaded.\n" - ] - } ] }, { @@ -107,28 +83,32 @@ }, { "cell_type": "code", + "execution_count": 1, "metadata": { "colab": { "base_uri": "https://localhost:8080/" }, "id": "IhirSkgUvYau", - "outputId": "df90af1a-06bd-48a1-94e6-7def19e87d5f" + "outputId": "664367b9-6a2a-493d-fd78-6495fb459fa2" }, - "source": [ - "!feast init feature_repo" - ], - "execution_count": 1, "outputs": [ { - "output_type": "stream", "name": "stdout", + "output_type": "stream", "text": [ "Feast is an open source project that collects anonymized error reporting and usage statistics. To opt out or learn more see https://docs.feast.dev/reference/usage\n", + "/usr/local/lib/python3.7/dist-packages/scipy/fft/__init__.py:97: DeprecationWarning: The module numpy.dual is deprecated. Instead of using dual, use the functions directly from numpy or scipy.\n", + " from numpy.dual import register_func\n", + "/usr/local/lib/python3.7/dist-packages/scipy/sparse/sputils.py:17: DeprecationWarning: `np.typeDict` is a deprecated alias for `np.sctypeDict`.\n", + " supported_dtypes = [np.typeDict[x] for x in supported_dtypes]\n", "\n", "Creating a new Feast repository in \u001b[1m\u001b[32m/content/feature_repo\u001b[0m.\n", "\n" ] } + ], + "source": [ + "!feast init feature_repo" ] }, { @@ -150,22 +130,18 @@ }, { "cell_type": "code", + "execution_count": 2, "metadata": { "colab": { "base_uri": "https://localhost:8080/" }, "id": "9jXuzt4ovzA3", - "outputId": "bff15f0c-9f8e-4a3c-e605-5ad84be30709" + "outputId": "9e326892-f0cc-4d86-d0b2-f33f822f83a9" }, - "source": [ - "%cd feature_repo\n", - "!ls -R" - ], - "execution_count": 2, "outputs": [ { - "output_type": "stream", "name": "stdout", + "output_type": "stream", "text": [ "/content/feature_repo\n", ".:\n", @@ -175,6 +151,10 @@ "driver_stats.parquet\n" ] } + ], + "source": [ + "%cd feature_repo\n", + "!ls -R" ] }, { @@ -198,21 +178,18 @@ }, { "cell_type": "code", + "execution_count": 3, "metadata": { "colab": { "base_uri": "https://localhost:8080/" }, "id": "9_YJ--uYdtcP", - "outputId": "89268e31-6be0-43fb-e576-6d335a2c1dd9" + "outputId": "af56a8da-9ca2-4dd9-f73c-a60dd3e1613a" }, - "source": [ - "!pygmentize feature_store.yaml" - ], - "execution_count": 3, "outputs": [ { - "output_type": "stream", "name": "stdout", + "output_type": "stream", "text": [ "\u001b[94mproject\u001b[39;49;00m: feature_repo\n", "\u001b[94mregistry\u001b[39;49;00m: data/registry.db\n", @@ -221,6 +198,9 @@ " \u001b[94mpath\u001b[39;49;00m: data/online_store.db\n" ] } + ], + "source": [ + "!pygmentize feature_store.yaml" ] }, { @@ -236,56 +216,21 @@ }, { "cell_type": "code", + "execution_count": 4, "metadata": { "colab": { "base_uri": "https://localhost:8080/", - "height": 424 + "height": 423 }, "id": "sIF2lO59dwzi", - "outputId": "80e798d5-df21-4ebd-de1c-9bde282bd742" + "outputId": "8931930b-b32f-43e1-d45b-de230489c7b8" }, - "source": [ - "import pandas as pd\n", - "\n", - "pd.read_parquet(\"data/driver_stats.parquet\")" - ], - "execution_count": 4, "outputs": [ { - "output_type": "execute_result", "data": { - "text/plain": [ - " event_timestamp driver_id conv_rate acc_rate \\\n", - "0 2022-03-31 14:00:00+00:00 1005 0.313336 0.231481 \n", - "1 2022-03-31 15:00:00+00:00 1005 0.959499 0.942614 \n", - "2 2022-03-31 16:00:00+00:00 1005 0.231786 0.313516 \n", - "3 2022-03-31 17:00:00+00:00 1005 0.886911 0.531613 \n", - "4 2022-03-31 18:00:00+00:00 1005 0.574945 0.718223 \n", - "... ... ... ... ... \n", - "1802 2022-04-15 12:00:00+00:00 1001 0.521622 0.266667 \n", - "1803 2022-04-15 13:00:00+00:00 1001 0.003188 0.535501 \n", - "1804 2021-04-12 07:00:00+00:00 1001 0.709081 0.823138 \n", - "1805 2022-04-08 02:00:00+00:00 1003 0.033297 0.053268 \n", - "1806 2022-04-08 02:00:00+00:00 1003 0.033297 0.053268 \n", - "\n", - " avg_daily_trips created \n", - "0 303 2022-04-15 14:34:10.056 \n", - "1 842 2022-04-15 14:34:10.056 \n", - "2 782 2022-04-15 14:34:10.056 \n", - "3 634 2022-04-15 14:34:10.056 \n", - "4 441 2022-04-15 14:34:10.056 \n", - "... ... ... \n", - "1802 406 2022-04-15 14:34:10.056 \n", - "1803 593 2022-04-15 14:34:10.056 \n", - "1804 997 2022-04-15 14:34:10.056 \n", - "1805 534 2022-04-15 14:34:10.056 \n", - "1806 534 2022-04-15 14:34:10.056 \n", - "\n", - "[1807 rows x 6 columns]" - ], "text/html": [ "\n", - "
\n", + "
\n", "
\n", "
\n", "