From 7ebe49b6b1162d5a19d8c815718fc2430ddc1b16 Mon Sep 17 00:00:00 2001 From: narugo1992 Date: Wed, 4 Sep 2024 23:12:10 +0800 Subject: [PATCH] dev(narugo): add docs --- cheesechaser/datapool/konachan.py | 54 +++++++++++++++++++---- docs/source/api_doc/datapool/konachan.rst | 8 ++++ 2 files changed, 53 insertions(+), 9 deletions(-) diff --git a/cheesechaser/datapool/konachan.py b/cheesechaser/datapool/konachan.py index a85a2ce8a..d30e31fb9 100644 --- a/cheesechaser/datapool/konachan.py +++ b/cheesechaser/datapool/konachan.py @@ -1,13 +1,17 @@ """ -This module provides a data pool implementation for Konachan images. +This module provides data pool implementations for Konachan images. -It defines the KonachanDataPool class, which is a specialized version of the -IncrementIDDataPool for handling Konachan image data. The module uses a -predefined repository for storing and accessing Konachan image data. +It defines two classes: + +1. KonachanDataPool: A specialized version of IncrementIDDataPool for handling Konachan image data. +2. KonachanWebpDataPool: A specialized version of IncrementIDDataPool for handling Konachan WebP image data. + +The module uses predefined repositories for storing and accessing Konachan image data. .. note:: - The dataset `deepghs/konachan_full `_ - is gated, you have to get the access of it before using this module. + The datasets `deepghs/konachan_full `_ and + `deepghs/konachan-webp-4Mpixel `_ are gated. + You have to get access to them before using this module. """ from typing import Optional @@ -53,9 +57,6 @@ def __init__(self, revision: str = 'main', hf_token: Optional[str] = None): :type revision: str :param hf_token: Optional Hugging Face token for authentication, defaults to None. :type hf_token: Optional[str] - - Example: - >>> pool = KonachanDataPool(revision='v2.0', hf_token='my_secret_token') """ IncrementIDDataPool.__init__( self, @@ -71,7 +72,42 @@ def __init__(self, revision: str = 'main', hf_token: Optional[str] = None): class KonachanWebpDataPool(IncrementIDDataPool): + """ + A data pool class for managing Konachan WebP image data. + + This class extends the IncrementIDDataPool to provide specific functionality + for handling Konachan WebP image data. It uses a predefined repository to store + and access the WebP image data and indices. + + :param revision: The revision of the data to use, defaults to 'main'. + :type revision: str + :param hf_token: Optional Hugging Face token for authentication, defaults to None. + :type hf_token: Optional[str] + + Usage: + >>> konachan_webp_pool = KonachanWebpDataPool() + >>> konachan_webp_pool_with_token = KonachanWebpDataPool(hf_token='your_token_here') + >>> konachan_webp_pool_specific_revision = KonachanWebpDataPool(revision='v1.0') + + Note: + The KonachanWebpDataPool uses a predefined repository (_KONACHAN_WEBP_REPO) for both + data and index storage. This ensures consistency in data access and management + for Konachan WebP images. + """ + def __init__(self, revision: str = 'main', hf_token: Optional[str] = None): + """ + Initialize the KonachanWebpDataPool. + + This constructor sets up the KonachanWebpDataPool with the specified revision + and optional Hugging Face token. It initializes the underlying IncrementIDDataPool + with the predefined Konachan WebP repository for both data and index management. + + :param revision: The revision of the data to use, defaults to 'main'. + :type revision: str + :param hf_token: Optional Hugging Face token for authentication, defaults to None. + :type hf_token: Optional[str] + """ IncrementIDDataPool.__init__( self, data_repo_id=_KONACHAN_WEBP_REPO, diff --git a/docs/source/api_doc/datapool/konachan.rst b/docs/source/api_doc/datapool/konachan.rst index a5c3c79d8..475610880 100644 --- a/docs/source/api_doc/datapool/konachan.rst +++ b/docs/source/api_doc/datapool/konachan.rst @@ -14,3 +14,11 @@ KonachanDataPool +KonachanWebpDataPool +----------------------------------------------------- + +.. autoclass:: KonachanWebpDataPool + :members: __doc__,__init__,__module__ + + +