We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
`Feature.proto` should have a description field
**Is your feature request related to a problem? Please describe.**
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]

I would like to attach a human-readable description to each field in a feature view. Since data scientists shop for individual features and not feature-views, it's useful to have documentation associated with each feature individually (rather than for the entire feature view). Persisting it here will allow us to surface them in various UIs.

**Describe the solution you'd like**
A clear and concise description of what you want to happen.

Similar to `Entity.proto`, we should add a description field to features and store them in the registry.

**Describe alternatives you've considered**
A clear and concise description of any alternative solutions or features you've considered.

For now, we're just using a `description` tag on each feature. This works, but it's clunky. It also means that in our UI, we have to remove certain tags before showing the raw tags to the users.

**Additional context**
Add any other context or screenshots about the feature request here.


--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `sdk/python/feast/field.py`
Content:
```
1 # Copyright 2022 The Feast Authors
2 #
3 # Licensed under the Apache License, Version 2.0 (the "License");
4 # you may not use this file except in compliance with the License.
5 # You may obtain a copy of the License at
6 #
7 #     https://www.apache.org/licenses/LICENSE-2.0
8 #
9 # Unless required by applicable law or agreed to in writing, software
10 # distributed under the License is distributed on an "AS IS" BASIS,
11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 # See the License for the specific language governing permissions and
13 # limitations under the License.
14 
15 from typing import Dict, Optional
16 
17 from typeguard import typechecked
18 
19 from feast.feature import Feature
20 from feast.protos.feast.core.Feature_pb2 import FeatureSpecV2 as FieldProto
21 from feast.types import FeastType, from_value_type
22 from feast.value_type import ValueType
23 
24 
25 @typechecked
26 class Field:
27     """
28     A Field represents a set of values with the same structure.
29 
30     Attributes:
31         name: The name of the field.
32         dtype: The type of the field, such as string or float.
33         tags: User-defined metadata in dictionary form.
34     """
35 
36     name: str
37     dtype: FeastType
38     tags: Dict[str, str]
39 
40     def __init__(
41         self,
42         *,
43         name: str,
44         dtype: FeastType,
45         tags: Optional[Dict[str, str]] = None,
46     ):
47         """
48         Creates a Field object.
49 
50         Args:
51             name: The name of the field.
52             dtype: The type of the field, such as string or float.
53             tags (optional): User-defined metadata in dictionary form.
54         """
55         self.name = name
56         self.dtype = dtype
57         self.tags = tags or {}
58 
59     def __eq__(self, other):
60         if type(self) != type(other):
61             return False
62 
63         if (
64             self.name != other.name
65             or self.dtype != other.dtype
66             or self.tags != other.tags
67         ):
68             return False
69         return True
70 
71     def __hash__(self):
72         return hash((self.name, hash(self.dtype)))
73 
74     def __lt__(self, other):
75         return self.name < other.name
76 
77     def __repr__(self):
78         return f"{self.name}-{self.dtype}"
79 
80     def __str__(self):
81         return f"Field(name={self.name}, dtype={self.dtype}, tags={self.tags})"
82 
83     def to_proto(self) -> FieldProto:
84         """Converts a Field object to its protobuf representation."""
85         value_type = self.dtype.to_value_type()
86         return FieldProto(name=self.name, value_type=value_type.value, tags=self.tags)
87 
88     @classmethod
89     def from_proto(cls, field_proto: FieldProto):
90         """
91         Creates a Field object from a protobuf representation.
92 
93         Args:
94             field_proto: FieldProto protobuf object
95         """
96         value_type = ValueType(field_proto.value_type)
97         return cls(
98             name=field_proto.name,
99             dtype=from_value_type(value_type=value_type),
100             tags=dict(field_proto.tags),
101         )
102 
103     @classmethod
104     def from_feature(cls, feature: Feature):
105         """
106         Creates a Field object from a Feature object.
107 
108         Args:
109             feature: Feature object to convert.
110         """
111         return cls(
112             name=feature.name, dtype=from_value_type(feature.dtype), tags=feature.labels
113         )
114
```

Path: `sdk/python/feast/templates/local/feature_repo/example_repo.py`
Content:
```
1 # This is an example feature definition file
2 
3 from datetime import timedelta
4 
5 import pandas as pd
6 
7 from feast import (
8     Entity,
9     FeatureService,
10     FeatureView,
11     Field,
12     FileSource,
13     PushSource,
14     RequestSource,
15 )
16 from feast.on_demand_feature_view import on_demand_feature_view
17 from feast.types import Float32, Float64, Int64
18 
19 # Define an entity for the driver. You can think of an entity as a primary key used to
20 # fetch features.
21 driver = Entity(name="driver", join_keys=["driver_id"])
22 
23 # Read data from parquet files. Parquet is convenient for local development mode. For
24 # production, you can use your favorite DWH, such as BigQuery. See Feast documentation
25 # for more info.
26 driver_stats_source = FileSource(
27     name="driver_hourly_stats_source",
28     path="%PARQUET_PATH%",
29     timestamp_field="event_timestamp",
30     created_timestamp_column="created",
31 )
32 
33 # Our parquet files contain sample data that includes a driver_id column, timestamps and
34 # three feature column. Here we define a Feature View that will allow us to serve this
35 # data to our model online.
36 driver_stats_fv = FeatureView(
37     # The unique name of this feature view. Two feature views in a single
38     # project cannot have the same name
39     name="driver_hourly_stats",
40     entities=[driver],
41     ttl=timedelta(days=1),
42     # The list of features defined below act as a schema to both define features
43     # for both materialization of features into a store, and are used as references
44     # during retrieval for building a training dataset or serving features
45     schema=[
46         Field(name="conv_rate", dtype=Float32),
47         Field(name="acc_rate", dtype=Float32),
48         Field(name="avg_daily_trips", dtype=Int64),
49     ],
50     online=True,
51     source=driver_stats_source,
52     # Tags are user defined key/value pairs that are attached to each
53     # feature view
54     tags={"team": "driver_performance"},
55 )
56 
57 # Define a request data source which encodes features / information only
58 # available at request time (e.g. part of the user initiated HTTP request)
59 input_request = RequestSource(
60     name="vals_to_add",
61     schema=[
62         Field(name="val_to_add", dtype=Int64),
63         Field(name="val_to_add_2", dtype=Int64),
64     ],
65 )
66 
67 
68 # Define an on demand feature view which can generate new features based on
69 # existing feature views and RequestSource features
70 @on_demand_feature_view(
71     sources=[driver_stats_fv, input_request],
72     schema=[
73         Field(name="conv_rate_plus_val1", dtype=Float64),
74         Field(name="conv_rate_plus_val2", dtype=Float64),
75     ],
76 )
77 def transformed_conv_rate(inputs: pd.DataFrame) -> pd.DataFrame:
78     df = pd.DataFrame()
79     df["conv_rate_plus_val1"] = inputs["conv_rate"] + inputs["val_to_add"]
80     df["conv_rate_plus_val2"] = inputs["conv_rate"] + inputs["val_to_add_2"]
81     return df
82 
83 
84 # This groups features into a model version
85 driver_activity_v1 = FeatureService(
86     name="driver_activity_v1",
87     features=[
88         driver_stats_fv[["conv_rate"]],  # Sub-selects a feature from a feature view
89         transformed_conv_rate,  # Selects all features from the feature view
90     ],
91 )
92 driver_activity_v2 = FeatureService(
93     name="driver_activity_v2", features=[driver_stats_fv, transformed_conv_rate]
94 )
95 
96 # Defines a way to push data (to be available offline, online or both) into Feast.
97 driver_stats_push_source = PushSource(
98     name="driver_stats_push_source",
99     batch_source=driver_stats_source,
100 )
101 
102 # Defines a slightly modified version of the feature view from above, where the source
103 # has been changed to the push source. This allows fresh features to be directly pushed
104 # to the online store for this feature view.
105 driver_stats_fresh_fv = FeatureView(
106     name="driver_hourly_stats_fresh",
107     entities=[driver],
108     ttl=timedelta(days=1),
109     schema=[
110         Field(name="conv_rate", dtype=Float32),
111         Field(name="acc_rate", dtype=Float32),
112         Field(name="avg_daily_trips", dtype=Int64),
113     ],
114     online=True,
115     source=driver_stats_push_source,  # Changed from above
116     tags={"team": "driver_performance"},
117 )
118 
119 
120 # Define an on demand feature view which can generate new features based on
121 # existing feature views and RequestSource features
122 @on_demand_feature_view(
123     sources=[driver_stats_fresh_fv, input_request],  # relies on fresh version of FV
124     schema=[
125         Field(name="conv_rate_plus_val1", dtype=Float64),
126         Field(name="conv_rate_plus_val2", dtype=Float64),
127     ],
128 )
129 def transformed_conv_rate_fresh(inputs: pd.DataFrame) -> pd.DataFrame:
130     df = pd.DataFrame()
131     df["conv_rate_plus_val1"] = inputs["conv_rate"] + inputs["val_to_add"]
132     df["conv_rate_plus_val2"] = inputs["conv_rate"] + inputs["val_to_add_2"]
133     return df
134 
135 
136 driver_activity_v3 = FeatureService(
137     name="driver_activity_v3",
138     features=[driver_stats_fresh_fv, transformed_conv_rate_fresh],
139 )
140
```

Path: `sdk/python/feast/feature.py`
Content:
```
1 # Copyright 2020 The Feast Authors
2 #
3 # Licensed under the Apache License, Version 2.0 (the "License");
4 # you may not use this file except in compliance with the License.
5 # You may obtain a copy of the License at
6 #
7 #     https://www.apache.org/licenses/LICENSE-2.0
8 #
9 # Unless required by applicable law or agreed to in writing, software
10 # distributed under the License is distributed on an "AS IS" BASIS,
11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 # See the License for the specific language governing permissions and
13 # limitations under the License.
14 
15 from typing import Dict, Optional
16 
17 from feast.protos.feast.core.Feature_pb2 import FeatureSpecV2 as FeatureSpecProto
18 from feast.protos.feast.types.Value_pb2 import ValueType as ValueTypeProto
19 from feast.value_type import ValueType
20 
21 
22 class Feature:
23     """
24     A Feature represents a class of serveable feature.
25 
26     Args:
27         name: Name of the feature.
28         dtype: The type of the feature, such as string or float.
29         labels (optional): User-defined metadata in dictionary form.
30     """
31 
32     def __init__(
33         self,
34         name: str,
35         dtype: ValueType,
36         labels: Optional[Dict[str, str]] = None,
37     ):
38         """Creates a Feature object."""
39         self._name = name
40         if not isinstance(dtype, ValueType):
41             raise ValueError("dtype is not a valid ValueType")
42         if dtype is ValueType.UNKNOWN:
43             raise ValueError(f"dtype cannot be {dtype}")
44         self._dtype = dtype
45         if labels is None:
46             self._labels = dict()
47         else:
48             self._labels = labels
49 
50     def __eq__(self, other):
51         if self.name != other.name or self.dtype != other.dtype:
52             return False
53         return True
54 
55     def __lt__(self, other):
56         return self.name < other.name
57 
58     def __repr__(self):
59         # return string representation of the reference
60         return f"{self.name}-{self.dtype}"
61 
62     def __str__(self):
63         # readable string of the reference
64         return f"Feature<{self.__repr__()}>"
65 
66     @property
67     def name(self):
68         """
69         Gets the name of this feature.
70         """
71         return self._name
72 
73     @property
74     def dtype(self) -> ValueType:
75         """
76         Gets the data type of this feature.
77         """
78         return self._dtype
79 
80     @property
81     def labels(self) -> Dict[str, str]:
82         """
83         Gets the labels of this feature.
84         """
85         return self._labels
86 
87     def to_proto(self) -> FeatureSpecProto:
88         """
89         Converts Feature object to its Protocol Buffer representation.
90 
91         Returns:
92             A FeatureSpecProto protobuf.
93         """
94         value_type = ValueTypeProto.Enum.Value(self.dtype.name)
95 
96         return FeatureSpecProto(
97             name=self.name,
98             value_type=value_type,
99             tags=self.labels,
100         )
101 
102     @classmethod
103     def from_proto(cls, feature_proto: FeatureSpecProto):
104         """
105         Args:
106             feature_proto: FeatureSpecV2 protobuf object
107 
108         Returns:
109             Feature object
110         """
111         feature = cls(
112             name=feature_proto.name,
113             dtype=ValueType(feature_proto.value_type),
114             labels=dict(feature_proto.tags),
115         )
116 
117         return feature
118
```
--- END FILES ---

Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.

Here is an example:

```diff
diff --git a/examples/server_async.py b/examples/server_async.py
--- a/examples/server_async.py
+++ b/examples/server_async.py
@@ -313,4 +313,4 @@
 
 
 if __name__ == "__main__":
-    asyncio.run(run_async_server("."), debug=True)
+    asyncio.run(run_async_server(), debug=True)
diff --git a/examples/server_sync.py b/examples/server_sync.py
--- a/examples/server_sync.py
+++ b/examples/server_sync.py
@@ -313,5 +313,5 @@
 
 
 if __name__ == "__main__":
-    server = run_sync_server(".")
+    server = run_sync_server()
     server.shutdown()

```

diff --git a/sdk/python/feast/feature.py b/sdk/python/feast/feature.py
--- a/sdk/python/feast/feature.py
+++ b/sdk/python/feast/feature.py
@@ -33,6 +33,7 @@
         self,
         name: str,
         dtype: ValueType,
+        description: str = "",
         labels: Optional[Dict[str, str]] = None,
     ):
         """Creates a Feature object."""
@@ -42,6 +43,7 @@
         if dtype is ValueType.UNKNOWN:
             raise ValueError(f"dtype cannot be {dtype}")
         self._dtype = dtype
+        self._description = description
         if labels is None:
             self._labels = dict()
         else:
@@ -77,6 +79,13 @@
         """
         return self._dtype
 
+    @property
+    def description(self) -> str:
+        """
+        Gets the description of the feature
+        """
+        return self._description
+
     @property
     def labels(self) -> Dict[str, str]:
         """
@@ -96,6 +105,7 @@
         return FeatureSpecProto(
             name=self.name,
             value_type=value_type,
+            description=self.description,
             tags=self.labels,
         )
 
@@ -111,6 +121,7 @@
         feature = cls(
             name=feature_proto.name,
             dtype=ValueType(feature_proto.value_type),
+            description=feature_proto.description,
             labels=dict(feature_proto.tags),
         )
 
diff --git a/sdk/python/feast/field.py b/sdk/python/feast/field.py
--- a/sdk/python/feast/field.py
+++ b/sdk/python/feast/field.py
@@ -30,7 +30,7 @@
     Attributes:
         name: The name of the field.
         dtype: The type of the field, such as string or float.
-        tags: User-defined metadata in dictionary form.
+        tags (optional): User-defined metadata in dictionary form.
     """
 
     name: str
@@ -42,6 +42,7 @@
         *,
         name: str,
         dtype: FeastType,
+        description: str = "",
         tags: Optional[Dict[str, str]] = None,
     ):
         """
@@ -54,6 +55,7 @@
         """
         self.name = name
         self.dtype = dtype
+        self.description = description
         self.tags = tags or {}
 
     def __eq__(self, other):
@@ -83,7 +85,12 @@
     def to_proto(self) -> FieldProto:
         """Converts a Field object to its protobuf representation."""
         value_type = self.dtype.to_value_type()
-        return FieldProto(name=self.name, value_type=value_type.value, tags=self.tags)
+        return FieldProto(
+            name=self.name,
+            value_type=value_type.value,
+            description=self.description,
+            tags=self.tags,
+        )
 
     @classmethod
     def from_proto(cls, field_proto: FieldProto):
@@ -109,5 +116,8 @@
             feature: Feature object to convert.
         """
         return cls(
-            name=feature.name, dtype=from_value_type(feature.dtype), tags=feature.labels
+            name=feature.name,
+            dtype=from_value_type(feature.dtype),
+            description=feature.description,
+            tags=feature.labels,
         )
diff --git a/sdk/python/feast/templates/local/feature_repo/example_repo.py b/sdk/python/feast/templates/local/feature_repo/example_repo.py
--- a/sdk/python/feast/templates/local/feature_repo/example_repo.py
+++ b/sdk/python/feast/templates/local/feature_repo/example_repo.py
@@ -45,7 +45,7 @@
     schema=[
         Field(name="conv_rate", dtype=Float32),
         Field(name="acc_rate", dtype=Float32),
-        Field(name="avg_daily_trips", dtype=Int64),
+        Field(name="avg_daily_trips", dtype=Int64, description="Average daily trips"),
     ],
     online=True,
     source=driver_stats_source,

{"golden_diff": "diff --git a/sdk/python/feast/feature.py b/sdk/python/feast/feature.py\n--- a/sdk/python/feast/feature.py\n+++ b/sdk/python/feast/feature.py\n@@ -33,6 +33,7 @@\n         self,\n         name: str,\n         dtype: ValueType,\n+        description: str = \"\",\n         labels: Optional[Dict[str, str]] = None,\n     ):\n         \"\"\"Creates a Feature object.\"\"\"\n@@ -42,6 +43,7 @@\n         if dtype is ValueType.UNKNOWN:\n             raise ValueError(f\"dtype cannot be {dtype}\")\n         self._dtype = dtype\n+        self._description = description\n         if labels is None:\n             self._labels = dict()\n         else:\n@@ -77,6 +79,13 @@\n         \"\"\"\n         return self._dtype\n \n+    @property\n+    def description(self) -> str:\n+        \"\"\"\n+        Gets the description of the feature\n+        \"\"\"\n+        return self._description\n+\n     @property\n     def labels(self) -> Dict[str, str]:\n         \"\"\"\n@@ -96,6 +105,7 @@\n         return FeatureSpecProto(\n             name=self.name,\n             value_type=value_type,\n+            description=self.description,\n             tags=self.labels,\n         )\n \n@@ -111,6 +121,7 @@\n         feature = cls(\n             name=feature_proto.name,\n             dtype=ValueType(feature_proto.value_type),\n+            description=feature_proto.description,\n             labels=dict(feature_proto.tags),\n         )\n \ndiff --git a/sdk/python/feast/field.py b/sdk/python/feast/field.py\n--- a/sdk/python/feast/field.py\n+++ b/sdk/python/feast/field.py\n@@ -30,7 +30,7 @@\n     Attributes:\n         name: The name of the field.\n         dtype: The type of the field, such as string or float.\n-        tags: User-defined metadata in dictionary form.\n+        tags (optional): User-defined metadata in dictionary form.\n     \"\"\"\n \n     name: str\n@@ -42,6 +42,7 @@\n         *,\n         name: str,\n         dtype: FeastType,\n+        description: str = \"\",\n         tags: Optional[Dict[str, str]] = None,\n     ):\n         \"\"\"\n@@ -54,6 +55,7 @@\n         \"\"\"\n         self.name = name\n         self.dtype = dtype\n+        self.description = description\n         self.tags = tags or {}\n \n     def __eq__(self, other):\n@@ -83,7 +85,12 @@\n     def to_proto(self) -> FieldProto:\n         \"\"\"Converts a Field object to its protobuf representation.\"\"\"\n         value_type = self.dtype.to_value_type()\n-        return FieldProto(name=self.name, value_type=value_type.value, tags=self.tags)\n+        return FieldProto(\n+            name=self.name,\n+            value_type=value_type.value,\n+            description=self.description,\n+            tags=self.tags,\n+        )\n \n     @classmethod\n     def from_proto(cls, field_proto: FieldProto):\n@@ -109,5 +116,8 @@\n             feature: Feature object to convert.\n         \"\"\"\n         return cls(\n-            name=feature.name, dtype=from_value_type(feature.dtype), tags=feature.labels\n+            name=feature.name,\n+            dtype=from_value_type(feature.dtype),\n+            description=feature.description,\n+            tags=feature.labels,\n         )\ndiff --git a/sdk/python/feast/templates/local/feature_repo/example_repo.py b/sdk/python/feast/templates/local/feature_repo/example_repo.py\n--- a/sdk/python/feast/templates/local/feature_repo/example_repo.py\n+++ b/sdk/python/feast/templates/local/feature_repo/example_repo.py\n@@ -45,7 +45,7 @@\n     schema=[\n         Field(name=\"conv_rate\", dtype=Float32),\n         Field(name=\"acc_rate\", dtype=Float32),\n-        Field(name=\"avg_daily_trips\", dtype=Int64),\n+        Field(name=\"avg_daily_trips\", dtype=Int64, description=\"Average daily trips\"),\n     ],\n     online=True,\n     source=driver_stats_source,\n", "issue": "`Feature.proto` should have a description field\n**Is your feature request related to a problem? Please describe.**\r\nA clear and concise description of what the problem is. Ex. I'm always frustrated when [...]\r\n\r\nI would like to attach a human-readable description to each field in a feature view. Since data scientists shop for individual features and not feature-views, it's useful to have documentation associated with each feature individually (rather than for the entire feature view). Persisting it here will allow us to surface them in various UIs.\r\n\r\n**Describe the solution you'd like**\r\nA clear and concise description of what you want to happen.\r\n\r\nSimilar to `Entity.proto`, we should add a description field to features and store them in the registry.\r\n\r\n**Describe alternatives you've considered**\r\nA clear and concise description of any alternative solutions or features you've considered.\r\n\r\nFor now, we're just using a `description` tag on each feature. This works, but it's clunky. It also means that in our UI, we have to remove certain tags before showing the raw tags to the users.\r\n\r\n**Additional context**\r\nAdd any other context or screenshots about the feature request here.\r\n\n", "before_files": [{"content": "# Copyright 2022 The Feast Authors\n#\n# Licensed under the Apache License, Version 2.0 (the \"License\");\n# you may not use this file except in compliance with the License.\n# You may obtain a copy of the License at\n#\n#     https://www.apache.org/licenses/LICENSE-2.0\n#\n# Unless required by applicable law or agreed to in writing, software\n# distributed under the License is distributed on an \"AS IS\" BASIS,\n# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n# See the License for the specific language governing permissions and\n# limitations under the License.\n\nfrom typing import Dict, Optional\n\nfrom typeguard import typechecked\n\nfrom feast.feature import Feature\nfrom feast.protos.feast.core.Feature_pb2 import FeatureSpecV2 as FieldProto\nfrom feast.types import FeastType, from_value_type\nfrom feast.value_type import ValueType\n\n\n@typechecked\nclass Field:\n    \"\"\"\n    A Field represents a set of values with the same structure.\n\n    Attributes:\n        name: The name of the field.\n        dtype: The type of the field, such as string or float.\n        tags: User-defined metadata in dictionary form.\n    \"\"\"\n\n    name: str\n    dtype: FeastType\n    tags: Dict[str, str]\n\n    def __init__(\n        self,\n        *,\n        name: str,\n        dtype: FeastType,\n        tags: Optional[Dict[str, str]] = None,\n    ):\n        \"\"\"\n        Creates a Field object.\n\n        Args:\n            name: The name of the field.\n            dtype: The type of the field, such as string or float.\n            tags (optional): User-defined metadata in dictionary form.\n        \"\"\"\n        self.name = name\n        self.dtype = dtype\n        self.tags = tags or {}\n\n    def __eq__(self, other):\n        if type(self) != type(other):\n            return False\n\n        if (\n            self.name != other.name\n            or self.dtype != other.dtype\n            or self.tags != other.tags\n        ):\n            return False\n        return True\n\n    def __hash__(self):\n        return hash((self.name, hash(self.dtype)))\n\n    def __lt__(self, other):\n        return self.name < other.name\n\n    def __repr__(self):\n        return f\"{self.name}-{self.dtype}\"\n\n    def __str__(self):\n        return f\"Field(name={self.name}, dtype={self.dtype}, tags={self.tags})\"\n\n    def to_proto(self) -> FieldProto:\n        \"\"\"Converts a Field object to its protobuf representation.\"\"\"\n        value_type = self.dtype.to_value_type()\n        return FieldProto(name=self.name, value_type=value_type.value, tags=self.tags)\n\n    @classmethod\n    def from_proto(cls, field_proto: FieldProto):\n        \"\"\"\n        Creates a Field object from a protobuf representation.\n\n        Args:\n            field_proto: FieldProto protobuf object\n        \"\"\"\n        value_type = ValueType(field_proto.value_type)\n        return cls(\n            name=field_proto.name,\n            dtype=from_value_type(value_type=value_type),\n            tags=dict(field_proto.tags),\n        )\n\n    @classmethod\n    def from_feature(cls, feature: Feature):\n        \"\"\"\n        Creates a Field object from a Feature object.\n\n        Args:\n            feature: Feature object to convert.\n        \"\"\"\n        return cls(\n            name=feature.name, dtype=from_value_type(feature.dtype), tags=feature.labels\n        )\n", "path": "sdk/python/feast/field.py"}, {"content": "# This is an example feature definition file\n\nfrom datetime import timedelta\n\nimport pandas as pd\n\nfrom feast import (\n    Entity,\n    FeatureService,\n    FeatureView,\n    Field,\n    FileSource,\n    PushSource,\n    RequestSource,\n)\nfrom feast.on_demand_feature_view import on_demand_feature_view\nfrom feast.types import Float32, Float64, Int64\n\n# Define an entity for the driver. You can think of an entity as a primary key used to\n# fetch features.\ndriver = Entity(name=\"driver\", join_keys=[\"driver_id\"])\n\n# Read data from parquet files. Parquet is convenient for local development mode. For\n# production, you can use your favorite DWH, such as BigQuery. See Feast documentation\n# for more info.\ndriver_stats_source = FileSource(\n    name=\"driver_hourly_stats_source\",\n    path=\"%PARQUET_PATH%\",\n    timestamp_field=\"event_timestamp\",\n    created_timestamp_column=\"created\",\n)\n\n# Our parquet files contain sample data that includes a driver_id column, timestamps and\n# three feature column. Here we define a Feature View that will allow us to serve this\n# data to our model online.\ndriver_stats_fv = FeatureView(\n    # The unique name of this feature view. Two feature views in a single\n    # project cannot have the same name\n    name=\"driver_hourly_stats\",\n    entities=[driver],\n    ttl=timedelta(days=1),\n    # The list of features defined below act as a schema to both define features\n    # for both materialization of features into a store, and are used as references\n    # during retrieval for building a training dataset or serving features\n    schema=[\n        Field(name=\"conv_rate\", dtype=Float32),\n        Field(name=\"acc_rate\", dtype=Float32),\n        Field(name=\"avg_daily_trips\", dtype=Int64),\n    ],\n    online=True,\n    source=driver_stats_source,\n    # Tags are user defined key/value pairs that are attached to each\n    # feature view\n    tags={\"team\": \"driver_performance\"},\n)\n\n# Define a request data source which encodes features / information only\n# available at request time (e.g. part of the user initiated HTTP request)\ninput_request = RequestSource(\n    name=\"vals_to_add\",\n    schema=[\n        Field(name=\"val_to_add\", dtype=Int64),\n        Field(name=\"val_to_add_2\", dtype=Int64),\n    ],\n)\n\n\n# Define an on demand feature view which can generate new features based on\n# existing feature views and RequestSource features\n@on_demand_feature_view(\n    sources=[driver_stats_fv, input_request],\n    schema=[\n        Field(name=\"conv_rate_plus_val1\", dtype=Float64),\n        Field(name=\"conv_rate_plus_val2\", dtype=Float64),\n    ],\n)\ndef transformed_conv_rate(inputs: pd.DataFrame) -> pd.DataFrame:\n    df = pd.DataFrame()\n    df[\"conv_rate_plus_val1\"] = inputs[\"conv_rate\"] + inputs[\"val_to_add\"]\n    df[\"conv_rate_plus_val2\"] = inputs[\"conv_rate\"] + inputs[\"val_to_add_2\"]\n    return df\n\n\n# This groups features into a model version\ndriver_activity_v1 = FeatureService(\n    name=\"driver_activity_v1\",\n    features=[\n        driver_stats_fv[[\"conv_rate\"]],  # Sub-selects a feature from a feature view\n        transformed_conv_rate,  # Selects all features from the feature view\n    ],\n)\ndriver_activity_v2 = FeatureService(\n    name=\"driver_activity_v2\", features=[driver_stats_fv, transformed_conv_rate]\n)\n\n# Defines a way to push data (to be available offline, online or both) into Feast.\ndriver_stats_push_source = PushSource(\n    name=\"driver_stats_push_source\",\n    batch_source=driver_stats_source,\n)\n\n# Defines a slightly modified version of the feature view from above, where the source\n# has been changed to the push source. This allows fresh features to be directly pushed\n# to the online store for this feature view.\ndriver_stats_fresh_fv = FeatureView(\n    name=\"driver_hourly_stats_fresh\",\n    entities=[driver],\n    ttl=timedelta(days=1),\n    schema=[\n        Field(name=\"conv_rate\", dtype=Float32),\n        Field(name=\"acc_rate\", dtype=Float32),\n        Field(name=\"avg_daily_trips\", dtype=Int64),\n    ],\n    online=True,\n    source=driver_stats_push_source,  # Changed from above\n    tags={\"team\": \"driver_performance\"},\n)\n\n\n# Define an on demand feature view which can generate new features based on\n# existing feature views and RequestSource features\n@on_demand_feature_view(\n    sources=[driver_stats_fresh_fv, input_request],  # relies on fresh version of FV\n    schema=[\n        Field(name=\"conv_rate_plus_val1\", dtype=Float64),\n        Field(name=\"conv_rate_plus_val2\", dtype=Float64),\n    ],\n)\ndef transformed_conv_rate_fresh(inputs: pd.DataFrame) -> pd.DataFrame:\n    df = pd.DataFrame()\n    df[\"conv_rate_plus_val1\"] = inputs[\"conv_rate\"] + inputs[\"val_to_add\"]\n    df[\"conv_rate_plus_val2\"] = inputs[\"conv_rate\"] + inputs[\"val_to_add_2\"]\n    return df\n\n\ndriver_activity_v3 = FeatureService(\n    name=\"driver_activity_v3\",\n    features=[driver_stats_fresh_fv, transformed_conv_rate_fresh],\n)\n", "path": "sdk/python/feast/templates/local/feature_repo/example_repo.py"}, {"content": "# Copyright 2020 The Feast Authors\n#\n# Licensed under the Apache License, Version 2.0 (the \"License\");\n# you may not use this file except in compliance with the License.\n# You may obtain a copy of the License at\n#\n#     https://www.apache.org/licenses/LICENSE-2.0\n#\n# Unless required by applicable law or agreed to in writing, software\n# distributed under the License is distributed on an \"AS IS\" BASIS,\n# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n# See the License for the specific language governing permissions and\n# limitations under the License.\n\nfrom typing import Dict, Optional\n\nfrom feast.protos.feast.core.Feature_pb2 import FeatureSpecV2 as FeatureSpecProto\nfrom feast.protos.feast.types.Value_pb2 import ValueType as ValueTypeProto\nfrom feast.value_type import ValueType\n\n\nclass Feature:\n    \"\"\"\n    A Feature represents a class of serveable feature.\n\n    Args:\n        name: Name of the feature.\n        dtype: The type of the feature, such as string or float.\n        labels (optional): User-defined metadata in dictionary form.\n    \"\"\"\n\n    def __init__(\n        self,\n        name: str,\n        dtype: ValueType,\n        labels: Optional[Dict[str, str]] = None,\n    ):\n        \"\"\"Creates a Feature object.\"\"\"\n        self._name = name\n        if not isinstance(dtype, ValueType):\n            raise ValueError(\"dtype is not a valid ValueType\")\n        if dtype is ValueType.UNKNOWN:\n            raise ValueError(f\"dtype cannot be {dtype}\")\n        self._dtype = dtype\n        if labels is None:\n            self._labels = dict()\n        else:\n            self._labels = labels\n\n    def __eq__(self, other):\n        if self.name != other.name or self.dtype != other.dtype:\n            return False\n        return True\n\n    def __lt__(self, other):\n        return self.name < other.name\n\n    def __repr__(self):\n        # return string representation of the reference\n        return f\"{self.name}-{self.dtype}\"\n\n    def __str__(self):\n        # readable string of the reference\n        return f\"Feature<{self.__repr__()}>\"\n\n    @property\n    def name(self):\n        \"\"\"\n        Gets the name of this feature.\n        \"\"\"\n        return self._name\n\n    @property\n    def dtype(self) -> ValueType:\n        \"\"\"\n        Gets the data type of this feature.\n        \"\"\"\n        return self._dtype\n\n    @property\n    def labels(self) -> Dict[str, str]:\n        \"\"\"\n        Gets the labels of this feature.\n        \"\"\"\n        return self._labels\n\n    def to_proto(self) -> FeatureSpecProto:\n        \"\"\"\n        Converts Feature object to its Protocol Buffer representation.\n\n        Returns:\n            A FeatureSpecProto protobuf.\n        \"\"\"\n        value_type = ValueTypeProto.Enum.Value(self.dtype.name)\n\n        return FeatureSpecProto(\n            name=self.name,\n            value_type=value_type,\n            tags=self.labels,\n        )\n\n    @classmethod\n    def from_proto(cls, feature_proto: FeatureSpecProto):\n        \"\"\"\n        Args:\n            feature_proto: FeatureSpecV2 protobuf object\n\n        Returns:\n            Feature object\n        \"\"\"\n        feature = cls(\n            name=feature_proto.name,\n            dtype=ValueType(feature_proto.value_type),\n            labels=dict(feature_proto.tags),\n        )\n\n        return feature\n", "path": "sdk/python/feast/feature.py"}], "after_files": [{"content": "# Copyright 2022 The Feast Authors\n#\n# Licensed under the Apache License, Version 2.0 (the \"License\");\n# you may not use this file except in compliance with the License.\n# You may obtain a copy of the License at\n#\n#     https://www.apache.org/licenses/LICENSE-2.0\n#\n# Unless required by applicable law or agreed to in writing, software\n# distributed under the License is distributed on an \"AS IS\" BASIS,\n# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n# See the License for the specific language governing permissions and\n# limitations under the License.\n\nfrom typing import Dict, Optional\n\nfrom typeguard import typechecked\n\nfrom feast.feature import Feature\nfrom feast.protos.feast.core.Feature_pb2 import FeatureSpecV2 as FieldProto\nfrom feast.types import FeastType, from_value_type\nfrom feast.value_type import ValueType\n\n\n@typechecked\nclass Field:\n    \"\"\"\n    A Field represents a set of values with the same structure.\n\n    Attributes:\n        name: The name of the field.\n        dtype: The type of the field, such as string or float.\n        tags (optional): User-defined metadata in dictionary form.\n    \"\"\"\n\n    name: str\n    dtype: FeastType\n    tags: Dict[str, str]\n\n    def __init__(\n        self,\n        *,\n        name: str,\n        dtype: FeastType,\n        description: str = \"\",\n        tags: Optional[Dict[str, str]] = None,\n    ):\n        \"\"\"\n        Creates a Field object.\n\n        Args:\n            name: The name of the field.\n            dtype: The type of the field, such as string or float.\n            tags (optional): User-defined metadata in dictionary form.\n        \"\"\"\n        self.name = name\n        self.dtype = dtype\n        self.description = description\n        self.tags = tags or {}\n\n    def __eq__(self, other):\n        if type(self) != type(other):\n            return False\n\n        if (\n            self.name != other.name\n            or self.dtype != other.dtype\n            or self.tags != other.tags\n        ):\n            return False\n        return True\n\n    def __hash__(self):\n        return hash((self.name, hash(self.dtype)))\n\n    def __lt__(self, other):\n        return self.name < other.name\n\n    def __repr__(self):\n        return f\"{self.name}-{self.dtype}\"\n\n    def __str__(self):\n        return f\"Field(name={self.name}, dtype={self.dtype}, tags={self.tags})\"\n\n    def to_proto(self) -> FieldProto:\n        \"\"\"Converts a Field object to its protobuf representation.\"\"\"\n        value_type = self.dtype.to_value_type()\n        return FieldProto(\n            name=self.name,\n            value_type=value_type.value,\n            description=self.description,\n            tags=self.tags,\n        )\n\n    @classmethod\n    def from_proto(cls, field_proto: FieldProto):\n        \"\"\"\n        Creates a Field object from a protobuf representation.\n\n        Args:\n            field_proto: FieldProto protobuf object\n        \"\"\"\n        value_type = ValueType(field_proto.value_type)\n        return cls(\n            name=field_proto.name,\n            dtype=from_value_type(value_type=value_type),\n            tags=dict(field_proto.tags),\n        )\n\n    @classmethod\n    def from_feature(cls, feature: Feature):\n        \"\"\"\n        Creates a Field object from a Feature object.\n\n        Args:\n            feature: Feature object to convert.\n        \"\"\"\n        return cls(\n            name=feature.name,\n            dtype=from_value_type(feature.dtype),\n            description=feature.description,\n            tags=feature.labels,\n        )\n", "path": "sdk/python/feast/field.py"}, {"content": "# This is an example feature definition file\n\nfrom datetime import timedelta\n\nimport pandas as pd\n\nfrom feast import (\n    Entity,\n    FeatureService,\n    FeatureView,\n    Field,\n    FileSource,\n    PushSource,\n    RequestSource,\n)\nfrom feast.on_demand_feature_view import on_demand_feature_view\nfrom feast.types import Float32, Float64, Int64\n\n# Define an entity for the driver. You can think of an entity as a primary key used to\n# fetch features.\ndriver = Entity(name=\"driver\", join_keys=[\"driver_id\"])\n\n# Read data from parquet files. Parquet is convenient for local development mode. For\n# production, you can use your favorite DWH, such as BigQuery. See Feast documentation\n# for more info.\ndriver_stats_source = FileSource(\n    name=\"driver_hourly_stats_source\",\n    path=\"%PARQUET_PATH%\",\n    timestamp_field=\"event_timestamp\",\n    created_timestamp_column=\"created\",\n)\n\n# Our parquet files contain sample data that includes a driver_id column, timestamps and\n# three feature column. Here we define a Feature View that will allow us to serve this\n# data to our model online.\ndriver_stats_fv = FeatureView(\n    # The unique name of this feature view. Two feature views in a single\n    # project cannot have the same name\n    name=\"driver_hourly_stats\",\n    entities=[driver],\n    ttl=timedelta(days=1),\n    # The list of features defined below act as a schema to both define features\n    # for both materialization of features into a store, and are used as references\n    # during retrieval for building a training dataset or serving features\n    schema=[\n        Field(name=\"conv_rate\", dtype=Float32),\n        Field(name=\"acc_rate\", dtype=Float32),\n        Field(name=\"avg_daily_trips\", dtype=Int64, description=\"Average daily trips\"),\n    ],\n    online=True,\n    source=driver_stats_source,\n    # Tags are user defined key/value pairs that are attached to each\n    # feature view\n    tags={\"team\": \"driver_performance\"},\n)\n\n# Define a request data source which encodes features / information only\n# available at request time (e.g. part of the user initiated HTTP request)\ninput_request = RequestSource(\n    name=\"vals_to_add\",\n    schema=[\n        Field(name=\"val_to_add\", dtype=Int64),\n        Field(name=\"val_to_add_2\", dtype=Int64),\n    ],\n)\n\n\n# Define an on demand feature view which can generate new features based on\n# existing feature views and RequestSource features\n@on_demand_feature_view(\n    sources=[driver_stats_fv, input_request],\n    schema=[\n        Field(name=\"conv_rate_plus_val1\", dtype=Float64),\n        Field(name=\"conv_rate_plus_val2\", dtype=Float64),\n    ],\n)\ndef transformed_conv_rate(inputs: pd.DataFrame) -> pd.DataFrame:\n    df = pd.DataFrame()\n    df[\"conv_rate_plus_val1\"] = inputs[\"conv_rate\"] + inputs[\"val_to_add\"]\n    df[\"conv_rate_plus_val2\"] = inputs[\"conv_rate\"] + inputs[\"val_to_add_2\"]\n    return df\n\n\n# This groups features into a model version\ndriver_activity_v1 = FeatureService(\n    name=\"driver_activity_v1\",\n    features=[\n        driver_stats_fv[[\"conv_rate\"]],  # Sub-selects a feature from a feature view\n        transformed_conv_rate,  # Selects all features from the feature view\n    ],\n)\ndriver_activity_v2 = FeatureService(\n    name=\"driver_activity_v2\", features=[driver_stats_fv, transformed_conv_rate]\n)\n\n# Defines a way to push data (to be available offline, online or both) into Feast.\ndriver_stats_push_source = PushSource(\n    name=\"driver_stats_push_source\",\n    batch_source=driver_stats_source,\n)\n\n# Defines a slightly modified version of the feature view from above, where the source\n# has been changed to the push source. This allows fresh features to be directly pushed\n# to the online store for this feature view.\ndriver_stats_fresh_fv = FeatureView(\n    name=\"driver_hourly_stats_fresh\",\n    entities=[driver],\n    ttl=timedelta(days=1),\n    schema=[\n        Field(name=\"conv_rate\", dtype=Float32),\n        Field(name=\"acc_rate\", dtype=Float32),\n        Field(name=\"avg_daily_trips\", dtype=Int64),\n    ],\n    online=True,\n    source=driver_stats_push_source,  # Changed from above\n    tags={\"team\": \"driver_performance\"},\n)\n\n\n# Define an on demand feature view which can generate new features based on\n# existing feature views and RequestSource features\n@on_demand_feature_view(\n    sources=[driver_stats_fresh_fv, input_request],  # relies on fresh version of FV\n    schema=[\n        Field(name=\"conv_rate_plus_val1\", dtype=Float64),\n        Field(name=\"conv_rate_plus_val2\", dtype=Float64),\n    ],\n)\ndef transformed_conv_rate_fresh(inputs: pd.DataFrame) -> pd.DataFrame:\n    df = pd.DataFrame()\n    df[\"conv_rate_plus_val1\"] = inputs[\"conv_rate\"] + inputs[\"val_to_add\"]\n    df[\"conv_rate_plus_val2\"] = inputs[\"conv_rate\"] + inputs[\"val_to_add_2\"]\n    return df\n\n\ndriver_activity_v3 = FeatureService(\n    name=\"driver_activity_v3\",\n    features=[driver_stats_fresh_fv, transformed_conv_rate_fresh],\n)\n", "path": "sdk/python/feast/templates/local/feature_repo/example_repo.py"}, {"content": "# Copyright 2020 The Feast Authors\n#\n# Licensed under the Apache License, Version 2.0 (the \"License\");\n# you may not use this file except in compliance with the License.\n# You may obtain a copy of the License at\n#\n#     https://www.apache.org/licenses/LICENSE-2.0\n#\n# Unless required by applicable law or agreed to in writing, software\n# distributed under the License is distributed on an \"AS IS\" BASIS,\n# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n# See the License for the specific language governing permissions and\n# limitations under the License.\n\nfrom typing import Dict, Optional\n\nfrom feast.protos.feast.core.Feature_pb2 import FeatureSpecV2 as FeatureSpecProto\nfrom feast.protos.feast.types.Value_pb2 import ValueType as ValueTypeProto\nfrom feast.value_type import ValueType\n\n\nclass Feature:\n    \"\"\"\n    A Feature represents a class of serveable feature.\n\n    Args:\n        name: Name of the feature.\n        dtype: The type of the feature, such as string or float.\n        labels (optional): User-defined metadata in dictionary form.\n    \"\"\"\n\n    def __init__(\n        self,\n        name: str,\n        dtype: ValueType,\n        description: str = \"\",\n        labels: Optional[Dict[str, str]] = None,\n    ):\n        \"\"\"Creates a Feature object.\"\"\"\n        self._name = name\n        if not isinstance(dtype, ValueType):\n            raise ValueError(\"dtype is not a valid ValueType\")\n        if dtype is ValueType.UNKNOWN:\n            raise ValueError(f\"dtype cannot be {dtype}\")\n        self._dtype = dtype\n        self._description = description\n        if labels is None:\n            self._labels = dict()\n        else:\n            self._labels = labels\n\n    def __eq__(self, other):\n        if self.name != other.name or self.dtype != other.dtype:\n            return False\n        return True\n\n    def __lt__(self, other):\n        return self.name < other.name\n\n    def __repr__(self):\n        # return string representation of the reference\n        return f\"{self.name}-{self.dtype}\"\n\n    def __str__(self):\n        # readable string of the reference\n        return f\"Feature<{self.__repr__()}>\"\n\n    @property\n    def name(self):\n        \"\"\"\n        Gets the name of this feature.\n        \"\"\"\n        return self._name\n\n    @property\n    def dtype(self) -> ValueType:\n        \"\"\"\n        Gets the data type of this feature.\n        \"\"\"\n        return self._dtype\n\n    @property\n    def description(self) -> str:\n        \"\"\"\n        Gets the description of the feature\n        \"\"\"\n        return self._description\n\n    @property\n    def labels(self) -> Dict[str, str]:\n        \"\"\"\n        Gets the labels of this feature.\n        \"\"\"\n        return self._labels\n\n    def to_proto(self) -> FeatureSpecProto:\n        \"\"\"\n        Converts Feature object to its Protocol Buffer representation.\n\n        Returns:\n            A FeatureSpecProto protobuf.\n        \"\"\"\n        value_type = ValueTypeProto.Enum.Value(self.dtype.name)\n\n        return FeatureSpecProto(\n            name=self.name,\n            value_type=value_type,\n            description=self.description,\n            tags=self.labels,\n        )\n\n    @classmethod\n    def from_proto(cls, feature_proto: FeatureSpecProto):\n        \"\"\"\n        Args:\n            feature_proto: FeatureSpecV2 protobuf object\n\n        Returns:\n            Feature object\n        \"\"\"\n        feature = cls(\n            name=feature_proto.name,\n            dtype=ValueType(feature_proto.value_type),\n            description=feature_proto.description,\n            labels=dict(feature_proto.tags),\n        )\n\n        return feature\n", "path": "sdk/python/feast/feature.py"}]}