Client
Client
Bases: ResourceClient
, ServingClient
Client for interacting with Featureform APIs (resources and serving)
Using the Client:
import featureform as ff
from featureform import Client
client = Client()
# Example 1: Get a registered provider
redis = client.get_provider("redis-quickstart")
# Example 2: Compute a dataframe from a registered source
transactions_df = client.dataframe("transactions", "quickstart")
Source code in src/featureform/client.py
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 |
|
close()
columns(source, variant=None)
Returns the columns of a registered source or transformation
Example:
Parameters:
Name | Type | Description | Default |
---|---|---|---|
source |
Union[SourceRegistrar, SubscriptableTransformation, str]
|
The source or transformation to get the columns from |
required |
variant |
str
|
The source variant; can't be None if source is a string |
None
|
Returns:
Name | Type | Description |
---|---|---|
columns |
List[str]
|
The columns of the source or transformation |
Source code in src/featureform/client.py
dataframe(source, variant=None, limit=NO_RECORD_LIMIT, asynchronous=False, verbose=False)
Return a dataframe from a registered source or transformation
Example:
transactions_df = client.dataframe("transactions", "quickstart")
avg_user_transaction_df = transactions_df.groupby("CustomerID")["TransactionAmount"].mean()
Parameters:
Name | Type | Description | Default |
---|---|---|---|
source |
Union[SourceRegistrar, SubscriptableTransformation, str]
|
The source or transformation to compute the dataframe from |
required |
variant |
str
|
The source variant; can't be None if source is a string |
None
|
limit |
int
|
The maximum number of records to return; defaults to NO_RECORD_LIMIT |
NO_RECORD_LIMIT
|
asynchronous |
bool
|
Flag to determine whether the client should wait for resources to be in either a READY or FAILED state before returning. Defaults to False to ensure that newly registered resources are in a READY state prior to serving them as dataframes. |
False
|
Returns:
Name | Type | Description |
---|---|---|
df |
DataFrame
|
The dataframe computed from the source or transformation |
Source code in src/featureform/client.py
location(source, variant=None, resource_type=None)
Returns the location of a registered resource. For SQL resources, it will return the table name and for file resources, it will return the file path.
Example:
Parameters:
Name | Type | Description | Default |
---|---|---|---|
source |
Union[SourceRegistrar, SubscriptableTransformation, str]
|
The source or transformation to compute the dataframe from |
required |
variant |
str
|
The source variant; can't be None if source is a string |
None
|
resource_type |
ResourceType
|
The type of resource; can be one of ff.SOURCE, ff.FEATURE, ff.LABEL, or ff.TRAINING_SET |
None
|
Source code in src/featureform/client.py
nearest(feature, vector, k)
Query the K nearest neighbors of a provider vector in the index of a registered feature variant
Example:
# Get the 5 nearest neighbors of the vector [0.1, 0.2, 0.3] in the index of the feature "my_feature" with variant "my_variant"
nearest_neighbors = client.nearest("my_feature", "my_variant", [0.1, 0.2, 0.3], 5)
print(nearest_neighbors) # prints a list of entities (e.g. ["entity1", "entity2", "entity3", "entity4", "entity5"])
Parameters:
Name | Type | Description | Default |
---|---|---|---|
feature |
Union[FeatureColumnResource, tuple(str, str)]
|
Feature object or tuple of Feature name and variant |
required |
vector |
List[float]
|
Query vector |
required |
k |
int
|
Number of nearest neighbors to return |
required |