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

Csse pyd2 510 #347

Merged
merged 4 commits into from
Sep 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
22 changes: 4 additions & 18 deletions .github/workflows/CI.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,9 @@ jobs:
strategy:
fail-fast: false
matrix:
python-version: ["3.7", "3.9", "3.11", "3.12"]
pydantic-version: ["1", "2"]
python-version: ["3.7", "3.8", "3.9", "3.10", "3.11", "3.12"]
pydantic-version: ["2"]
runs-on: [ubuntu-latest, windows-latest]
exclude:
- runs-on: windows-latest
pydantic-version: "1"
name: "🐍 ${{ matrix.python-version }} • ${{ matrix.pydantic-version }} • ${{ matrix.runs-on }}"
runs-on: ${{ matrix.runs-on }}

Expand All @@ -35,15 +32,6 @@ jobs:
uses: actions/checkout@v3
- name: Install poetry
run: pip install poetry
# Force pydantic 1.0 by modifying poetry dep "pydantic" string with in-place sed
# -i is zero-length extension which does effectively in-place sub.
# Can't do -i '' because Ubuntu sed is -i{suffix} whereas OSX sed is -i {suffix}... ugh
# ^ start of line, pydantic, optional spaces and > sign, capture the version, replace with ^{version}
# Should avoid also replacing the autodoc-pydantic spec later on.
- name: Sed replace pydantic on repo
if: matrix.pydantic-version == '1'
run: |
sed -i 's/^pydantic *= *">*= *\([0-9.]*\)"/pydantic = "^\1"/' pyproject.toml
- name: Install repo with poetry (full deps)
if: matrix.python-version != '3.9'
run: poetry install --no-interaction --no-ansi --all-extras
Expand Down Expand Up @@ -74,12 +62,10 @@ jobs:
name: Set up Python
with:
python-version: "3.10"
- name: Setup Graphviz
uses: ts-graphviz/setup-graphviz@v2
- name: Install poetry
run: pip install poetry
# Force pydantic 1.0 by modifying poetry dep "pydantic" string with in-place sed (see above for details)
- name: Sed replace pydantic on repo
run: |
sed -i 's/^pydantic *= *">*= *\([0-9.]*\)"/pydantic = "^\1"/' pyproject.toml
- name: Install repo
run: poetry install --no-interaction --no-ansi
- name: Build Documentation
Expand Down
3 changes: 1 addition & 2 deletions docs/api.rst
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ QCElemental API
.. automodapi:: qcelemental.testing
:skip:tnm

.. automodapi:: qcelemental.models
:skip:Optimization
.. automodapi:: qcelemental.models.v2
:skip:qcschema_models

5 changes: 5 additions & 0 deletions docs/changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,18 @@ Changelog
Breaking Changes
++++++++++++++++
* The very old model names `ResultInput`, `Result`, `ResultProperties`, `Optimization` deprecated in 2019 are now only available through `qcelelemental.models.v1`
* ``models.v2`` do not support AutoDoc. The AutoDoc routines have been left at pydantic v1 syntax. Use autodoc-pydantic for Sphinx instead.

New Features
++++++++++++
* Downstream code should ``from qcelemental.models.v1 import Molecule, AtomicResult`` etc. to assure medium-term availability of existing models.
* New pydantic v2 models available as ``from qcelemental.models.v2 import Molecule, AtomicResult`` etc.

Enhancements
++++++++++++
* The ``models.v2`` have had their `schema_version` bumped for ``BasisSet``, ``AtomicInput``, ``OptimizationInput`` (implicit for ``AtomicResult`` and ``OptimizationResult``), ``TorsionDriveInput`` , and ``TorsionDriveResult``.
* The ``models.v2`` ``AtomicResultProperties`` has been given a ``schema_name`` and ``schema_version`` (2) for the first time.
* Note that ``models.v2`` ``QCInputSpecification`` and ``OptimizationSpecification`` have *not* had schema_version bumped.

Bug Fixes
+++++++++
Expand Down
13 changes: 7 additions & 6 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@
#
# This is also used if you do content translation via gettext catalogs.
# Usually you set "language" from the command line for these cases.
language = None
language = "en"

# List of patterns, relative to source directory, that match files and
# directories to ignore when looking for source files.
Expand All @@ -115,7 +115,7 @@
# Add any paths that contain custom static files (such as style sheets) here,
# relative to this directory. They are copied after the builtin static files,
# so a file named "default.css" will overwrite the builtin "default.css".
html_static_path = ["_static"]
html_static_path = [] # "_static"]

# Custom sidebar templates, must be a dictionary that maps document names
# to template names.
Expand Down Expand Up @@ -187,8 +187,8 @@
# -- Extension configuration -------------------------------------------------

extlinks = {
"issue": ("https://github.com/MolSSI/QCElemental/issues/%s", "GH#"),
"pr": ("https://github.com/MolSSI/QCElemental/pull/%s", "GH#"),
"issue": ("https://github.com/MolSSI/QCElemental/issues/%s", "GH#%s"),
"pr": ("https://github.com/MolSSI/QCElemental/pull/%s", "GH#%s"),
}


Expand All @@ -200,8 +200,9 @@
"numpy": ("https://numpy.org/doc/stable/", None),
"scipy": ("https://docs.scipy.org/doc/scipy/", None),
"matplotlib": ("https://matplotlib.org/stable/", None),
"qcengine": ("http://docs.qcarchive.molssi.org/projects/QCEngine/en/latest/", None),
"qcfractal": ("http://docs.qcarchive.molssi.org/projects/QCFractal/en/latest/", None),
"qcengine": ("https://molssi.github.io/QCEngine/", None),
"qcfractal": ("https://molssi.github.io/QCFractal/", None),
"nglview": ("https://nglviewer.org/nglview/release/v2.7.7", None),
}

# -- Options for todo extension ----------------------------------------------
Expand Down
16 changes: 8 additions & 8 deletions docs/model_common.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,40 +6,40 @@ Common Models used throughout the QCArchive ecosystem.
BasisSet
--------

.. autopydantic_model:: qcelemental.models.BasisSet
.. autopydantic_model:: qcelemental.models.v2.BasisSet
:noindex:

.. autopydantic_model:: qcelemental.models.basis.BasisCenter
.. autopydantic_model:: qcelemental.models.v2.basis.BasisCenter
:noindex:

.. autopydantic_model:: qcelemental.models.basis.ElectronShell
.. autopydantic_model:: qcelemental.models.v2.basis.ElectronShell
:noindex:

.. autopydantic_model:: qcelemental.models.basis.ECPPotential
.. autopydantic_model:: qcelemental.models.v2.basis.ECPPotential
:noindex:

ComputeError
------------

.. autopydantic_model:: qcelemental.models.ComputeError
.. autopydantic_model:: qcelemental.models.v2.ComputeError
:noindex:

FailedOperation
---------------

.. autopydantic_model:: qcelemental.models.FailedOperation
.. autopydantic_model:: qcelemental.models.v2.FailedOperation
:noindex:

Provenance
----------

.. autopydantic_model:: qcelemental.models.Provenance
.. autopydantic_model:: qcelemental.models.v2.Provenance
:noindex:

DriverEnum
----------

.. autoclass:: qcelemental.models.DriverEnum
.. autoclass:: qcelemental.models.v2.DriverEnum
:noindex:
:members:
:undoc-members:
Expand Down
2 changes: 1 addition & 1 deletion docs/model_molecule.rst
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,6 @@ Obtaining fragments with ghost atoms is also supported:
API
---

.. autopydantic_model:: qcelemental.models.Molecule
.. autopydantic_model:: qcelemental.models.v2.Molecule
:noindex:

10 changes: 5 additions & 5 deletions docs/model_result.rst
Original file line number Diff line number Diff line change
Expand Up @@ -8,25 +8,25 @@ A Python implementation of the `MolSSI QCSchema
AtomicInput
-----------

.. autopydantic_model:: qcelemental.models.AtomicInput
.. autopydantic_model:: qcelemental.models.v2.AtomicInput
:noindex:

AtomicResult
------------

.. autopydantic_model:: qcelemental.models.AtomicResult
.. autopydantic_model:: qcelemental.models.v2.AtomicResult
:noindex:


API
---

.. autopydantic_model:: qcelemental.models.results.AtomicResultProtocols
.. autopydantic_model:: qcelemental.models.v2.results.AtomicResultProtocols
:noindex:

.. autopydantic_model:: qcelemental.models.results.AtomicResultProperties
.. autopydantic_model:: qcelemental.models.v2.results.AtomicResultProperties
:noindex:

.. autopydantic_model:: qcelemental.models.results.WavefunctionProperties
.. autopydantic_model:: qcelemental.models.v2.results.WavefunctionProperties
:noindex:

60 changes: 47 additions & 13 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ classifiers = [
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Framework :: Pydantic",
"Framework :: Pydantic :: 2",
]

[tool.poetry.dependencies]
Expand All @@ -36,13 +38,13 @@ packaging = [
{ version = ">=24.1", python = ">=3.8" },
]
# qcel is compatible with most any numpy, v1 or v2, but numpy v2 only works with pint >=0.24, which is only available for py >=3.10
python = "^3.7"
python = "^3.7.1"
pint = [
{ version = ">=0.10", python = ">=3.7,<3.9" },
{ version = ">=0.23", python = ">=3.9,<3.10" },
{ version = ">=0.24", python = ">=3.10,<3.13" },
]
pydantic = ">=1.8.2"
pydantic = ">=2.0"
nglview = { version = "^3.0.3", optional = true }
ipykernel = { version = "<6.0.0", optional = true }
importlib-metadata = { version = ">=4.8", python = "<3.8" }
Expand All @@ -58,24 +60,56 @@ viz = ["nglview", "ipykernel"]
align = ["networkx", "scipy"]
test = ["pytest"]

# Note that all the versions below are a farce for poetry's benefit.
# One needs a fairly recent sphinx, pydantic, and autodoc-pydantic for a
# successful docs build, and that likely requires py 3.9."

[tool.poetry.group.dev.dependencies]
black = ">=22.1.0,<23.0a0"
mypy = "^1.1.1"
isort = "5.11.5"
flake8 = "<6.0.0"
pre-commit = "<3.2.0"
flake8 = [
{ version = "<6.0.0", python = "<3.8.1" },
{ version = "6.0.0", python = ">=3.8.1,<4.0.0" }
]
pre-commit = [
{ version = "<3.2.0", python = "<3.9" },
{ version = "^3.8.0", python = ">=3.9,<4.0.0" }
]
pytest-cov = "^4.0.0"
autoflake = "^2.0.2"
jsonschema = "^4.17.3"
msgpack = "^1.0.5"
numpydoc = "^1.5.0"
docutils = "<0.19"
sphinx = "<6.0.0"
jsonschema = { version = "^4.23.0", python = ">=3.8,<4.0.0" }
msgpack = { version = "^1.0.8", python = ">=3.8,<4.0.0" }
numpydoc = [
{ version = "^1.5.0", python = "<3.9" },
{ version = "^1.8.0", python = ">=3.9,<4.0.0" }
]
docutils = [
{ version = "<0.19", python = "<3.9" },
{ version = "0.20.1", python = ">=3.9,<4.0.0" }
]
sphinx = [
{ version = "<6.0.0", python = "<3.9" },
{ version = "^7.0.0", python = ">=3.9,<4.0.0" }
]
sphinxcontrib-napoleon = "^0.7"
sphinx-rtd-theme = "^1.2.0"
autodoc-pydantic = "^1.8.0"
sphinx-automodapi = "^0.15.0"
sphinx-autodoc-typehints = "^1.22"
sphinx-rtd-theme = [
{ version = "^1.2.0", python = "<3.9" },
{ version = "^2.0.0", python = ">=3.9,<4.0.0" }
]
autodoc-pydantic = [
{ version = "^2.0.0", python = "<3.8" },
{ version = "^2.1.0", python = ">=3.8,<4.0" }
]
sphinx-automodapi = [
{ version = "^0.15.0", python = "<3.8" },
{ version = "^0.17.0", python = ">=3.8,<4.0.0" }
]
sphinx-autodoc-typehints = [
{ version = "^1.22", python = "<3.10" },
{ version = "^2.3", python = ">=3.10,<4.0.0" }
]
graphviz = "^0.20.0" # insufficient on pypi as also need `dot`. python-graphviz sufficient in conda.

[tool.black]
line-length = 120
Expand Down
5 changes: 1 addition & 4 deletions qcelemental/info/cpu_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,7 @@
from functools import lru_cache
from typing import List, Optional

try:
from pydantic.v1 import Field
except ImportError: # Will also trap ModuleNotFoundError
from pydantic import Field
from pydantic.v1 import Field

from ..models import ProtoModel

Expand Down
5 changes: 1 addition & 4 deletions qcelemental/info/dft_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,7 @@

from typing import Dict

try:
from pydantic.v1 import Field
except ImportError: # Will also trap ModuleNotFoundError
from pydantic import Field
from pydantic.v1 import Field

from ..models import ProtoModel

Expand Down
9 changes: 9 additions & 0 deletions qcelemental/models/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1,10 @@
try:
import pydantic
except ImportError: # pragma: no cover
raise ImportError(
"Python module pydantic not found. Solve by installing it: "
"`conda install pydantic -c conda-forge` or `pip install pydantic`"
)

from . import v1, v2
from .v1 import *
8 changes: 0 additions & 8 deletions qcelemental/models/v1/__init__.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,3 @@
try:
import pydantic
except ImportError: # pragma: no cover
raise ImportError(
"Python module pydantic not found. Solve by installing it: "
"`conda install pydantic -c conda-forge` or `pip install pydantic`"
)

from . import types
from .align import AlignmentMill
from .basemodels import AutodocBaseSettings # remove when QCFractal merges `next`
Expand Down
6 changes: 1 addition & 5 deletions qcelemental/models/v1/align.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
from typing import Optional

import numpy as np

try:
from pydantic.v1 import Field, validator
except ImportError: # Will also trap ModuleNotFoundError
from pydantic import Field, validator
from pydantic.v1 import Field, validator

from ...util import blockwise_contract, blockwise_expand
from .basemodels import ProtoModel
Expand Down
9 changes: 2 additions & 7 deletions qcelemental/models/v1/basemodels.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,8 @@
from typing import Any, Dict, Optional, Set, Union

import numpy as np

try:
from pydantic.v1 import BaseSettings # remove when QCFractal merges `next`
from pydantic.v1 import BaseModel
except ImportError: # Will also trap ModuleNotFoundError
from pydantic import BaseSettings # remove when QCFractal merges `next`
from pydantic import BaseModel
from pydantic.v1 import BaseSettings # remove when QCFractal merges `next`
from pydantic.v1 import BaseModel

from qcelemental.util import deserialize, serialize
from qcelemental.util.autodocs import AutoPydanticDocGenerator # remove when QCFractal merges `next`
Expand Down
5 changes: 1 addition & 4 deletions qcelemental/models/v1/basis.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
from enum import Enum
from typing import Dict, List, Optional

try:
from pydantic.v1 import ConstrainedInt, Field, constr, validator
except ImportError: # Will also trap ModuleNotFoundError
from pydantic import ConstrainedInt, Field, constr, validator
from pydantic.v1 import ConstrainedInt, Field, constr, validator

from ...exceptions import ValidationError
from .basemodels import ProtoModel, qcschema_draft
Expand Down
Loading
Loading