Skip to content

Commit

Permalink
dev(narugo): add docs
Browse files Browse the repository at this point in the history
  • Loading branch information
narugo1992 committed Sep 4, 2024
1 parent bf64bc6 commit 7ebe49b
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 9 deletions.
54 changes: 45 additions & 9 deletions cheesechaser/datapool/konachan.py
Original file line number Diff line number Diff line change
@@ -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 <https://huggingface.co/datasets/deepghs/konachan_full>`_
is gated, you have to get the access of it before using this module.
The datasets `deepghs/konachan_full <https://huggingface.co/datasets/deepghs/konachan_full>`_ and
`deepghs/konachan-webp-4Mpixel <https://huggingface.co/datasets/deepghs/konachan-webp-4Mpixel>`_ are gated.
You have to get access to them before using this module.
"""

from typing import Optional
Expand Down Expand Up @@ -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,
Expand All @@ -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,
Expand Down
8 changes: 8 additions & 0 deletions docs/source/api_doc/datapool/konachan.rst
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,11 @@ KonachanDataPool



KonachanWebpDataPool
-----------------------------------------------------

.. autoclass:: KonachanWebpDataPool
:members: __doc__,__init__,__module__



0 comments on commit 7ebe49b

Please sign in to comment.