Repository: apify/crawlee-python
File: src/crawlee/storage_clients/_base/_storage_client.py (Python)

Code before:
    from ._dataset_client import DatasetClient
    from ._key_value_store_client import KeyValueStoreClient
    from ._request_queue_client import RequestQueueClient


@docs_group('Storage clients')
class StorageClient(ABC):
    """Base class for storage clients.

    The `StorageClient` serves as an abstract base class that defines the interface for accessing Crawlee's
    storage types: datasets, key-value stores, and request queues. It provides methods to open clients for
    each of these storage types and handles common functionality.

    Storage clients implementations can be provided for various backends (file system, memory, databases,
    various cloud providers, etc.) to support different use cases from development to production environments.

    Each storage client implementation is responsible for ensuring proper initialization, data persistence
    (where applicable), and consistent access patterns across all storage types it supports.
    """

    def get_additional_cache_key(self, configuration: Configuration) -> Hashable:  # noqa: ARG002
        """Return a cache key that can differentiate between different storages of this and other clients.

        Can be based on configuration or on the client itself. By default, returns a name of the client class.
        """
        return self.__class__.__name__

    @abstractmethod
    async def create_dataset_client(
        self,
        *,
        id: str | None = None,
        name: str | None = None,
        alias: str | None = None,
        configuration: Configuration | None = None,
    ) -> DatasetClient:
        """Create a dataset client."""

    @abstractmethod
    async def create_kvs_client(
        self,
        *,
        id: str | None = None,
        name: str | None = None,
        alias: str | None = None,
        configuration: Configuration | None = None,
    ) -> KeyValueStoreClient:
        """Create a key-value store client."""

    @abstractmethod
    async def create_rq_client(

Review comment (suggestion):
Two points regarding this method:

- `self.__class__.__name__` is not unique enough - could you at least attach `__module__` as well?
- the name of the method will not be very fitting after this PR

Code after:
    from ._dataset_client import DatasetClient
    from ._key_value_store_client import KeyValueStoreClient
    from ._request_queue_client import RequestQueueClient


@docs_group('Storage clients')
class StorageClient(ABC):
    """Base class for storage clients.

    The `StorageClient` serves as an abstract base class that defines the interface for accessing Crawlee's
    storage types: datasets, key-value stores, and request queues. It provides methods to open clients for
    each of these storage types and handles common functionality.

    Storage clients implementations can be provided for various backends (file system, memory, databases,
    various cloud providers, etc.) to support different use cases from development to production environments.

    Each storage client implementation is responsible for ensuring proper initialization, data persistence
    (where applicable), and consistent access patterns across all storage types it supports.
    """

    def get_storage_client_cache_key(self, configuration: Configuration) -> Hashable:  # noqa: ARG002
        """Return a cache key that can differentiate between different storages of this and other clients.

        Can be based on configuration or on the client itself. By default, returns a module and name of the client
        class.
        """
        return f'{self.__class__.__module__}.{self.__class__.__name__}'

    @abstractmethod
    async def create_dataset_client(
        self,
        *,
        id: str | None = None,
        name: str | None = None,
        alias: str | None = None,
        configuration: Configuration | None = None,
    ) -> DatasetClient:
        """Create a dataset client."""

    @abstractmethod
    async def create_kvs_client(
        self,
        *,
        id: str | None = None,
        name: str | None = None,
        alias: str | None = None,
        configuration: Configuration | None = None,
    ) -> KeyValueStoreClient:
        """Create a key-value store client."""

    @abstractmethod