GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
GeezerVison is showing github.com — feat: TabularDataset, fix: Dataset by morgandu · Pull Request #103 · googleapis/python-aiplatform Conversation
Contributor
List of Changes:
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page. All reactions…y, add metadata_schema_uri property in datasets.py, move datasets.py to datasets module
ivanmkc
reviewed
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nice cleanup!
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page. All reactions
ivanmkc
reviewed
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||
| return dataset_obj | ||
|
|
||
| @property |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Don't think the property decorator is relevant here. Property is used to create getters and setters, import_data is more of a one-off function.
reference: https://www.programiz.com/python-programming/property
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Agree that property should be removed here.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| parent=_TEST_PARENT, dataset=expected_dataset | ||
| ) | ||
|
|
||
| @pytest.mark.usefixtures("get_tabular_dataset_mock") |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Nice test!
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
lgtm, although I'd leave it people who were involved with the design process to give it a proper sign-off.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| credentials=credentials, | ||
| ) | ||
|
|
||
| assert self.metadata_schema_uri == schema.dataset.metadata.tabular, ( |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Preference to raise an Exception instead of asserting.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| credentials: Optional[auth_credentials.Credentials]=None, | ||
| Custom credentials to use to upload this model. Overrides | ||
| credentials set in aiplatform.init. | ||
| """ |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Should have a raises section.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
|
||
| @property | ||
| def import_data(self): | ||
| raise AttributeError("'TabularDataset' object has no 'import_data' method") |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
I agree that this issue should be resolved in the class hierarchy.
I think though that we still want a generic Dataset class (with name Dataset) similar to what we have now that supports all methods.
TabularDataset would just subclass Dataset.
Vision, NLP and others would subclass Dataset AND DatasetImportable.
If we go the multiple inheritance route then probably something like this:
TabularDataset would just subclass _Dataset.
Dataset, Vision, NLP and others would subclass _Dataset AND _DatasetImportable
But we can also do this without mixin:
TabularDataset would subclass _Dataset.
Dataset is a subclass of _Dataset with import and associated methods
Vision, NLP and others would subclass Dataset
To me it seems like it's cleaner without multiple inheritance because _DatasetImportable has a hard requirement on _Dataset to work.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
…ort', 'update' methods, and 'metadata_schema_uri' property which applies to all types of dataset. Removed 'import_data', '_import_data' methods. 1.1. removed 'gcs_source', 'bq_source' and replaced with optional empty 'dataset_metadata' (only used in tabular dataset creation) in 'create' method's signature. 1.2. Removed 'import_schema_uri', 'data_items_labels' from 'create' method's signature as they are used for importing data. 1.3. Removed the support for tabular dataset from 'create' method. 1.4. Removed the optional support for importing data. 2. Created a subclass 'Dataset' of '_Dataset', with supporting dataset types in '_types'. 2.1. Created 'create' method with optional support for importing data, only when both gcs_source and import_schema_uri are provided. 3. Created a subclass 'TabularDataset' of '_Dataset', with supporting dataset types in '_types'. 3.1. Created 'create' method using 'set_dataset_metadata' to validate input config when one and only one source, i.e. gcs, bq is provided. 4. Added dataset type validation for 'Dataset' and 'Tabular' Dataset. 5. Updated unit tests.
…e', 'export', 'update' methods, and 'metadata_schema_uri' property which applies to all types of dataset. Removed 'import_data', '_import_data' methods. 1.1. removed 'gcs_source', 'bq_source' and replaced with optional empty 'dataset_metadata' (only used in tabular dataset creation) in 'create' method's signature. 1.2. Removed 'import_schema_uri', 'data_items_labels' from 'create' method's signature as they are used for importing data. 1.3. Removed the support for tabular dataset from 'create' method. 1.4. Removed the optional support for importing data. 2. Created a subclass 'Dataset' of '_Dataset', with supporting dataset types in '_types'. 2.1. Created 'create' method with optional support for importing data, only when both gcs_source and import_schema_uri are provided. 3. Created a subclass 'TabularDataset' of '_Dataset', with supporting dataset types in '_types'. 3.1. Created 'create' method using 'set_dataset_metadata' to validate input config when one and only one source, i.e. gcs, bq is provided. 4. Added dataset type validation for 'Dataset' and 'Tabular' Dataset. 5. Updated unit tests." This reverts commit cbfce47.
…ed _type for supporting dataset type, added tabular data input config metadata constraint, added import data constraint
| class TabularDataset(datasets.Dataset): | ||
| """Managed tabular dataset resource for AI Platform""" | ||
|
|
||
| _types = [ |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
I really like this pattern. Prefer a tuple or frozenset since they are immutable.
Prefer _support_metadata_schema_uris to be less ambiguous.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
changed _types to _support_metadata_schema_uris with tuple
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| credentials=credentials, | ||
| ) | ||
|
|
||
| if self.metadata_schema_uri not in self._types: |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
I wonder if the base dataset class should have a method like
def _validate_metadata_schema_uri(self): if self._types and self.metadata_schema_uri not in self._types: raise Exception( f"{self.resource_name} can not be retrieved using " f"{self.__class__.__name__} class, check the dataset type" )
And the Dataset class can set self_types = None. And the validation can be done in the dataset class so we don't need to re-implement for every sub dataset class.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Implemented _validate_metadata_schema_uri in Dataset class, so retrieved dataset resource can be validated against predefined _support_metadata_schema_uris in Dataset class and subclass
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
|
||
| return dataset_obj | ||
|
|
||
| @property |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Agree that property should be removed here.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
|
||
| @property | ||
| def import_data(self): | ||
| raise AttributeError("'TabularDataset' object has no 'import_data' method") |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Agree that this should be changed to NotImplementedError.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
…_schema_uri method to Dataset 2. changed _types to tuple _support_metadata_schema_uris in TabularDataset 3. changed import_data method to raise NotImplementedError
|
changes are reflected in #153 |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
Successfully merging this pull request may close these issues.
There was an error while loading. Please reload this page.