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.
|
sasha-gitg
left a comment
There was a problem hiding this comment.
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.
This seems either superfluous or possibly will cause an error because we would call run on None.
There was a problem hiding this comment.
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.
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! |
busunkim96
left a comment
There was a problem hiding this comment.
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.pyfile to hold mocks.Here are the samples added:
init_samplecreate_and_import_dataset_image_samplecreate_batch_prediction_job_samplecreate_training_pipeline_image_classification_sample