-
Notifications
You must be signed in to change notification settings - Fork 4
(843-update-lookup-with-train-method #854
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
base: main
Are you sure you want to change the base?
Conversation
|
@thomasstvr @ebhills Pls look into final version of PR:
Mocked tests to avoid real model modification |
| try: | ||
| metadata = _data.model(model_id) | ||
| except Exception as e: | ||
| raise e |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When attempting to train a new model using the name parameter and action set to update, a cryptic error is raised:
RuntimeError: train.lookup - Something went wrong trying to access model NonePassing insert raises a better message, while upsert works. User should only be able to pass overwrite when creating a new model/using the name parameter. This can be caught early and each of the 3 cases can have the same error message. Something like:
"{action} not allowed when training a new model"
|
|
||
|
|
||
|
|
||
| def test_upsert_missing_key_for_key_variant(self, mock_lookup_action_backend): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's drop mocker everywhere that a new model is not being trained.
Update Lookup (with train method)
Overview
This pull request introduces support for an
actionparameter to thewritemethod for training lookup models, allowing more granular control withINSERT,UPDATE, andUPSERToperations. The implementation includes robust error handling and validation for these actions, and comprehensive tests have been added to ensure correct behavior and coverage of edge cases.Feature: Action parameter for lookup model training
actionparameter to thewritemethod inwrangles/connectors/train.py, supportingINSERT,UPDATE, andUPSERTactions for lookup models. This enables explicit control over whether to create, update, or upsert models.UPSERT: Updates existing models or creates new ones, handling duplicate keys and merging data.UPDATE: Updates only existing records in a model, with validation for presence of keys.INSERT: Creates a new model, with checks for duplicate model names and unique keys.Usage Examples
INSERT
UPDATE
UPSERT
UPSERT (by default)
Validation and error handling
Test coverage
tests/connectors/test_train.pyfor all new behaviors:Documentation
actionparameter and its possible values, improving clarity for users.