We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
Keep labels in Field api
I found that new api 'Field' will take place of 'Feature' in 0.21+ feast. but `Field` only have 'name' and 'dtype' parameters. The parameter 'labels' is disappeared. 
In my use case 'labels' is very import.  'labels' stores the default value, descriptions,and other things. for example

```python
comic_feature_view = FeatureView(
    name="comic_featureV1",
    entities=["item_id"],
    ttl=Duration(seconds=86400 * 1),
    features=[
        Feature(name="channel_id", dtype=ValueType.INT32, labels={"default": "14", "desc":"channel"}),
        Feature(name="keyword_weight", dtype=ValueType.FLOAT, labels={"default": "0.0", "desc":"keyword's weight"}),
        Feature(name="comic_vectorv1", dtype=ValueType.FLOAT, labels={"default": ";".join(["0.0" for i in range(32)]), "desc":"deepwalk vector","faiss_index":"/data/faiss_index/comic_featureV1__comic_vectorv1.index"}),
        Feature(name="comic_vectorv2", dtype=ValueType.FLOAT, labels={"default": ";".join(["0.0" for i in range(32)]), "desc":"word2vec vector","faiss_index":"/data/faiss_index/comic_featureV1__comic_vectorv2.index"}),
        Feature(name="gender", dtype=ValueType.INT32, labels={"default": "0", "desc":" 0-femal 1-male"}),
        Feature(name="pub_time", dtype=ValueType.STRING, labels={"default": "1970-01-01 00:00:00", "desc":"comic's publish time"}),
        Feature(name="update_time", dtype=ValueType.STRING, labels={"default": "1970-01-01 00:00:00", "desc":"comic's update time"}),
        Feature(name="view_cnt", dtype=ValueType.INT64, labels={"default": "0", "desc":"comic's hot score"}),
        Feature(name="collect_cnt", dtype=ValueType.INT64, labels={"default": "0", "desc":"collect count"}),
        Feature(name="source_id", dtype=ValueType.INT32, labels={"default": "0", "desc":"comic is from(0-unknown，1-japen，2-usa，3- other)"}),
```

So please keep the parameter 'labels' in Field api


--- 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 feast.feature import Feature
16 from feast.protos.feast.core.Feature_pb2 import FeatureSpecV2 as FieldProto
17 from feast.types import FeastType, from_value_type
18 from feast.value_type import ValueType
19 
20 
21 class Field:
22     """
23     A Field represents a set of values with the same structure.
24 
25     Attributes:
26         name: The name of the field.
27         dtype: The type of the field, such as string or float.
28     """
29 
30     name: str
31     dtype: FeastType
32 
33     def __init__(
34         self, *, name: str, dtype: FeastType,
35     ):
36         """
37         Creates a Field object.
38 
39         Args:
40             name: The name of the field.
41             dtype: The type of the field, such as string or float.
42         """
43         self.name = name
44         self.dtype = dtype
45 
46     def __eq__(self, other):
47         if self.name != other.name or self.dtype != other.dtype:
48             return False
49         return True
50 
51     def __hash__(self):
52         return hash((self.name, hash(self.dtype)))
53 
54     def __lt__(self, other):
55         return self.name < other.name
56 
57     def __repr__(self):
58         return f"{self.name}-{self.dtype}"
59 
60     def __str__(self):
61         return f"Field(name={self.name}, dtype={self.dtype})"
62 
63     def to_proto(self) -> FieldProto:
64         """Converts a Field object to its protobuf representation."""
65         value_type = self.dtype.to_value_type()
66         return FieldProto(name=self.name, value_type=value_type.value)
67 
68     @classmethod
69     def from_proto(cls, field_proto: FieldProto):
70         """
71         Creates a Field object from a protobuf representation.
72 
73         Args:
74             field_proto: FieldProto protobuf object
75         """
76         value_type = ValueType(field_proto.value_type)
77         return cls(name=field_proto.name, dtype=from_value_type(value_type=value_type))
78 
79     @classmethod
80     def from_feature(cls, feature: Feature):
81         """
82         Creates a Field object from a Feature object.
83 
84         Args:
85             feature: Feature object to convert.
86         """
87         return cls(name=feature.name, dtype=from_value_type(feature.dtype))
88
```

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, name: str, dtype: ValueType, labels: Optional[Dict[str, str]] = None,
34     ):
35         """Creates a Feature object."""
36         self._name = name
37         if not isinstance(dtype, ValueType):
38             raise ValueError("dtype is not a valid ValueType")
39         if dtype is ValueType.UNKNOWN:
40             raise ValueError(f"dtype cannot be {dtype}")
41         self._dtype = dtype
42         if labels is None:
43             self._labels = dict()
44         else:
45             self._labels = labels
46 
47     def __eq__(self, other):
48         if self.name != other.name or self.dtype != other.dtype:
49             return False
50         return True
51 
52     def __lt__(self, other):
53         return self.name < other.name
54 
55     def __repr__(self):
56         # return string representation of the reference
57         return f"{self.name}-{self.dtype}"
58 
59     def __str__(self):
60         # readable string of the reference
61         return f"Feature<{self.__repr__()}>"
62 
63     @property
64     def name(self):
65         """
66         Gets the name of this feature.
67         """
68         return self._name
69 
70     @property
71     def dtype(self) -> ValueType:
72         """
73         Gets the data type of this feature.
74         """
75         return self._dtype
76 
77     @property
78     def labels(self) -> Dict[str, str]:
79         """
80         Gets the labels of this feature.
81         """
82         return self._labels
83 
84     def to_proto(self) -> FeatureSpecProto:
85         """
86         Converts Feature object to its Protocol Buffer representation.
87 
88         Returns:
89             A FeatureSpecProto protobuf.
90         """
91         value_type = ValueTypeProto.Enum.Value(self.dtype.name)
92 
93         return FeatureSpecProto(
94             name=self.name, value_type=value_type, labels=self.labels,
95         )
96 
97     @classmethod
98     def from_proto(cls, feature_proto: FeatureSpecProto):
99         """
100         Args:
101             feature_proto: FeatureSpecV2 protobuf object
102 
103         Returns:
104             Feature object
105         """
106         feature = cls(
107             name=feature_proto.name,
108             dtype=ValueType(feature_proto.value_type),
109             labels=dict(feature_proto.labels),
110         )
111 
112         return feature
113
```
--- 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
@@ -91,7 +91,7 @@
         value_type = ValueTypeProto.Enum.Value(self.dtype.name)
 
         return FeatureSpecProto(
-            name=self.name, value_type=value_type, labels=self.labels,
+            name=self.name, value_type=value_type, tags=self.labels,
         )
 
     @classmethod
@@ -106,7 +106,7 @@
         feature = cls(
             name=feature_proto.name,
             dtype=ValueType(feature_proto.value_type),
-            labels=dict(feature_proto.labels),
+            labels=dict(feature_proto.tags),
         )
 
         return feature
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
@@ -12,6 +12,8 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
+from typing import Dict, Optional
+
 from feast.feature import Feature
 from feast.protos.feast.core.Feature_pb2 import FeatureSpecV2 as FieldProto
 from feast.types import FeastType, from_value_type
@@ -25,13 +27,15 @@
     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.
     """
 
     name: str
     dtype: FeastType
+    tags: Dict[str, str]
 
     def __init__(
-        self, *, name: str, dtype: FeastType,
+        self, *, name: str, dtype: FeastType, tags: Optional[Dict[str, str]] = None,
     ):
         """
         Creates a Field object.
@@ -39,12 +43,18 @@
         Args:
             name: The name of the field.
             dtype: The type of the field, such as string or float.
+            tags (optional): User-defined metadata in dictionary form.
         """
         self.name = name
         self.dtype = dtype
+        self.tags = tags or {}
 
     def __eq__(self, other):
-        if self.name != other.name or self.dtype != other.dtype:
+        if (
+            self.name != other.name
+            or self.dtype != other.dtype
+            or self.tags != other.tags
+        ):
             return False
         return True
 
@@ -58,12 +68,12 @@
         return f"{self.name}-{self.dtype}"
 
     def __str__(self):
-        return f"Field(name={self.name}, dtype={self.dtype})"
+        return f"Field(name={self.name}, dtype={self.dtype}, tags={self.tags})"
 
     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)
+        return FieldProto(name=self.name, value_type=value_type.value, tags=self.tags)
 
     @classmethod
     def from_proto(cls, field_proto: FieldProto):
@@ -74,7 +84,11 @@
             field_proto: FieldProto protobuf object
         """
         value_type = ValueType(field_proto.value_type)
-        return cls(name=field_proto.name, dtype=from_value_type(value_type=value_type))
+        return cls(
+            name=field_proto.name,
+            dtype=from_value_type(value_type=value_type),
+            tags=dict(field_proto.tags),
+        )
 
     @classmethod
     def from_feature(cls, feature: Feature):
@@ -84,4 +98,6 @@
         Args:
             feature: Feature object to convert.
         """
-        return cls(name=feature.name, dtype=from_value_type(feature.dtype))
+        return cls(
+            name=feature.name, dtype=from_value_type(feature.dtype), tags=feature.labels
+        )

{"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@@ -91,7 +91,7 @@\n         value_type = ValueTypeProto.Enum.Value(self.dtype.name)\n \n         return FeatureSpecProto(\n-            name=self.name, value_type=value_type, labels=self.labels,\n+            name=self.name, value_type=value_type, tags=self.labels,\n         )\n \n     @classmethod\n@@ -106,7 +106,7 @@\n         feature = cls(\n             name=feature_proto.name,\n             dtype=ValueType(feature_proto.value_type),\n-            labels=dict(feature_proto.labels),\n+            labels=dict(feature_proto.tags),\n         )\n \n         return feature\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@@ -12,6 +12,8 @@\n # See the License for the specific language governing permissions and\n # limitations under the License.\n \n+from typing import Dict, Optional\n+\n from feast.feature import Feature\n from feast.protos.feast.core.Feature_pb2 import FeatureSpecV2 as FieldProto\n from feast.types import FeastType, from_value_type\n@@ -25,13 +27,15 @@\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, *, name: str, dtype: FeastType,\n+        self, *, name: str, dtype: FeastType, tags: Optional[Dict[str, str]] = None,\n     ):\n         \"\"\"\n         Creates a Field object.\n@@ -39,12 +43,18 @@\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 self.name != other.name or self.dtype != other.dtype:\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@@ -58,12 +68,12 @@\n         return f\"{self.name}-{self.dtype}\"\n \n     def __str__(self):\n-        return f\"Field(name={self.name}, dtype={self.dtype})\"\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)\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@@ -74,7 +84,11 @@\n             field_proto: FieldProto protobuf object\n         \"\"\"\n         value_type = ValueType(field_proto.value_type)\n-        return cls(name=field_proto.name, dtype=from_value_type(value_type=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@@ -84,4 +98,6 @@\n         Args:\n             feature: Feature object to convert.\n         \"\"\"\n-        return cls(name=feature.name, dtype=from_value_type(feature.dtype))\n+        return cls(\n+            name=feature.name, dtype=from_value_type(feature.dtype), tags=feature.labels\n+        )\n", "issue": "Keep labels in Field api\nI found that new api 'Field' will take place of 'Feature' in 0.21+ feast. but `Field` only have 'name' and 'dtype' parameters. The parameter 'labels' is disappeared. \r\nIn my use case 'labels' is very import.  'labels' stores the default value, descriptions,and other things. for example\r\n\r\n```python\r\ncomic_feature_view = FeatureView(\r\n    name=\"comic_featureV1\",\r\n    entities=[\"item_id\"],\r\n    ttl=Duration(seconds=86400 * 1),\r\n    features=[\r\n        Feature(name=\"channel_id\", dtype=ValueType.INT32, labels={\"default\": \"14\", \"desc\":\"channel\"}),\r\n        Feature(name=\"keyword_weight\", dtype=ValueType.FLOAT, labels={\"default\": \"0.0\", \"desc\":\"keyword's weight\"}),\r\n        Feature(name=\"comic_vectorv1\", dtype=ValueType.FLOAT, labels={\"default\": \";\".join([\"0.0\" for i in range(32)]), \"desc\":\"deepwalk vector\",\"faiss_index\":\"/data/faiss_index/comic_featureV1__comic_vectorv1.index\"}),\r\n        Feature(name=\"comic_vectorv2\", dtype=ValueType.FLOAT, labels={\"default\": \";\".join([\"0.0\" for i in range(32)]), \"desc\":\"word2vec vector\",\"faiss_index\":\"/data/faiss_index/comic_featureV1__comic_vectorv2.index\"}),\r\n        Feature(name=\"gender\", dtype=ValueType.INT32, labels={\"default\": \"0\", \"desc\":\" 0-femal 1-male\"}),\r\n        Feature(name=\"pub_time\", dtype=ValueType.STRING, labels={\"default\": \"1970-01-01 00:00:00\", \"desc\":\"comic's publish time\"}),\r\n        Feature(name=\"update_time\", dtype=ValueType.STRING, labels={\"default\": \"1970-01-01 00:00:00\", \"desc\":\"comic's update time\"}),\r\n        Feature(name=\"view_cnt\", dtype=ValueType.INT64, labels={\"default\": \"0\", \"desc\":\"comic's hot score\"}),\r\n        Feature(name=\"collect_cnt\", dtype=ValueType.INT64, labels={\"default\": \"0\", \"desc\":\"collect count\"}),\r\n        Feature(name=\"source_id\", dtype=ValueType.INT32, labels={\"default\": \"0\", \"desc\":\"comic is from(0-unknown\uff0c1-japen\uff0c2-usa\uff0c3- other)\"}),\r\n```\r\n\r\nSo please keep the parameter 'labels' in Field api\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 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\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    \"\"\"\n\n    name: str\n    dtype: FeastType\n\n    def __init__(\n        self, *, name: str, dtype: FeastType,\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        \"\"\"\n        self.name = name\n        self.dtype = dtype\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 __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})\"\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)\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(name=field_proto.name, dtype=from_value_type(value_type=value_type))\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(name=feature.name, dtype=from_value_type(feature.dtype))\n", "path": "sdk/python/feast/field.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, name: str, dtype: ValueType, 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, value_type=value_type, labels=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.labels),\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 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\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, *, name: str, dtype: FeastType, 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 (\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": "# 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, name: str, dtype: ValueType, 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, value_type=value_type, 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"}]}