From 471666995b8d930255daeb19b1c5402270b78fde Mon Sep 17 00:00:00 2001 From: Daniel Thom Date: Wed, 22 Nov 2023 13:15:00 -0700 Subject: [PATCH] Upgrade pydantic to v2 --- disco/models/base.py | 6 ++---- disco/models/power_flow_generic_models.py | 2 +- disco/models/snapshot_impact_analysis_model.py | 2 +- disco/models/time_series_analysis_model.py | 2 +- disco/models/upgrade_cost_analysis_equipment_model.py | 4 ++-- disco/models/upgrade_cost_analysis_generic_input_model.py | 3 ++- disco/models/upgrade_cost_analysis_generic_output_model.py | 2 +- disco/models/upgrade_cost_analysis_model.py | 2 +- disco/version.py | 2 +- setup.py | 6 +++--- 10 files changed, 15 insertions(+), 16 deletions(-) diff --git a/disco/models/base.py b/disco/models/base.py index 13c5160e..1b9ed948 100644 --- a/disco/models/base.py +++ b/disco/models/base.py @@ -5,10 +5,8 @@ from enum import Enum from typing import List, Optional, Union, Set -from pydantic.class_validators import validator, root_validator -from pydantic.fields import Field -from pydantic.main import BaseModel -from pydantic.types import DirectoryPath, FilePath +from pydantic.v1 import validator, root_validator, Field, BaseModel +from pydantic.v1.types import DirectoryPath, FilePath from jade.utils.utils import ExtendedJSONEncoder, standardize_timestamp from PyDSS.common import ControllerType diff --git a/disco/models/power_flow_generic_models.py b/disco/models/power_flow_generic_models.py index 026460de..01bdc40c 100644 --- a/disco/models/power_flow_generic_models.py +++ b/disco/models/power_flow_generic_models.py @@ -2,7 +2,7 @@ from pathlib import Path from typing import Dict, List, Optional, Set -from pydantic import BaseModel, Field, root_validator, validator +from pydantic.v1 import BaseModel, Field, root_validator, validator from jade.utils.utils import load_data diff --git a/disco/models/snapshot_impact_analysis_model.py b/disco/models/snapshot_impact_analysis_model.py index 369b779f..a9c73116 100644 --- a/disco/models/snapshot_impact_analysis_model.py +++ b/disco/models/snapshot_impact_analysis_model.py @@ -2,7 +2,7 @@ from typing import Optional -from pydantic.fields import Field +from pydantic.v1 import Field from .base import ImpactAnalysisBaseModel diff --git a/disco/models/time_series_analysis_model.py b/disco/models/time_series_analysis_model.py index 5120d733..6849e780 100644 --- a/disco/models/time_series_analysis_model.py +++ b/disco/models/time_series_analysis_model.py @@ -2,7 +2,7 @@ from typing import Optional -from pydantic.fields import Field +from pydantic.v1 import Field from .base import ImpactAnalysisBaseModel diff --git a/disco/models/upgrade_cost_analysis_equipment_model.py b/disco/models/upgrade_cost_analysis_equipment_model.py index 34332d52..62c43e03 100644 --- a/disco/models/upgrade_cost_analysis_equipment_model.py +++ b/disco/models/upgrade_cost_analysis_equipment_model.py @@ -3,7 +3,7 @@ from typing import Any from pathlib import Path from typing import Optional, List -from pydantic import BaseModel, Field, validator +from pydantic.v1 import BaseModel, Field, validator from jade.utils.utils import load_data @@ -551,4 +551,4 @@ class ExtraTransformerParams(BaseModel): title="amp_limit_per_phase", description="amp_limit_per_phase. This is a new field, not a direct OpenDSS object property.", determine_upgrade_option=True, - ) \ No newline at end of file + ) diff --git a/disco/models/upgrade_cost_analysis_generic_input_model.py b/disco/models/upgrade_cost_analysis_generic_input_model.py index c732d7c4..5256d140 100644 --- a/disco/models/upgrade_cost_analysis_generic_input_model.py +++ b/disco/models/upgrade_cost_analysis_generic_input_model.py @@ -1,5 +1,6 @@ from typing import List, Optional, Set, Dict -from pydantic import Field, root_validator, validator, ValidationError +from pydantic.v1 import Field, root_validator, validator +from pydantic.v1.error_wrappers import ValidationError import pandas as pd diff --git a/disco/models/upgrade_cost_analysis_generic_output_model.py b/disco/models/upgrade_cost_analysis_generic_output_model.py index 61bfaf21..1af36835 100644 --- a/disco/models/upgrade_cost_analysis_generic_output_model.py +++ b/disco/models/upgrade_cost_analysis_generic_output_model.py @@ -1,7 +1,7 @@ import enum import logging from typing import List, Optional, Set, Dict, Any -from pydantic import Field +from pydantic.v1 import Field from disco.models.upgrade_cost_analysis_equipment_model import UpgradeParamsBaseModel, ExtraLineParams, ExtraTransformerParams from disco.models.upgrade_cost_analysis_generic_input_model import OpenDSSLineModel, OpenDSSTransformerModel diff --git a/disco/models/upgrade_cost_analysis_model.py b/disco/models/upgrade_cost_analysis_model.py index d5858462..f55a9c03 100644 --- a/disco/models/upgrade_cost_analysis_model.py +++ b/disco/models/upgrade_cost_analysis_model.py @@ -1,6 +1,6 @@ from typing import Optional -from pydantic.fields import Field +from pydantic.v1 import Field from disco.models.base import ( BaseAnalysisModel, diff --git a/disco/version.py b/disco/version.py index df124332..3d187266 100644 --- a/disco/version.py +++ b/disco/version.py @@ -1 +1 @@ -__version__ = "0.4.2" +__version__ = "0.5.0" diff --git a/setup.py b/setup.py index c478900f..8dc7ec6e 100644 --- a/setup.py +++ b/setup.py @@ -60,17 +60,17 @@ def install_jade_extensions(): version = lines[0].split()[2].strip('"').strip("'") install_requires = [ - "NREL-jade~=0.9.3", + "NREL-jade~=0.10.0", "chevron~=0.14.0", "click~=8.0", - "dsspy~=2.3.0", + "dsspy~=3.0.0", "filelock~=3.8", "matplotlib~=3.6", "networkx~=2.8", "opendssdirect.py~=0.8.4", "openpyxl~=3.0", "pandas~=1.5.0", - "pydantic~=1.6", + "pydantic~=2.5.2", "seaborn~=0.12.1", "scikit-learn~=1.1", "sqlalchemy~=1.4",