Skip to content

feature: with_feature_group [feature_store] #3658

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged

Conversation

patrickmcarlos
Copy link
Contributor

@patrickmcarlos patrickmcarlos commented Feb 14, 2023

Issue #, if available:

Description of changes:
Adds three new parameters to the with_feature_group Feature Store dataset_builder class.

These three new parameters are:

        feature_name_in_target (str): A string representing the feature in the target feature group
            that will be compared to the target feature in the base feature group. If None is
            provided, the record identifier will be used in the join statement. (default: None).
        join_comparator (JoinComparatorEnum): A JoinComparatorEnum representing the comparator used
            when joining the target feature in the base feature group and the feature in the target
            feature group (default: None).
        join_type (JoinTypeEnum): A JoinTypeEnum representing the type of join between the base and
            target feature groups. (default: None).

feature_name_in_target

  • Allows users to provide the feature name in the target feature group that will be used as a join key alongside the currently existing target_feature_name_in_base feature in the SQL JOIN statement. Before, only the record identifier feature in the target feature group could be used when creating the query.

join_comparator

  • Allows user to provide a Join comparator, which will be used to compare the two join keys. For example, we can now join a row together if feature_1 (target_feature_name_in_base) in feature group A is greater than feature_1 (feature_name_in_target). Before, only = (Equals) was able to be used.

join_type

Usage

Say we have two feature groups, feature_group_a, and feature_group_b.

feature_group_a has three features, rec-id-a, event-time-id-a and feature-a.
feature_group_b has three features, rec-id-b, event-time-id-b and feature-b.

To join these feature groups together, a user might write the code:

dataset_builder = feature_store.create_dataset(
    base=feature_group_a,
    output_path=f"s3://{s3_bucket_name}",
)

result_df, query = dataset_builder.with_feature_group(
    feature_group=feature_group_b,
    target_feature_name_in_base="feature-a",
).to_dataframe()

However, a user may want to join feature-a from feature_group_a (base) and feature-b from feature_group_b (target). Furthermore, the user wants to perform a RIGHT_JOIN instead of a regular JOIN (inner) and use the LESS_THAN comparator instead of equals

Our code could look like this:

result_df, query = dataset_builder.with_feature_group(
    feature_group=feature_group_b,
    target_feature_name_in_base="feature-a",
    feature_name_in_target="feature-b"
    join_comparator=JoinComparatorEnum.LESS_THAN,
    join_type=JoinTypeEnum.RIGHT_JOIN).to_dataframe()

or without named arguments

result_df, query = dataset_builder.with_feature_group(
    feature_group_b,
    "feature-a",
    None,
    "feature-b"
    JoinComparatorEnum.LESS_THAN,
    JoinTypeEnum.RIGHT_JOIN).to_dataframe()

Testing done:

  • Unit & integration test to ensure properties of dataset_builder class are correctly updated when the new parameters are used in with_feature_group
  • Unit & integration test for the SQL query generated when using the with_feature_group with the new parameters.
  • Currently existing unit tests are unchanged.

Merge Checklist

Put an x in the boxes that apply. You can also fill these out after creating the PR. If you're unsure about any of them, don't hesitate to ask. We're here to help! This is simply a reminder of what we are going to look for before merging your pull request.

General

  • I have read the CONTRIBUTING doc
  • I certify that the changes I am introducing will be backward compatible, and I have discussed concerns about this, if any, with the Python SDK team
  • I used the commit message format described in CONTRIBUTING
  • I have passed the region in to all S3 and STS clients that I've initialized as part of this change.
  • I have updated any necessary documentation, including READMEs and API docs (if appropriate)

Tests

  • I have added tests that prove my fix is effective or that my feature works (if appropriate)
  • I have added unit and/or integration tests as appropriate to ensure backward compatibility of the changes
  • I have checked that my tests are not configured for a specific region or account (if appropriate)
  • I have used unique_name_from_base to create resource names in integ tests (if appropriate)

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@patrickmcarlos patrickmcarlos marked this pull request as ready for review February 15, 2023 00:20
@patrickmcarlos patrickmcarlos requested a review from a team as a code owner February 15, 2023 00:20
@patrickmcarlos patrickmcarlos requested review from trajanikant and removed request for a team February 15, 2023 00:20
Copy link
Contributor

@trajanikant trajanikant left a comment

Choose a reason for hiding this comment

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

/bot run pr, slow-tests

Copy link
Contributor

@trajanikant trajanikant left a comment

Choose a reason for hiding this comment

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

/bot run all

@sagemaker-bot
Copy link
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: sagemaker-python-sdk-unit-tests
  • Commit ID: 487322e
  • Result: SUCCEEDED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

@codecov-commenter
Copy link

codecov-commenter commented Feb 16, 2023

Codecov Report

Merging #3658 (c5b97b2) into master (1ad9d9c) will decrease coverage by 0.78%.
The diff coverage is 95.65%.

@@            Coverage Diff             @@
##           master    #3658      +/-   ##
==========================================
- Coverage   89.75%   88.98%   -0.78%     
==========================================
  Files         968      227     -741     
  Lines       91168    22569   -68599     
==========================================
- Hits        81824    20082   -61742     
+ Misses       9344     2487    -6857     
Impacted Files Coverage Δ
src/sagemaker/feature_store/dataset_builder.py 87.87% <95.65%> (ø)
...maker/cli/compatibility/v2/modifiers/image_uris.py
...10/lib/python3.10/site-packages/sagemaker/model.py
...ython3.7/site-packages/sagemaker/debugger/utils.py
...hon3.7/site-packages/sagemaker/local/exceptions.py
...ite-packages/sagemaker/async_inference/__init__.py
...ython3.10/site-packages/sagemaker/pytorch/model.py
...s/sagemaker/workflow/pipeline_experiment_config.py
...310/lib/python3.10/site-packages/sagemaker/logs.py
...3.8/site-packages/sagemaker/workflow/model_step.py
... and 1186 more

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

@sagemaker-bot
Copy link
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: sagemaker-python-sdk-local-mode-tests
  • Commit ID: 487322e
  • Result: SUCCEEDED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

@sagemaker-bot
Copy link
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: sagemaker-python-sdk-notebook-tests
  • Commit ID: 487322e
  • Result: SUCCEEDED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

@sagemaker-bot
Copy link
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: sagemaker-python-sdk-pr
  • Commit ID: 487322e
  • Result: FAILED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

@sagemaker-bot
Copy link
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: sagemaker-python-sdk-slow-tests
  • Commit ID: 487322e
  • Result: FAILED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

Copy link
Contributor

@trajanikant trajanikant left a comment

Choose a reason for hiding this comment

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

/bot run pr, slow-tests

@sagemaker-bot
Copy link
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: sagemaker-python-sdk-slow-tests
  • Commit ID: 487322e
  • Result: FAILED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

@sagemaker-bot
Copy link
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: sagemaker-python-sdk-pr
  • Commit ID: 487322e
  • Result: FAILED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

Copy link
Contributor

@trajanikant trajanikant left a comment

Choose a reason for hiding this comment

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

/bot run pr

@sagemaker-bot
Copy link
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: sagemaker-python-sdk-pr
  • Commit ID: 487322e
  • Result: FAILED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

Copy link
Contributor

@trajanikant trajanikant left a comment

Choose a reason for hiding this comment

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

/bot run pr

@sagemaker-bot
Copy link
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: sagemaker-python-sdk-pr
  • Commit ID: 487322e
  • Result: FAILED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

@patrickmcarlos patrickmcarlos force-pushed the patmcar-improve-join-functionality branch 3 times, most recently from 152d7cf to c5b97b2 Compare March 3, 2023 23:50
Copy link
Contributor

@trajanikant trajanikant left a comment

Choose a reason for hiding this comment

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

/bot run all

@sagemaker-bot
Copy link
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: sagemaker-python-sdk-pr
  • Commit ID: c5b97b2
  • Result: SUCCEEDED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

@sagemaker-bot
Copy link
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: sagemaker-python-sdk-unit-tests
  • Commit ID: c5b97b2
  • Result: SUCCEEDED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

@sagemaker-bot
Copy link
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: sagemaker-python-sdk-local-mode-tests
  • Commit ID: c5b97b2
  • Result: SUCCEEDED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

@sagemaker-bot
Copy link
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: sagemaker-python-sdk-notebook-tests
  • Commit ID: c5b97b2
  • Result: SUCCEEDED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

@sagemaker-bot
Copy link
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: sagemaker-python-sdk-slow-tests
  • Commit ID: c5b97b2
  • Result: FAILED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

@trajanikant trajanikant force-pushed the patmcar-improve-join-functionality branch from c5b97b2 to 1ced27a Compare March 6, 2023 20:19
@trajanikant trajanikant changed the title feature: feature store with_feature_group functionality changes feature: with_feature_group [feature_store] Mar 6, 2023
@trajanikant trajanikant merged commit 67dc885 into aws:master Mar 6, 2023
nmadan pushed a commit to nmadan/sagemaker-python-sdk that referenced this pull request Apr 18, 2023
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.

5 participants