MCPcopy
hub / github.com/feast-dev/feast / get_online_labels

Function get_online_labels

sdk/python/feast/ui_server.py:125–165  ·  view source on GitHub ↗

Retrieve current label values from the online store for given entity keys.

(request: GetOnlineFeaturesRequest)

Source from the content-addressed store, hash-verified

123
124 @rest_app.post("/get-online-labels")
125 def get_online_labels(request: GetOnlineFeaturesRequest):
126 """Retrieve current label values from the online store for given entity keys."""
127 try:
128 fv_name = request.feature_view
129
130 fv: Any = None
131 try:
132 fv = store.get_feature_view(fv_name)
133 except Exception:
134 pass
135
136 if fv is None:
137 try:
138 fv = store.registry.get_label_view(fv_name, store.project)
139 except Exception:
140 pass
141
142 if fv is None:
143 return Response(
144 content=json.dumps(
145 {"detail": f"Feature view or label view '{fv_name}' not found"}
146 ),
147 status_code=status.HTTP_404_NOT_FOUND,
148 media_type="application/json",
149 )
150
151 feature_refs = [f"{fv_name}:{f.name}" for f in fv.features]
152
153 result = store.get_online_features(
154 features=feature_refs,
155 entity_rows=[
156 {k: v[i] for k, v in request.entity_keys.items()}
157 for i in range(len(next(iter(request.entity_keys.values()))))
158 ],
159 )
160
161 result_dict = result.to_dict()
162 return {"results": result_dict}
163 except Exception:
164 logger.exception("get-online-labels failed")
165 return _safe_error_response("Get online labels")
166
167 class ListLabelsRequest(BaseModel):
168 feature_view: str

Callers

nothing calls this directly

Calls 7

_safe_error_responseFunction · 0.85
exceptionMethod · 0.80
get_feature_viewMethod · 0.45
get_label_viewMethod · 0.45
get_online_featuresMethod · 0.45
valuesMethod · 0.45
to_dictMethod · 0.45

Tested by

no test coverage detected