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

Function export_training_dataset

sdk/python/feast/ui_server.py:656–692  ·  view source on GitHub ↗

Generate a training dataset using get_historical_features and return as JSON (downloadable).

(request: TrainingExportRequest)

Source from the content-addressed store, hash-verified

654
655 @rest_app.post("/training-dataset/export")
656 def export_training_dataset(request: TrainingExportRequest):
657 """Generate a training dataset using get_historical_features and return as JSON (downloadable)."""
658 try:
659 from datetime import datetime, timezone
660
661 entity_df = pd.DataFrame(request.entity_df)
662
663 if "event_timestamp" not in entity_df.columns:
664 if request.end_date:
665 ts = pd.Timestamp(request.end_date, tz="UTC")
666 else:
667 ts = pd.Timestamp(datetime.now(timezone.utc))
668 entity_df["event_timestamp"] = ts
669
670 fs = store.get_feature_service(request.feature_service)
671 training_df = store.get_historical_features(
672 entity_df=entity_df,
673 features=fs,
674 ).to_df()
675
676 result = training_df.to_dict(orient="records")
677 for row in result:
678 for k, v in row.items():
679 if pd.isna(v):
680 row[k] = None
681 elif hasattr(v, "isoformat"):
682 row[k] = v.isoformat()
683
684 return {
685 "data": result,
686 "columns": list(training_df.columns),
687 "row_count": len(training_df),
688 "feature_service": request.feature_service,
689 }
690 except Exception:
691 logger.exception("Training dataset export failed")
692 return _safe_error_response("Training dataset export")
693
694 @rest_app.get("/webhook/config/{label_view_name}")
695 def webhook_config(label_view_name: str):

Callers

nothing calls this directly

Calls 6

_safe_error_responseFunction · 0.85
exceptionMethod · 0.80
get_feature_serviceMethod · 0.45
to_dfMethod · 0.45
to_dictMethod · 0.45

Tested by

no test coverage detected