Repository: kedro-org/kedro
File: kedro/io/core.py (Python)

Code before:

    @abc.abstractmethod
    def _load(self) -> _DO:
        raise NotImplementedError(
            f"'{self.__class__.__name__}' is a subclass of AbstractDataset and "
            f"it must implement the '_load' method"
        )

    @abc.abstractmethod
    def _save(self, data: _DI) -> None:
        raise NotImplementedError(
            f"'{self.__class__.__name__}' is a subclass of AbstractDataset and "
            f"it must implement the '_save' method"
        )

    @abc.abstractmethod
    def _describe(self) -> dict[str, Any]:
        raise NotImplementedError(
            f"'{self.__class__.__name__}' is a subclass of AbstractDataset and "
            f"it must implement the '_describe' method"
        )

    def exists(self) -> bool:
        """Checks whether a data set's output already exists by calling
        the provided _exists() method.

        Returns:
            Flag indicating whether the output already exists.

        Raises:
            DatasetError: when underlying exists method raises error.

        """
        try:
            self._logger.debug("Checking whether target of %s exists", str(self))
            return self._exists()
        except Exception as exc:
            message = (
                f"Failed during exists check for data set {str(self)}.\n{str(exc)}"
            )
            raise DatasetError(message) from exc

    def _exists(self) -> bool:
        self._logger.warning(
            "'exists()' not implemented for '%s'. Assuming output does not exist.",
            self.__class__.__name__,
        )
        return False

    def release(self) -> None:
        """Release any cached data.

Review comment (suggestion):
If it comes from `kedro_datasets`, I feel like it would be much cleaner to have the short name users can provide (i.e. `pandas.CSVDataset` instead of `kedro_datasets.pandas.csv_dataset.CSVDataset`).

Similarly, from Kedro core, `MemoryDataset`, etc. seems much easier to read than the full path.

Code after:
                    fmt.format(key, _to_str(value))  # 2
                    for key, value in sorted_dict
                    if value is not None  # 3
                )

                return text if is_root else "{" + text + "}"  # 1

            # not a dictionary
            return str(obj)

        return f"{type(self).__name__}({_to_str(self._describe(), True)})"

    def _pretty_repr(self, object_description: dict[str, Any]) -> str:
        str_keys = []
        for arg_name, arg_descr in object_description.items():
            if arg_descr is not None:
                descr = pprint.pformat(
                    arg_descr,
                    sort_dicts=False,
                    compact=True,
                    depth=2,
                    width=sys.maxsize,
                )
                str_keys.append(f"{arg_name}={descr}")

        return f"{type(self).__module__}.{type(self).__name__}({', '.join(str_keys)})"

    def __repr__(self) -> str:
        return self._pretty_repr(self._describe())

    @abc.abstractmethod
    def _load(self) -> _DO:
        raise NotImplementedError(
            f"'{self.__class__.__name__}' is a subclass of AbstractDataset and "
            f"it must implement the '_load' method"
        )

    @abc.abstractmethod
    def _save(self, data: _DI) -> None:
        raise NotImplementedError(
            f"'{self.__class__.__name__}' is a subclass of AbstractDataset and "
            f"it must implement the '_save' method"
        )

    @abc.abstractmethod
    def _describe(self) -> dict[str, Any]:
        raise NotImplementedError(
            f"'{self.__class__.__name__}' is a subclass of AbstractDataset and "
            f"it must implement the '_describe' method"
        )