-
Notifications
You must be signed in to change notification settings - Fork 541
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
0.1.0: Intro DataConnector and DataLoader (#64)
This PR contains the following main elements: - `Data Connector` and `DataLoader` implemented - `Cacher` for `DataLoader` and `CacherManager` for extensions - Some chore: docs build test, example...
- Loading branch information
Showing
56 changed files
with
1,289 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
name: Testing docs build | ||
|
||
on: | ||
push: | ||
branches: ["master", "main"] | ||
pull_request: | ||
branches: ["master", "main"] | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
python-version: ["3.8", "3.11"] | ||
|
||
steps: | ||
- uses: actions/checkout@v3 | ||
- name: Set up Python ${{ matrix.python-version }} | ||
uses: actions/setup-python@v5 | ||
with: | ||
python-version: ${{ matrix.python-version }} | ||
cache: "pip" | ||
- name: Install dependencies | ||
run: | | ||
python -m pip install --upgrade pip | ||
python -m pip install -e .[docs] | ||
- name: Test build docs | ||
run: | | ||
cd docs | ||
make clean && make html |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -52,5 +52,5 @@ repos: | |
rev: "v1.7.1" | ||
hooks: | ||
- id: mypy | ||
files: duetector | ||
files: sdgx | ||
stages: [manual] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
Cacher | ||
======================= | ||
|
||
.. autoclass:: sdgx.cachers.base.Cacher | ||
:members: | ||
:undoc-members: | ||
:inherited-members: | ||
:show-inheritance: | ||
:private-members: | ||
|
||
|
||
|
||
NoCache | ||
======================= | ||
|
||
.. autoclass:: sdgx.cachers.base.NoCache | ||
:members: | ||
:undoc-members: | ||
:inherited-members: | ||
:show-inheritance: | ||
:private-members: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
DiskCache | ||
======================= | ||
|
||
.. autoclass:: sdgx.cachers.disk_cache.DiskCache | ||
:members: | ||
:undoc-members: | ||
:inherited-members: | ||
:show-inheritance: | ||
:private-members: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
.. _api_reference/cacher-extension: | ||
|
||
Extension hookspec | ||
============================ | ||
|
||
.. automodule:: sdgx.cachers.extension | ||
:members: | ||
:undoc-members: | ||
:inherited-members: | ||
:show-inheritance: | ||
:private-members: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
Cacher | ||
======================================================== | ||
|
||
Built-in Cacher | ||
----------------------------- | ||
|
||
.. toctree:: | ||
:maxdepth: 2 | ||
|
||
base <base> | ||
MemoryCache <memory_cache> | ||
DiskCache <disk_cache> | ||
|
||
Custom Cacher Relevant | ||
----------------------------- | ||
|
||
.. toctree:: | ||
:maxdepth: 2 | ||
|
||
Extension hookspec <extension> | ||
CacherManager <manager> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
CacherManager | ||
================================= | ||
|
||
.. autoclass:: sdgx.cachers.manager.CacherManager | ||
:members: | ||
:undoc-members: | ||
:inherited-members: | ||
:show-inheritance: | ||
:private-members: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
MemoryCache | ||
========================== | ||
|
||
.. autoclass:: sdgx.cachers.memory_cache.MemoryCache | ||
:members: | ||
:undoc-members: | ||
:inherited-members: | ||
:show-inheritance: | ||
:private-members: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
DataConnector | ||
======================= | ||
|
||
.. autoclass:: sdgx.data_connectors.base.DataConnector | ||
:members: | ||
:undoc-members: | ||
:inherited-members: | ||
:show-inheritance: | ||
:private-members: |
10 changes: 10 additions & 0 deletions
10
docs/source/api_reference/data_connectors/csv_connector.rst
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
CsvConnector | ||
===================================== | ||
|
||
|
||
.. autoclass:: sdgx.data_connectors.csv_connector.CsvConnector | ||
:members: | ||
:undoc-members: | ||
:inherited-members: | ||
:show-inheritance: | ||
:private-members: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
.. _api_reference/data-connector-extension: | ||
|
||
Extension hookspec | ||
============================ | ||
|
||
.. automodule:: sdgx.data_connectors.extension | ||
:members: | ||
:undoc-members: | ||
:inherited-members: | ||
:show-inheritance: | ||
:private-members: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
DataConnector | ||
======================================================== | ||
|
||
Built-in DataConnector | ||
----------------------------- | ||
|
||
.. toctree:: | ||
:maxdepth: 2 | ||
|
||
DataConnector <base> | ||
CsvConnector <csv_connector> | ||
|
||
Custom DataConnector Relevant | ||
----------------------------- | ||
|
||
.. toctree:: | ||
:maxdepth: 2 | ||
|
||
Extension hookspec <extension> | ||
DataConnectorManager <manager> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
DataConnectorManager | ||
================================= | ||
|
||
.. autoclass:: sdgx.data_connectors.manager.DataConnectorManager | ||
:members: | ||
:undoc-members: | ||
:inherited-members: | ||
:show-inheritance: | ||
:private-members: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
Data Loader | ||
============================ | ||
|
||
.. automodule:: sdgx.data_loader | ||
:members: | ||
:undoc-members: | ||
:private-members: | ||
:show-inheritance: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
Exceptions | ||
============================ | ||
|
||
.. automodule:: sdgx.exceptions | ||
:members: | ||
:undoc-members: | ||
:inherited-members: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
.. _manager: | ||
|
||
Manager | ||
======================= | ||
|
||
|
||
.. autoclass:: sdgx.manager.Manager | ||
:members: | ||
:undoc-members: | ||
:private-members: | ||
:show-inheritance: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
Synthesizer | ||
================================== | ||
|
||
.. autoclass:: sdgx.synthesizer.Synthesizer | ||
:members: | ||
:undoc-members: | ||
:private-members: | ||
:show-inheritance: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
Extented Synthetic Data Generator | ||
===================================== | ||
|
||
.. NOTE:: | ||
|
||
Understand the purpose of each component from the :ref:`architecture`. | ||
|
||
SDG uses `pluggy <https://github.com/pytest-dev/pluggy>`_ to develop plug-in systems, | ||
which is based on the `entry-points of Python project <https://packaging.python.org/en/latest/specifications/entry-points/#entry-points>`_. | ||
|
||
A plugin project is made up of three parts: | ||
|
||
- A class, inherits from the ``register_type`` of :ref:`Manager <manager>`, which contains your own logic. | ||
- A register function, which's name is defined(decorated) by ``@hookspec``. | ||
and you need to implement it and use ``@hookimp`` to declare it as a registed hook. | ||
- A ``entry-points`` in ``pyproject.toml``, which pointing to the hookimp function. The subdomain of the entry-point | ||
is the ``PROJECT_NAME`` you can find in :ref:`manager`. | ||
|
||
|
||
View latest extension example on `GitHub <https://github.com/hitsz-ids/synthetic-data-generator/tree/main/example/extension>`_. | ||
|
||
|
||
Plugin-supported modules | ||
------------------------ | ||
|
||
- :ref:`Cacher for DataLoader <api_reference/cacher-extension>` | ||
- :ref:`Data Connector <_api_reference/data-connector-extension>` | ||
- :ref:`Data Processor <_api_reference/data-processor-extension>` | ||
- :ref:`Model <_api_reference/model-extension>` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
__version__ = "0.1.0" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
from __future__ import annotations | ||
|
||
from sdgx.cachers.base import Cacher | ||
|
||
|
||
class MyOwnCache(Cacher): | ||
... | ||
|
||
|
||
from sdgx.cachers.extension import hookimpl | ||
|
||
|
||
@hookimpl | ||
def register(manager): | ||
manager.register("DummyCache", MyOwnCache) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
[build-system] | ||
requires = ["hatchling"] | ||
build-backend = "hatchling.build" | ||
|
||
[project] | ||
name = "dummycache" | ||
dependencies = ["sdgx"] | ||
dynamic = ["version"] | ||
requires-python = ">=3.8" | ||
classifiers = [ | ||
"Programming Language :: Python :: 3", | ||
'Programming Language :: Python :: 3.8', | ||
'Programming Language :: Python :: 3.9', | ||
'Programming Language :: Python :: 3.10', | ||
'Programming Language :: Python :: 3.11', | ||
] | ||
[project.optional-dependencies] | ||
test = ["pytest"] | ||
|
||
[tool.check-manifest] | ||
ignore = [".*"] | ||
|
||
[tool.hatch.version] | ||
path = "dummycache/__init__.py" | ||
|
||
[project.entry-points."sdgx.cacher"] | ||
dummycache = "dummycache.dummycache" |
16 changes: 16 additions & 0 deletions
16
example/extension/dummycache/tests/test_registed_cacher.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import pytest | ||
|
||
from sdgx.cachers.manager import CacherManager | ||
|
||
|
||
@pytest.fixture | ||
def manager(): | ||
yield CacherManager() | ||
|
||
|
||
def test_registed_cacher(manager: CacherManager): | ||
assert manager._normalize_name("DummyCache") in manager.registed_cachers | ||
|
||
|
||
if __name__ == "__main__": | ||
pytest.main(["-vv", "-s", __file__]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.