Skip to content

feat(feature-store): Add lineage registration to DatasetBuilder#6014

Open
Vishakha263 wants to merge 2 commits into
aws:masterfrom
Vishakha263:feat/fs-lineage-dataset-builder
Open

feat(feature-store): Add lineage registration to DatasetBuilder#6014
Vishakha263 wants to merge 2 commits into
aws:masterfrom
Vishakha263:feat/fs-lineage-dataset-builder

Conversation

@Vishakha263

@Vishakha263 Vishakha263 commented Jul 10, 2026

Copy link
Copy Markdown
Contributor

Description
Add optional lineage registration to DatasetBuilder that creates a SM Dataset (HubContent) after extracting features from Feature Groups. This enables automatic lineage tracking between Feature Groups and Training Jobs.

Motivation
SageMaker's auto-lineage currently has a gap: there's no connection between Feature Groups and Training Jobs. When a customer extracts features via DatasetBuilder.to_csv_file() and uses the resulting CSV for training, that relationship is lost. This PR fills that gap by registering the extraction as a SM Dataset with source Feature Group metadata.

Implementation details:

  • Added register_as_dataset parameter to DatasetBuilder.create() (default False — fully backward compatible)
  • After Athena query completes, calls HubContent.import_hub_content() with source FG ARNs in the document metadata
  • Tracks source Feature Groups from both base and merged (via with_feature_group()) calls
  • Deduplicates ARNs if the same FG is used multiple times
  • Best-effort: if registration fails (missing permissions, service error), logs a warning and returns the CSV normally

Files changed:

  • dataset_builder.py
  • test_dataset_builder.py

Testing
Added 10 unit tests in TestDatasetBuilderRegisterAsDataset:

  • Default flag behavior (False by default)
  • Opt-in flag stored correctly
  • ARN collection from base FG
  • ARN collection from base + merged FGs
  • ARN deduplication
  • DataFrame base returns empty ARN list
  • HubContent API called with correct parameters
  • Graceful handling of AccessDeniedException
  • Graceful handling of generic errors
  • Registration skipped when no FG ARNs available
  • All tests passing locally.

Permissions required (for customers who opt in)
sagemaker:ImportHubContent on the execution role. If missing, a warning is logged and the CSV is still returned.

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

Add register_as_dataset parameter to DatasetBuilder.create() that
registers the built dataset as a HubContent with source feature group
ARNs in ContentMetadata. This enables auto-lineage between Feature
Groups and Training Jobs via SM Dataset (HubContent) as bridge.

Changes:
- Add register_as_dataset flag to DatasetBuilder.create()
- Collect source FG ARNs from base and merged feature groups
- Call HubContent.import_hub_content() with sourceFeatureGroups,
  extractionMethod, and athenaQueryExecutionId metadata
- Graceful fallback on AccessDenied or generic errors (logs warning)
- Add 10 unit tests covering opt-in, ARN collection, dedup,
  DataFrame path, HubContent invocation, error handling
try:
from sagemaker.core.resources import HubContent

HubContent.import_hub_content(

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of calling HubContent.import_hub_content directly, might consider to use DataSet.create from sagemaker.ai_registry.dataset. It handles document construction and schema compliance internally. We'd need to extend DataSet.create to accept a metadata param for passing sourceFeatureGroups though.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants