-
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.
- Loading branch information
Showing
11 changed files
with
158 additions
and
6 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,35 @@ | ||
name: Testing example extensions | ||
|
||
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 .[test] | ||
- name: Install all packages in example/extension | ||
run: | | ||
python -m pip install -e example/extension/dummydataconnector[test] | ||
python -m pip install -e example/extension/dummydataprocessor[test] | ||
python -m pip install -e example/extension/dummymodel[test] | ||
- name: Test with pytest | ||
run: | | ||
pytest -vv example/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
1 change: 1 addition & 0 deletions
1
example/extension/dummydataconnector/dummydataconnector/__init__.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 @@ | ||
__version__ = "0.1.0" |
15 changes: 15 additions & 0 deletions
15
example/extension/dummydataconnector/dummydataconnector/dataconnector.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,15 @@ | ||
from __future__ import annotations | ||
|
||
from sdgx.data_connectors.base import DataConnector | ||
|
||
|
||
class MyOwnDataConnector(DataConnector): | ||
... | ||
|
||
|
||
from sdgx.data_connectors.extension import hookimpl | ||
|
||
|
||
@hookimpl | ||
def register(manager): | ||
manager.register("DummyDataConnector", MyOwnDataConnector) |
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 = "dummydataconnector" | ||
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 = "dummydataconnector/__init__.py" | ||
|
||
[project.entry-points."sdgx.data_connector"] | ||
dummydataconnector = "dummydataconnector.dataconnector" |
17 changes: 17 additions & 0 deletions
17
example/extension/dummydataconnector/tests/test_registed_data_connector.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,17 @@ | ||
import pytest | ||
|
||
from sdgx.data_connectors.manager import DataConnectorManager | ||
|
||
|
||
@pytest.fixture | ||
def manager(): | ||
yield DataConnectorManager() | ||
|
||
|
||
def test_registed_data_connector(manager: DataConnectorManager): | ||
assert "DummyDataConnector" in manager.registed_data_connectors | ||
manager.init_data_connector("DummyDataConnector") | ||
|
||
|
||
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
17 changes: 17 additions & 0 deletions
17
example/extension/dummydataprocessor/tests/test_registed_data_processor.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,17 @@ | ||
import pytest | ||
|
||
from sdgx.data_processors.manager import DataProcessorManager | ||
|
||
|
||
@pytest.fixture | ||
def manager(): | ||
yield DataProcessorManager() | ||
|
||
|
||
def test_registed_data_processor(manager: DataProcessorManager): | ||
assert "DummyDataProcessor" in manager.registed_data_processors | ||
manager.init_data_processors("DummyDataProcessor") | ||
|
||
|
||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import pytest | ||
|
||
from sdgx.models.manager import ModelManager | ||
|
||
|
||
@pytest.fixture | ||
def manager(): | ||
yield ModelManager() | ||
|
||
|
||
def test_registed_model(manager: ModelManager): | ||
assert "DummyModel" in manager.registed_models | ||
manager.init_model("DummyModel") | ||
|
||
|
||
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