Skip to content

Commit

Permalink
Replace io by catalog in docstrings of DataCatalog (#4034)
Browse files Browse the repository at this point in the history
Signed-off-by: Yury Fedotov <[email protected]>
  • Loading branch information
yury-fedotov authored Jul 26, 2024
1 parent 5e15044 commit fd17607
Showing 1 changed file with 14 additions and 14 deletions.
28 changes: 14 additions & 14 deletions kedro/io/data_catalog.py
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ def __init__( # noqa: PLR0913
>>> cars = CSVDataset(filepath="cars.csv",
>>> load_args=None,
>>> save_args={"index": False})
>>> io = DataCatalog(datasets={'cars': cars})
>>> catalog = DataCatalog(datasets={'cars': cars})
"""
self._datasets = dict(datasets or {})
self.datasets = _FrozenDatasets(self._datasets)
Expand Down Expand Up @@ -527,9 +527,9 @@ def load(self, name: str, version: str | None = None) -> Any:
>>> cars = CSVDataset(filepath="cars.csv",
>>> load_args=None,
>>> save_args={"index": False})
>>> io = DataCatalog(datasets={'cars': cars})
>>> catalog = DataCatalog(datasets={'cars': cars})
>>>
>>> df = io.load("cars")
>>> df = catalog.load("cars")
"""
load_version = Version(version, None) if version else None
dataset = self._get_dataset(name, version=load_version)
Expand Down Expand Up @@ -569,12 +569,12 @@ def save(self, name: str, data: Any) -> None:
>>> cars = CSVDataset(filepath="cars.csv",
>>> load_args=None,
>>> save_args={"index": False})
>>> io = DataCatalog(datasets={'cars': cars})
>>> catalog = DataCatalog(datasets={'cars': cars})
>>>
>>> df = pd.DataFrame({'col1': [1, 2],
>>> 'col2': [4, 5],
>>> 'col3': [5, 6]})
>>> io.save("cars", df)
>>> catalog.save("cars", df)
"""
dataset = self._get_dataset(name)

Expand Down Expand Up @@ -642,11 +642,11 @@ def add(
>>> from kedro_datasets.pandas import CSVDataset
>>>
>>> io = DataCatalog(datasets={
>>> catalog = DataCatalog(datasets={
>>> 'cars': CSVDataset(filepath="cars.csv")
>>> })
>>>
>>> io.add("boats", CSVDataset(filepath="boats.csv"))
>>> catalog.add("boats", CSVDataset(filepath="boats.csv"))
"""
if dataset_name in self._datasets:
if replace:
Expand Down Expand Up @@ -678,17 +678,17 @@ def add_all(
>>> from kedro_datasets.pandas import CSVDataset, ParquetDataset
>>>
>>> io = DataCatalog(datasets={
>>> catalog = DataCatalog(datasets={
>>> "cars": CSVDataset(filepath="cars.csv")
>>> })
>>> additional = {
>>> "planes": ParquetDataset("planes.parq"),
>>> "boats": CSVDataset(filepath="boats.csv")
>>> }
>>>
>>> io.add_all(additional)
>>> catalog.add_all(additional)
>>>
>>> assert io.list() == ["cars", "planes", "boats"]
>>> assert catalog.list() == ["cars", "planes", "boats"]
"""
for name, dataset in datasets.items():
self.add(name, dataset, replace)
Expand Down Expand Up @@ -756,13 +756,13 @@ def list(self, regex_search: str | None = None) -> list[str]:
Example:
::
>>> io = DataCatalog()
>>> catalog = DataCatalog()
>>> # get data sets where the substring 'raw' is present
>>> raw_data = io.list(regex_search='raw')
>>> raw_data = catalog.list(regex_search='raw')
>>> # get data sets which start with 'prm' or 'feat'
>>> feat_eng_data = io.list(regex_search='^(prm|feat)')
>>> feat_eng_data = catalog.list(regex_search='^(prm|feat)')
>>> # get data sets which end with 'time_series'
>>> models = io.list(regex_search='.+time_series$')
>>> models = catalog.list(regex_search='.+time_series$')
"""

if regex_search is None:
Expand Down

0 comments on commit fd17607

Please sign in to comment.