umesh sri
07/13/2024, 3:08 PMtestAbstractCsv:
type: kedrotest.myabstractDataSet.MyOwnDataset
filepath: ${_dataset_filetype}/countries.csv
Absolute path src/kedrotest/myabstractDataSet/MyOwnDataset.py
Thanks.Deepyaman Datta
07/13/2024, 3:34 PMumesh sri
07/14/2024, 11:22 AMDeepyaman Datta
07/15/2024, 1:02 PMDeepyaman Datta
07/15/2024, 1:03 PMsrc
); however, given you used kedro ipython
, I think it should be fine.umesh sri
07/16/2024, 9:11 AMNok Lam Chan
07/16/2024, 1:31 PM___init___.py
if it's a python module.Nok Lam Chan
07/16/2024, 1:32 PMkedro ipython
? Is the error only showing up when you do kedro run
but not kedro ipython
?Nok Lam Chan
07/16/2024, 1:34 PMpip install -e .
at the root to make sure kedrotest
is installed as a package.
Kedro did something behind the background so you don't have to do this during development, but you will likely need to install it later when you need to start writing tests.umesh sri
07/16/2024, 2:27 PM___init___.py
Yes in kedro Run its showing that error.
C:.
│
│ MyOwnDataset.py
│ init.py <-----------------------
│
└───__pycache__
MyOwnDataset.cpython-311.pyc
init.cpython-311.pycNok Lam Chan
07/16/2024, 2:28 PMNok Lam Chan
07/16/2024, 2:29 PMtestAbstractCsv:
type: kedrotest.myabstractDataSet.MyOwnDataset
filepath: ${_dataset_filetype}/countries.csv
Absolute path src/kedrotest/myabstractDataSet/MyOwnDataset.py
the type should be the name of the class , not the python fileNok Lam Chan
07/16/2024, 2:29 PMclass MyDataset(AbstractDataset)
...
In MyOwnDataset.py
Nok Lam Chan
07/16/2024, 2:29 PMxxxxx.MyOwnDataset.MyDataset
Nok Lam Chan
07/16/2024, 2:31 PMtype
is the import path of a python object. You should be do this equivalently.
let say you can import a dataset like this
from a.b.c import Dataset
Then the equivalent type
in catalog.yml
is type: a.b.c.Dataset
umesh sri
07/16/2024, 2:42 PMMydataset:
type: kedrotest.datasets.MyOwnDataset.MyOwnDataset
filepath: data/01_raw/countries.csv
However, I am getting new error
DatasetError: An exception occurred when parsing config for dataset 'Mydataset':
name 'AbstractDataset' is not defined
This is myowndataset class
from pathlib import Path, PurePosixPath
from typing import Any, Dict
import pandas as pd
# from <http://kedro.io|kedro.io> import AbstractDataset
from <http://kedro.io|kedro.io> import AbstractDataSet
# from kedro.io.core import get_filepath_str, get_protocol_and_path
class MyOwnDataset(AbstractDataset[pd.DataFrame, pd.DataFrame]):
def __init__(self, filepath, param1=True, param2=True):
self._filepath = PurePosixPath(filepath)
self._param1 = param1
self._param2 = param2
def _load(self) -> pd.DataFrame:
return pd.read_csv(self._filepath)
def _save(self, df: pd.DataFrame) -> None:
df.to_csv(str(self._filepath))
def _exists(self) -> bool:
return Path(self._filepath.as_posix()).exists()
def _describe(self):
return dict(param1=self._param1, param2=self._param2)
Nok Lam Chan
07/16/2024, 2:43 PMNok Lam Chan
07/16/2024, 2:43 PMDataset
convention. If it's possible it's better to stick with the lowercase.Nok Lam Chan
07/16/2024, 2:53 PMNok Lam Chan
07/16/2024, 2:53 PMfrom <http://kedro.io|kedro.io> import AbstractDataset
Just thisumesh sri
07/16/2024, 2:57 PM