-
Notifications
You must be signed in to change notification settings - Fork 353
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
feat: Add initial Model Builder SDK samples #265
Conversation
Here is the summary of changes. You are about to add 4 region tags.
This comment is generated by snippet-bot.
|
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.
LGTM! Added some comments.
samples/model-builder/create_and_import_dataset_image_sample.py
Outdated
Show resolved
Hide resolved
samples/model-builder/create_training_pipeline_image_classification_sample.py
Show resolved
Hide resolved
samples/model-builder/create_and_import_dataset_image_sample_test.py
Outdated
Show resolved
Hide resolved
with patch.object( | ||
aiplatform.training_jobs.AutoMLImageTrainingJob, "__init__" | ||
) as mock: | ||
mock.return_value = None |
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.
This seems either superfluous or possibly will cause an error because we would call run
on None
.
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.
Not returning None
when patching the __init__
caused the following exception:
TypeError: __init__() should return None, not 'MagicMock'
The downstream calls would also be patched so it shouldn't cause an error. Is this alright or should we look for alternative approaches?
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.
Ah, right. I was wrong on that. Leave it as is. That makes sense, __new__
returns the instance, not __init__
.
PTAL when you get a chance @busunkim96 @tmatsuo — thanks! |
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.
I recommend turning on Autospeccing (https://docs.python.org/3/library/unittest.mock.html#autospeccing) where possible. It makes it easier to catch incorrect method calls.
The conftest.py
approach seems good for sharing code needed by the tests. For very simple mocks IMO it is easier for folks to follow when the mock is right next to the test using the patch() decorator syntax. (example in google-auth)
Adds an initial set of Model Builder SDK samples and their tests, along with a
conftest.py
file to hold mocks.Here are the samples added:
init_sample
create_and_import_dataset_image_sample
create_batch_prediction_job_sample
create_training_pipeline_image_classification_sample