Skip to content

Commit

Permalink
fix: 🐛 Moving to model_validator for pydantic v2
Browse files Browse the repository at this point in the history
  • Loading branch information
awhipp committed May 2, 2024
1 parent 871a752 commit ec7ae08
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
8 changes: 4 additions & 4 deletions foresight/utils/aws.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,14 @@ def get_client(service_type: str):
service_type,
aws_access_key_id=os.getenv("AWS_ACCESS_KEY_ID"),
aws_secret_access_key=os.getenv("AWS_SECRET_ACCESS_KEY"),
region_name=os.getenv("AWS_REGION_NAME"),
region_name=os.getenv("AWS_REGION"),
)
else:
return boto3.client(
service_type,
aws_access_key_id=os.getenv("AWS_ACCESS_KEY_ID"),
aws_secret_access_key=os.getenv("AWS_SECRET_ACCESS_KEY"),
region_name=os.getenv("AWS_REGION_NAME"),
region_name=os.getenv("AWS_REGION"),
endpoint_url=endpoint_url,
)

Expand All @@ -37,13 +37,13 @@ def get_resource(service_type: str):
service_type,
aws_access_key_id=os.getenv("AWS_ACCESS_KEY_ID"),
aws_secret_access_key=os.getenv("AWS_SECRET_ACCESS_KEY"),
region_name=os.getenv("AWS_REGION_NAME"),
region_name=os.getenv("AWS_REGION"),
)
else:
return boto3.resource(
service_type,
aws_access_key_id=os.getenv("AWS_ACCESS_KEY_ID"),
aws_secret_access_key=os.getenv("AWS_SECRET_ACCESS_KEY"),
region_name=os.getenv("AWS_REGION_NAME"),
region_name=os.getenv("AWS_REGION"),
endpoint_url=endpoint_url,
)
4 changes: 2 additions & 2 deletions foresight/utils/models/forex_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from typing import Optional

from pydantic import BaseModel
from pydantic import root_validator
from pydantic import model_validator

from foresight.utils.database import TimeScaleService
from foresight.utils.logger import generate_logger
Expand Down Expand Up @@ -37,7 +37,7 @@ class ForexData(BaseModel):
ask: Optional[float] = None
price: Optional[float] = None

@root_validator(skip_on_failure=True)
@model_validator(mode="before")
def check_bid_ask_or_price(cls, values): # pylint: disable=no-self-argument
"""Validates that either bid and ask are defined, or price is defined.
Expand Down

1 comment on commit ec7ae08

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Coverage

Code Coverage
FileStmtsMissCoverMissing
foresight
   __init__.py00100% 
foresight/indicator_services
   __init__.py00100% 
   indicator.py64640%3–5, 7–10, 12, 15, 18, 21–24, 26, 33–38, 44, 46–50, 52, 54, 57, 63, 65, 67–69, 73, 77–78, 82–84, 88, 90, 92, 94, 96, 108, 110–111, 117, 119, 122, 125, 128, 130, 132, 134–136, 138–139, 141, 143, 145
   moving_average_indicator.py18180%3, 5–6, 9, 12, 20–21, 28, 30, 33–34, 36–37, 40, 42, 45–46, 51
foresight/interface_service
   __init__.py00100% 
   app.py31310%3–4, 6–9, 11–12, 15, 18, 20, 23, 25, 33–34, 36, 39–40, 42, 45–46, 48–51, 53–54, 56, 59–61
foresight/stream_service
   __init__.py00100% 
   app.py711381%82, 110, 131, 133–134, 139, 142–148
foresight/stream_service/models
   __init__.py00100% 
   pricing.py40100% 
   stream.py180100% 
foresight/utils
   __init__.py00100% 
   aws.py12558%14, 33, 35–36, 43
   database.py551180%52–53, 70–71, 76, 91–92, 94, 98–100
   logger.py90100% 
foresight/utils/models
   __init__.py00100% 
   forex_data.py61296%164–165
   subscription_feed.py25292%90–91
foresight/window_service
   __init__.py00100% 
   app.py351071%20, 25–27, 70–71, 75, 77–78, 80
tests
   conftest.py240100% 
tests/stream_service
   conftest.py19952%21–22, 30, 33, 37–41
   stream_service_test.py410100% 
tests/utils/models
   forex_data_test.py610100% 
   subscription_feeds_test.py360100% 
tests/window_service
   window_service_test.py370100% 
TOTAL62116573% 

Please sign in to comment.