From 523cd597ea7ed1928ebd3e420363e700bfd1d63c Mon Sep 17 00:00:00 2001 From: Andrew Rosen Date: Tue, 26 Sep 2023 16:52:17 -1000 Subject: [PATCH 01/14] pydantic bump --- pyproject.toml | 12 +++++++----- src/jobflow/settings.py | 12 +++++------- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index f249f045..5e69c59b 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -28,10 +28,11 @@ classifiers = [ requires-python = ">=3.8" dependencies = [ "PyYAML", - "maggma>=0.38.1", - "monty>=2021.5.9", + "maggma>=0.57.0", + "monty>=2023.9.25", "networkx", - "pydantic<2", + "pydantic>=2.4.1", + "pydantic-settings>=2.0.3", "pydash", ] @@ -52,12 +53,13 @@ fireworks = ["FireWorks"] strict = [ "FireWorks==2.0.3", "PyYAML==6.0.1", - "maggma==0.56.0", + "maggma==0.57.0", "matplotlib==3.7.2", "monty==2023.9.25", "moto==4.2.4", "networkx==3.1", - "pydantic==1.10.9", + "pydantic==2.4.1", + "pydantic-settings==2.0.3", "pydash==7.0.6", "pydot==1.4.2", "typing-extensions==4.8.0", diff --git a/src/jobflow/settings.py b/src/jobflow/settings.py index 4f42257b..08effab6 100644 --- a/src/jobflow/settings.py +++ b/src/jobflow/settings.py @@ -5,9 +5,10 @@ from pathlib import Path from maggma.stores import MemoryStore -from pydantic import BaseSettings, Field, root_validator +from pydantic import model_validator, Field from jobflow import JobStore +from pydantic_settings import BaseSettings, SettingsConfigDict DEFAULT_CONFIG_FILE_PATH = Path("~/.jobflow.yaml").expanduser().as_posix() @@ -118,13 +119,10 @@ class JobflowSettings(BaseSettings): "%Y-%m-%d-%H-%M-%S-%f", description="Date stamp format used to create directories", ) + model_config = SettingsConfigDict(env_prefix="jobflow_") - class Config: - """Pydantic config settings.""" - - env_prefix = "jobflow_" - - @root_validator(pre=True) + @model_validator(mode="before") + @classmethod def load_default_settings(cls, values): """ Load settings from file or environment variables. From c7c588e8b258c03b07c67be71cb1a898d78e646e Mon Sep 17 00:00:00 2001 From: Andrew Rosen Date: Tue, 26 Sep 2023 16:54:30 -1000 Subject: [PATCH 02/14] fix --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 5e69c59b..3b6749f4 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -38,7 +38,7 @@ dependencies = [ [project.optional-dependencies] docs = [ - "autodoc_pydantic==1.9.0", + "autodoc_pydantic==2.0.1", "furo==2023.9.10", "ipython==8.15.0", "myst_parser==2.0.0", From 72d810cdd2ea3f2b4b80297fb60623d7da2c22d9 Mon Sep 17 00:00:00 2001 From: Andrew Rosen Date: Tue, 26 Sep 2023 16:55:43 -1000 Subject: [PATCH 03/14] lint --- src/jobflow/settings.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/jobflow/settings.py b/src/jobflow/settings.py index 08effab6..e27b0da9 100644 --- a/src/jobflow/settings.py +++ b/src/jobflow/settings.py @@ -6,9 +6,9 @@ from maggma.stores import MemoryStore from pydantic import model_validator, Field +from pydantic_settings import BaseSettings, SettingsConfigDict from jobflow import JobStore -from pydantic_settings import BaseSettings, SettingsConfigDict DEFAULT_CONFIG_FILE_PATH = Path("~/.jobflow.yaml").expanduser().as_posix() From 34491b0895526464054ae23740c7ee67681e6798 Mon Sep 17 00:00:00 2001 From: Andrew Rosen Date: Tue, 26 Sep 2023 17:01:20 -1000 Subject: [PATCH 04/14] lint --- src/jobflow/settings.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/jobflow/settings.py b/src/jobflow/settings.py index e27b0da9..7b813f80 100644 --- a/src/jobflow/settings.py +++ b/src/jobflow/settings.py @@ -5,7 +5,7 @@ from pathlib import Path from maggma.stores import MemoryStore -from pydantic import model_validator, Field +from pydantic import Field, model_validator from pydantic_settings import BaseSettings, SettingsConfigDict from jobflow import JobStore From 3bed5e9f17d07cc81dfa1c4cd58c03ba228c2688 Mon Sep 17 00:00:00 2001 From: Andrew Rosen Date: Tue, 26 Sep 2023 17:06:58 -1000 Subject: [PATCH 05/14] patch --- tests/core/test_reference.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/core/test_reference.py b/tests/core/test_reference.py index d4c5f699..2d805e13 100644 --- a/tests/core/test_reference.py +++ b/tests/core/test_reference.py @@ -161,7 +161,7 @@ class InnerSchema(BaseModel): class MediumSchema(BaseModel): s: str nested: InnerSchema - nested_opt: Optional[InnerSchema] + nested_opt: Optional[InnerSchema] = None nested_u: Union[InnerSchema, dict] nested_l: List[InnerSchema] nested_d: Dict[str, InnerSchema] From 9b1e4e3f6499a177f87891a2d604306ec20052bb Mon Sep 17 00:00:00 2001 From: Andrew Rosen Date: Tue, 26 Sep 2023 17:17:13 -1000 Subject: [PATCH 06/14] patch --- src/jobflow/core/reference.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/jobflow/core/reference.py b/src/jobflow/core/reference.py index bb71d145..c8df29ad 100644 --- a/src/jobflow/core/reference.py +++ b/src/jobflow/core/reference.py @@ -8,7 +8,7 @@ from monty.json import MontyDecoder, MontyEncoder, MSONable, jsanitize from pydantic import BaseModel -from pydantic.utils import lenient_issubclass +from pydantic.v1.utils import lenient_issubclass from jobflow.utils.enum import ValueEnum From 68074ba31f44d90aebf78c622857aeb0bceab7d0 Mon Sep 17 00:00:00 2001 From: "Andrew S. Rosen" Date: Tue, 26 Sep 2023 17:20:48 -1000 Subject: [PATCH 07/14] Update pyproject.toml --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 3b6749f4..7c07fb02 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -31,7 +31,7 @@ dependencies = [ "maggma>=0.57.0", "monty>=2023.9.25", "networkx", - "pydantic>=2.4.1", + "pydantic>=2.0", "pydantic-settings>=2.0.3", "pydash", ] From 28ddf86f2cdf392490130ac007d3cfbd34ffb34e Mon Sep 17 00:00:00 2001 From: "Andrew S. Rosen" Date: Tue, 26 Sep 2023 17:21:26 -1000 Subject: [PATCH 08/14] Update pyproject.toml --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 7c07fb02..a227cae4 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -31,7 +31,7 @@ dependencies = [ "maggma>=0.57.0", "monty>=2023.9.25", "networkx", - "pydantic>=2.0", + "pydantic>=2.0.1", "pydantic-settings>=2.0.3", "pydash", ] From 2acc5e286bf8c9d45dbc545dda806eb292969fc7 Mon Sep 17 00:00:00 2001 From: Andrew Rosen Date: Wed, 27 Sep 2023 19:23:52 -1000 Subject: [PATCH 09/14] patch --- src/jobflow/core/reference.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/jobflow/core/reference.py b/src/jobflow/core/reference.py index c8df29ad..223ed31b 100644 --- a/src/jobflow/core/reference.py +++ b/src/jobflow/core/reference.py @@ -503,7 +503,7 @@ def validate_schema_access( raise AttributeError(f"{schema.__name__} does not have attribute '{item}'.") subschema = None - item_type = schema.__fields__[item].outer_type_ + item_type = schema.model_fields[item].annotation if lenient_issubclass(item_type, BaseModel): subschema = item_type From 85f0caeb991f916e60113b1b6956b862502b5bee Mon Sep 17 00:00:00 2001 From: Andrew Rosen Date: Wed, 27 Sep 2023 19:44:31 -1000 Subject: [PATCH 10/14] patch --- tests/core/test_reference.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/tests/core/test_reference.py b/tests/core/test_reference.py index 2d805e13..fcab0e21 100644 --- a/tests/core/test_reference.py +++ b/tests/core/test_reference.py @@ -184,25 +184,25 @@ class MySchema(BaseModel): assert new_ref.output_schema is None with pytest.raises(AttributeError): - assert ref.a.uuid == "123" + ref.a.uuid with pytest.raises(AttributeError): - assert ref["a"].uuid == "123" + ref["a"].uuid with pytest.raises(AttributeError): - assert ref[1].uuid == "123" + ref[1].uuid # check valid nested schemas assert ref.nested.s.uuid == "123" with pytest.raises(AttributeError): - assert ref.nested.m.uuid == "123" + ref.nested.m.uuid assert ref.nested.nested.n.uuid == "123" with pytest.raises(AttributeError): - assert ref.nested.nested.m.uuid == "123" + ref.nested.nested.m.uuid assert ref.nested.nested_opt.n.uuid == "123" with pytest.raises(AttributeError): - assert ref.nested.nested_opt.m.uuid == "123" + ref.nested.nested_opt.m.uuid # Union, List and Dict are currently not recognized by their inner type # but check that there is no problem with them From 4fe1f66a793dff529e38b870101b9c964a42caa4 Mon Sep 17 00:00:00 2001 From: Andrew Rosen Date: Wed, 27 Sep 2023 19:48:14 -1000 Subject: [PATCH 11/14] patch --- pyproject.toml | 1 + 1 file changed, 1 insertion(+) diff --git a/pyproject.toml b/pyproject.toml index a227cae4..40410b35 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -86,6 +86,7 @@ extend-ignore = "E203, W503, E501, F401, RST21" min-python-version = "3.8.0" docstring-convention = "numpy" rst-roles = "class, func, ref, obj" +extend-exclude = ["tests"] [tool.mypy] ignore_missing_imports = true From 3e3c9cffd1b8caaa32ccb60de7e26c2f9634cfe0 Mon Sep 17 00:00:00 2001 From: Andrew Rosen Date: Wed, 27 Sep 2023 19:50:10 -1000 Subject: [PATCH 12/14] patch --- pyproject.toml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 40410b35..78cf0c04 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -86,7 +86,6 @@ extend-ignore = "E203, W503, E501, F401, RST21" min-python-version = "3.8.0" docstring-convention = "numpy" rst-roles = "class, func, ref, obj" -extend-exclude = ["tests"] [tool.mypy] ignore_missing_imports = true @@ -145,4 +144,4 @@ isort.known-first-party = ["jobflow"] [tool.ruff.per-file-ignores] "__init__.py" = ["F401"] -"**/tests/*" = ["D"] +"**/tests/*" = ["D", "B018] From bb9c2fac63c18a8aa6c647199eb83a62cb1bf2d1 Mon Sep 17 00:00:00 2001 From: Andrew Rosen Date: Wed, 27 Sep 2023 19:51:23 -1000 Subject: [PATCH 13/14] patch --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 78cf0c04..f0ac1b67 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -144,4 +144,4 @@ isort.known-first-party = ["jobflow"] [tool.ruff.per-file-ignores] "__init__.py" = ["F401"] -"**/tests/*" = ["D", "B018] +"**/tests/*" = ["D", "B018"] From de0d676b2a009194afba761a91601be5ee61d6b0 Mon Sep 17 00:00:00 2001 From: Andrew Rosen Date: Wed, 27 Sep 2023 19:56:42 -1000 Subject: [PATCH 14/14] update --- tests/core/test_reference.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/core/test_reference.py b/tests/core/test_reference.py index fcab0e21..544270e2 100644 --- a/tests/core/test_reference.py +++ b/tests/core/test_reference.py @@ -1,4 +1,4 @@ -from typing import Dict, List, Optional, Union +from typing import Dict, List, Union import pytest @@ -161,7 +161,7 @@ class InnerSchema(BaseModel): class MediumSchema(BaseModel): s: str nested: InnerSchema - nested_opt: Optional[InnerSchema] = None + nested_opt: InnerSchema = None nested_u: Union[InnerSchema, dict] nested_l: List[InnerSchema] nested_d: Dict[str, InnerSchema]