feat: support dataset update#1416
Conversation
| assert dataset.gca_resource.description == _TEST_DATASET_DESCRIPTION | ||
|
|
||
| finally: | ||
| if dataset is not None: |
There was a problem hiding this comment.
This line is superfluous. dataset will only exist on assignment after ImageDataset.create is successful.
The test should start with dataset=None
There was a problem hiding this comment.
If the ImageDataset.create is successful, then we want to delete the dataset finally. But if create() fails, dataset is None and we shouldn't call dataset.delete(). So I think it's necessary to add this line.
There was a problem hiding this comment.
If create fails then dataset is not defined and if dataset is not None will throw a NameError. dataset isn't created until after the right side of the statement, dataset = aiplatform.ImageDataset.create() is successful. You can validate this behavior in Python:
def f():
raise RuntimeError('')
try:
dataset = f()
except:
if dataset is None:
passThere was a problem hiding this comment.
Got it!
But I see other system tests like test_create_and_import_image_dataset and test_create_tabular_dataset have the same pattern that checks if dataset is not None. Is there any reason for that?
There was a problem hiding this comment.
No, those should be eventually fixed as well.
There was a problem hiding this comment.
Got it. Just removed this line. Thank you!
Thank you for opening a Pull Request! Before submitting your PR, there are a few things you can do to make sure it goes smoothly:
Fixes #1178 🦕