MCPcopy Index your code
hub / github.com/feast-dev/feast / Feature

Class Feature

sdk/python/feast/feature.py:22–134  ·  view source on GitHub ↗

A Feature represents a class of serveable feature. Args: name: Name of the feature. dtype: The type of the feature, such as string or float. labels (optional): User-defined metadata in dictionary form.

Source from the content-addressed store, hash-verified

20
21
22class 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 description: str = "",
37 labels: Optional[Dict[str, str]] = None,
38 ):
39 """Creates a Feature object."""
40 self._name = name
41 if not isinstance(dtype, ValueType):
42 raise ValueError("dtype is not a valid ValueType")
43 if dtype is ValueType.UNKNOWN:
44 raise ValueError(f"dtype cannot be {dtype}")
45 self._dtype = dtype
46 self._description = description
47 if labels is None:
48 self._labels = dict()
49 else:
50 self._labels = labels
51
52 def __eq__(self, other):
53 if self.name != other.name or self.dtype != other.dtype:
54 return False
55 return True
56
57 def __lt__(self, other):
58 return self.name < other.name
59
60 def __repr__(self):
61 return (
62 f"Feature(\n"
63 f" name={self._name!r},\n"
64 f" dtype={self._dtype!r},\n"
65 f" description={self._description!r},\n"
66 f" labels={self._labels!r}\n"
67 f")"
68 )
69
70 def __str__(self):
71 # readable string of the reference
72 return f"Feature<{self.name}: {self.dtype}>"
73
74 @property
75 def name(self):
76 """
77 Gets the name of this feature.
78 """
79 return self._name

Calls

no outgoing calls