Francis Duval
01/23/2024, 6:19 PMmodel_name:
type: ibc_codes.datasets.st_dataset.STDataset
filepath: data/05_models/model_name
metadata:
kedro-viz:
layer: models
Dataset 'model_name' must only contain arguments valid for the constructor of '<http://ibc_codes.datasets.st|ibc_codes.datasets.st>_dataset.STDataset'.
I looked at the documentation to see how I can implement this in my custom dataset class:
https://docs.kedro.org/en/stable/data/how_to_create_a_custom_dataset.html#how-to-contribute-a-custom-dataset-implementation,
as well as the pandas.CSVDataset source code:
https://docs.kedro.org/en/0.18.6/_modules/kedro/datasets/pandas/csv_dataset.html#CSVDataSet,
but I found no reference of layers.
My custom dataset class:
from kedro.io import AbstractDataset
from sentence_transformers import SentenceTransformer
class STDataset(AbstractDataset):
def __init__(self, filepath: str):
self.filepath = filepath
def _load(self):
return SentenceTransformer(self.filepath)
def _save(self, model: SentenceTransformer):
model.save(self.filepath)
def _describe(self):
return {
'filepath': self.filepath
}
datajoely
01/23/2024, 6:29 PMTakieddine Kadiri
01/23/2024, 6:34 PMsuper().__init__(...)
Francis Duval
01/23/2024, 6:49 PMconfig_dic = {
'type': 'ibc_codes.datasets.st_dataset.STDataset',
'filepath': 'data/05_models/model_name',
'metadata': {
'kedro-viz':{
'layer': 'models'}
}
}
STDataset.from_config(name='test', config=config_dic)
Nope, I get
DatasetError:
STDataset._init_() got an unexpected keyword argument 'metadata'
Dataset 'test' must only contain arguments valid for the constructor of '<http://ibc_codes.datasets.st|ibc_codes.datasets.st>_dataset.STDataset'
But yes, I'll try to do the super init, maybe it's the problem!Francis Duval
01/23/2024, 7:01 PMNok Lam Chan
01/23/2024, 10:31 PMFrancis Duval
01/23/2024, 11:29 PMNok Lam Chan
01/24/2024, 12:11 PMkedro-datasets
? the metadata
field was added a few months ago so maybe it's a version incompatibility issueFrancis Duval
01/24/2024, 2:19 PMNok Lam Chan
01/24/2024, 3:05 PMFrancis Duval
01/24/2024, 3:09 PMNok Lam Chan
01/24/2024, 3:28 PMclass STDataset(AbstractDataset):
def __init__(self, filepath: str):
self.filepath = filepath
Nok Lam Chan
01/24/2024, 3:30 PMFrancis Duval
01/24/2024, 3:52 PMNok Lam Chan
01/24/2024, 4:02 PM