Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: added support for Pydantic V2 #487

Closed
wants to merge 59 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
59 commits
Select commit Hold shift + click to select a range
be01c39
build: removed exclude src in pre-commit-config
camilovelezr Feb 16, 2023
79fd117
refactor: added docstrings to top of scripts
camilovelezr Feb 27, 2023
f726f80
refactor: addressed most of flake8
camilovelezr Mar 2, 2023
c782ef0
Merge branch 'nickupdate' of github.com:camilovelezr/polus-plugins in…
camilovelezr Mar 2, 2023
b32c4a5
refactor: refactored to pass flake8 and remove plugins class
camilovelezr Mar 3, 2023
cd70c77
refactor: fixed isort and black conflicts
camilovelezr Mar 7, 2023
77c09b7
refactor: removed unused code in __init__.py
camilovelezr Mar 7, 2023
d4088b1
refactor: removed extra comments
camilovelezr Mar 7, 2023
5aea47e
fix: fixed missing character in pyproject.toml
camilovelezr Mar 8, 2023
4f09101
feat: improved error handling of manifests' validation errors
camilovelezr Mar 8, 2023
6c62833
refactor: removed logger config
camilovelezr Mar 10, 2023
604b530
feat: added cwl methods
camilovelezr Mar 15, 2023
5f87610
build: modified authors in pyproject.toml
camilovelezr Mar 15, 2023
6cae5c6
build: modified authors in pyproject.toml
camilovelezr Mar 15, 2023
378484a
Merge branch 'nickupdate' into err2
camilovelezr Mar 15, 2023
b417cc7
Merge branch 'err2' into cwl3
camilovelezr Mar 15, 2023
08ef8f5
refactor: removed 'files' from outputbinding
camilovelezr Apr 14, 2023
18a1b78
Merge branch 'master' into err2
camilovelezr Apr 14, 2023
d827d67
Merge branch 'err2' into cwl3
camilovelezr Apr 14, 2023
1f14b0a
fix: fixed Union operator for Python <3.10
camilovelezr Apr 24, 2023
95ec314
refactor: removed global var invalid_manifest
camilovelezr Apr 24, 2023
30a96d1
fix: fixed collection not as directory type
camilovelezr Apr 25, 2023
e4e6cd4
fix: fixed lower case d in Directory output
camilovelezr Apr 25, 2023
51f3814
refactor: refactored enums in CLT to str for compat with workflows
camilovelezr Apr 25, 2023
e622e19
Merge branch 'err2' into cwl3
camilovelezr May 15, 2023
49f76cc
build: added cwltool to pyproject.toml
camilovelezr May 15, 2023
02b0687
Merge branch 'cwl3' into rm1
camilovelezr May 15, 2023
f2ec33a
fix: removed | for unions
camilovelezr May 15, 2023
a6e92e0
Merge branch 'cwl3' into rm1
camilovelezr May 15, 2023
11282b5
feat: added methods to remove plugins
camilovelezr May 15, 2023
3bf67b7
feat: added refresh to update functions
camilovelezr May 15, 2023
17ff571
refactor: general refactoring
camilovelezr May 30, 2023
e9924f1
refactor: added missing type hint in plugin_methods
camilovelezr May 30, 2023
42cbf86
style: addressed review comments
camilovelezr Jul 7, 2023
eb3b63b
chore: removed poetry.lock
camilovelezr Jul 7, 2023
7ee8b0d
Merge branch 'master' into rm1
camilovelezr Jul 7, 2023
a6d229d
Merge branch 'master' into rm1
camilovelezr Jul 17, 2023
b637530
fix: fixed rm all
camilovelezr Oct 26, 2023
a45e05d
Merge branch 'master' into rm1
camilovelezr Oct 26, 2023
6391d45
fix: fixed unexported load_config function
camilovelezr May 17, 2023
90f8335
fix: fixed last rebase
camilovelezr Oct 26, 2023
1ac6808
chore: edited gitignore
camilovelezr Apr 24, 2023
1acab6f
chore: updated gitignore to include node_modules
camilovelezr May 16, 2023
af67ab5
test: added initial tests
camilovelezr May 17, 2023
dc02e08
tests: refactored test_cwl
camilovelezr May 22, 2023
4cb0e8c
tests: refactored tests
camilovelezr May 23, 2023
0c3828b
refactor: renamed omeconverter.json
camilovelezr May 30, 2023
6311575
refactor: refactored test_plugins test_manifests
camilovelezr Jun 5, 2023
5bd377f
fix: fixed pyproject and all tests passing
camilovelezr Oct 26, 2023
1d3285a
feat: improved version comparison
camilovelezr Jul 27, 2023
de915a2
fix: fixed wrong imports
camilovelezr Jul 27, 2023
3446967
fix: restored plugin_classes from test2
camilovelezr Oct 26, 2023
7a55c53
fix: fix DuplicateVersionFound in plugin_classes
camilovelezr Oct 26, 2023
506a94b
feat: improved version comparison
camilovelezr Oct 26, 2023
56c31d9
fix: fixed dependencies order
camilovelezr Nov 7, 2023
76ce715
Merge branch 'master' into ver2
camilovelezr Nov 27, 2023
d0b1e59
feat: added pydantic v2 support
camilovelezr Nov 24, 2023
0a579d1
fix: fixed load_config and save_config
camilovelezr Dec 4, 2023
7186dae
tests: updated tests to include pydantic v2
camilovelezr Dec 4, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 14 additions & 9 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
fail_fast: true

repos:

- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0
hooks:
Expand All @@ -21,38 +20,44 @@ repos:
- id: detect-private-key
- id: end-of-file-fixer
- id: mixed-line-ending
args: ['--fix=lf']
args: ["--fix=lf"]
description: Forces to replace line ending by the UNIX 'lf' character.
- id: trailing-whitespace
exclude: '.bumpversion.cfg'
exclude: ".bumpversion.cfg"
- id: check-merge-conflict

- repo: https://github.com/psf/black
rev: '23.3.0'
rev: "23.3.0"
hooks:
- id: black
language_version: python3.9
exclude: ^src\/polus\/plugins\/_plugins\/models\/\w*Schema.py$
exclude: |
(?x)(
^src\/polus\/plugins\/_plugins\/models\/pydanticv1\/\w*Schema.py$|
^src\/polus\/plugins\/_plugins\/models\/pydanticv2\/\w*Schema.py$
)

- repo: https://github.com/charliermarsh/ruff-pre-commit
# Ruff version.
rev: 'v0.0.274'
rev: "v0.0.274"
hooks:
- id: ruff
exclude: |
(?x)(
test_[a-zA-Z0-9]+.py$|
^src\/polus\/plugins\/_plugins\/models\/\w*Schema.py$
^src\/polus\/plugins\/_plugins\/models\/pydanticv1\/\w*Schema.py$|
^src\/polus\/plugins\/_plugins\/models\/pydanticv2\/\w*Schema.py$
)
args: [--fix]

- repo: https://github.com/pre-commit/mirrors-mypy
rev: 'v1.4.0'
rev: "v1.4.0"
hooks:
- id: mypy
exclude: |
(?x)(
test_[a-zA-Z0-9]+.py$|
^src\/polus\/plugins\/_plugins\/models\/\w*Schema.py$
^src\/polus\/plugins\/_plugins\/models\/pydanticv1\/\w*Schema.py$|
^src\/polus\/plugins\/_plugins\/models\/pydanticv2\/\w*Schema.py$
)
additional_dependencies: [types-requests==2.31.0.1]
15 changes: 7 additions & 8 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,37 +10,36 @@ repository = "https://github.com/PolusAI/polus-plugins"
version = "0.1.1"

[tool.poetry.dependencies]
python = ">=3.9, <3.12"

click = "^8.1.3"
cwltool = "^3.1.20230513155734"
fsspec = "^2023.6.0"
pydantic = ">=1.10.9, <2.0"
pydantic = ">=1.10.0"
pygithub = "^1.58.2"
python = ">=3.9, <3.12"
python-on-whales = "^0.57.0"
python-on-whales = "^0.66.0"
pyyaml = "^6.0"
tqdm = "^4.65.0"
validators = "^0.22.0"
xmltodict = "^0.13.0"

[tool.poetry.group.dev.dependencies]
python = ">=3.9, <3.12"

black = "^23.3.0"
bump2version = "^1.0.1"
datamodel-code-generator = "^0.17.1"
datamodel-code-generator = "^0.23.0"
flake8 = "^6.0.0"
fsspec = "^2023.1.0"
mypy = "^1.4.0"
nox = "^2022.11.21"
poetry = "^1.3.2"
pre-commit = "^3.3.3"
pydantic = "^1.10.4"
pydantic-to-typescript = "^1.0.10"
pytest = "^7.3.2"
pytest-benchmark = "^4.0.0"
pytest-cov = "^4.1.0"
pytest-sugar = "^0.9.7"
pytest-xdist = "^3.3.1"
python = ">=3.9, <3.12"
python-on-whales = "^0.57.0"
pyyaml = "^6.0"
ruff = "^0.0.274"
tqdm = "^4.64.1"
Expand Down
4 changes: 4 additions & 0 deletions src/polus/plugins/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@
"""
logger = logging.getLogger("polus.plugins")

VERSION = "0.1.1"


refresh() # calls the refresh method when library is imported

Expand All @@ -39,6 +41,8 @@ def __getattr__(name: str) -> Union[Plugin, ComputePlugin, list]:
return list_plugins()
if name in list_plugins():
return get_plugin(name)
if name == "__version__":
return VERSION
msg = f"module '{__name__}' has no attribute '{name}'"
raise AttributeError(msg)

Expand Down
39 changes: 30 additions & 9 deletions src/polus/plugins/_plugins/classes/__init__.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,32 @@
"""Plugin classes and functions."""
from polus.plugins._plugins.classes.plugin_classes import ComputePlugin
from polus.plugins._plugins.classes.plugin_classes import Plugin
from polus.plugins._plugins.classes.plugin_classes import get_plugin
from polus.plugins._plugins.classes.plugin_classes import list_plugins
from polus.plugins._plugins.classes.plugin_classes import load_config
from polus.plugins._plugins.classes.plugin_classes import refresh
from polus.plugins._plugins.classes.plugin_classes import remove_all
from polus.plugins._plugins.classes.plugin_classes import remove_plugin
from polus.plugins._plugins.classes.plugin_classes import submit_plugin
import pydantic

PYDANTIC_VERSION = pydantic.__version__

if PYDANTIC_VERSION.split(".")[0] == "1":
from polus.plugins._plugins.classes.plugin_classes_v1 import PLUGINS
from polus.plugins._plugins.classes.plugin_classes_v1 import ComputePlugin
from polus.plugins._plugins.classes.plugin_classes_v1 import Plugin
from polus.plugins._plugins.classes.plugin_classes_v1 import _load_plugin
from polus.plugins._plugins.classes.plugin_classes_v1 import get_plugin
from polus.plugins._plugins.classes.plugin_classes_v1 import list_plugins
from polus.plugins._plugins.classes.plugin_classes_v1 import load_config
from polus.plugins._plugins.classes.plugin_classes_v1 import refresh
from polus.plugins._plugins.classes.plugin_classes_v1 import remove_all
from polus.plugins._plugins.classes.plugin_classes_v1 import remove_plugin
from polus.plugins._plugins.classes.plugin_classes_v1 import submit_plugin
elif PYDANTIC_VERSION.split(".")[0] == "2":
from polus.plugins._plugins.classes.plugin_classes_v2 import PLUGINS
from polus.plugins._plugins.classes.plugin_classes_v2 import ComputePlugin
from polus.plugins._plugins.classes.plugin_classes_v2 import Plugin
from polus.plugins._plugins.classes.plugin_classes_v2 import _load_plugin
from polus.plugins._plugins.classes.plugin_classes_v2 import get_plugin
from polus.plugins._plugins.classes.plugin_classes_v2 import list_plugins
from polus.plugins._plugins.classes.plugin_classes_v2 import load_config
from polus.plugins._plugins.classes.plugin_classes_v2 import refresh
from polus.plugins._plugins.classes.plugin_classes_v2 import remove_all
from polus.plugins._plugins.classes.plugin_classes_v2 import remove_plugin
from polus.plugins._plugins.classes.plugin_classes_v2 import submit_plugin

__all__ = [
"Plugin",
Expand All @@ -19,4 +38,6 @@
"remove_plugin",
"remove_all",
"load_config",
"_load_plugin",
"PLUGINS",
]
Loading