Skip to content

Commit

Permalink
Resolved merge conflicts in authentication approach
Browse files Browse the repository at this point in the history
  • Loading branch information
MeenaBana committed Mar 1, 2024
2 parents 8e9e9d3 + 65c652a commit 174beef
Show file tree
Hide file tree
Showing 12 changed files with 34 additions and 37 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/tox.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ['3.8', '3.9', '3.10']
python-version: ['3.9', '3.10', '3.11']
defaults:
run:
working-directory: /home/runner/work/pyPrediktorMapClient/pyPrediktorMapClient
Expand Down
2 changes: 1 addition & 1 deletion .readthedocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ formats:
- pdf

python:
version: 3.8
version: 3.9
install:
- requirements: docs/requirements.txt
- {path: ., method: pip}
2 changes: 2 additions & 0 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,8 @@
# If this is True, todo emits a warning for each TODO entries. The default is False.
todo_emit_warnings = True

# Since the documentation build process doesn't need to make actual database connections, we can mock the pyodbc module during the documentation build.
autodoc_mock_imports = ["pyodbc"]

# -- Options for HTML output -------------------------------------------------

Expand Down
13 changes: 8 additions & 5 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ package_dir =
=src

# Require a min/specific Python version (comma-separated conditions)
python_requires = >=3.8
python_requires = >=3.9

# Add here dependencies of your project (line-separated), e.g. requests>=2.2,<3.0.
# Version specifiers like >=2.2,<3.0 avoid problems due to API changes in
Expand All @@ -53,7 +53,8 @@ install_requires =
aiohttp >= 3.8.1
pydantic >= 2.0
pandas >= 1.4.4
pyodbc >= 4.0.39
pyodbc
pyPrediktorUtilities >= 0.3.2

[options.packages.find]
where = src
Expand All @@ -70,6 +71,8 @@ testing =
setuptools
pytest
pytest-cov
pyPrediktorUtilities >= 0.3.2
pyodbc

[options.entry_points]

Expand Down Expand Up @@ -118,10 +121,10 @@ version = 4.3
package = pyprediktormapclient

[tox:tox]
envlist = py38, py39, py310, mypy
envlist = py39, py310, py311, mypy

[gh-actions]
python =
3.8: py38
3.9: py39
3.10: py310, mypy
3.10: py310, mypy
3.11: py311
2 changes: 1 addition & 1 deletion src/pyprediktormapclient/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from .opc_ua import *

if sys.version_info[:2] >= (3, 8):
# TODO: Import directly (no need for conditional) when `python_requires = >= 3.8`
# TODO: Import directly (no need for conditional) when `python_requires = >= 3.9`
from importlib.metadata import PackageNotFoundError, version # pragma: no cover
else:
from importlib_metadata import PackageNotFoundError, version # pragma: no cover
Expand Down
8 changes: 4 additions & 4 deletions src/pyprediktormapclient/dwh/context/enercast.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import json
from pydantic import validate_call
from typing import List, Dict, Any, Union
from typing import List, Dict, Union

from ..idwh import IDWH

Expand All @@ -10,19 +10,19 @@ def __init__(self, dwh: IDWH) -> None:
self.dwh = dwh

@validate_call
def get_plants_to_update(self) -> List[Any]:
def get_plants_to_update(self) -> List:
query = "SET NOCOUNT ON; EXEC dwetl.GetEnercastPlantsToUpdate"
return self.dwh.fetch(query)

@validate_call
def get_live_meter_data(self, asset_name: str) -> List[Any]:
def get_live_meter_data(self, asset_name: str) -> List:
query = f"SET NOCOUNT ON; EXEC dwetl.GetEnercastLiveMeterData '{asset_name}'"
return self.dwh.fetch(query)

@validate_call
def upsert_forecast_data(
self, enercast_forecast_data: Dict, forecast_type_key: Union[int, None] = None
) -> List[Any]:
) -> List:
enercast_forecast_data_json = json.dumps({"results": enercast_forecast_data})

query = "EXEC dwetl.UpsertEnercastForecastData ?, ?"
Expand Down
8 changes: 4 additions & 4 deletions src/pyprediktormapclient/dwh/context/plant.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import json
from pydantic import validate_call
from typing import List, Dict, Any
from typing import List, Dict

from ..idwh import IDWH

Expand All @@ -10,15 +10,15 @@ def __init__(self, dwh: IDWH) -> None:
self.dwh = dwh

@validate_call
def get_optimal_tracker_angles(self, facility_name: str) -> List[Any]:
def get_optimal_tracker_angles(self, facility_name: str) -> List:
query = (
f"SET NOCOUNT ON; EXEC dwetl.GetOptimalTrackerAngleParameters "
+ f"@FacilityName = N'{facility_name}'"
)
return self.dwh.fetch(query)

@validate_call
def upsert_optimal_tracker_angles(self, facility_data: Dict) -> List[Any]:
def upsert_optimal_tracker_angles(self, facility_data: Dict) -> List:
facility_data_json = json.dumps(facility_data)
facility_data_json.replace("'", '"')

Expand All @@ -33,7 +33,7 @@ def insert_log(
data_type: str,
has_thrown_error: bool = False,
message: str = "",
) -> List[Any]:
) -> List:
query = "EXEC dwetl.InsertExtDataUpdateLog @plantname = ?, @extkey = ?, @DataType = ?, @Message = ?, @Result = ?"
return self.dwh.execute(
query,
Expand Down
6 changes: 3 additions & 3 deletions src/pyprediktormapclient/dwh/context/solcast.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import json
from pydantic import validate_call
from typing import List, Dict, Any, Union
from typing import List, Dict, Union

from ..idwh import IDWH

Expand All @@ -10,7 +10,7 @@ def __init__(self, dwh: IDWH) -> None:
self.dwh = dwh

@validate_call
def get_plants_to_update(self) -> List[Any]:
def get_plants_to_update(self) -> List:
query = "SET NOCOUNT ON; EXEC dwetl.GetSolcastPlantsToUpdate"
return self.dwh.fetch(query)

Expand All @@ -20,7 +20,7 @@ def upsert_forecast_data(
plantname: str,
solcast_forecast_data: Dict,
forecast_type_key: Union[int, None] = None,
) -> List[Any]:
) -> List:
solcast_forecast_data_json = json.dumps(
{
"results": {
Expand Down
14 changes: 4 additions & 10 deletions src/pyprediktormapclient/dwh/dwh.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
import importlib
from typing import Dict
from pydantic import validate_call
from pyprediktorutilities import Dwh as Db

from .db import Db
from . import context
from .idwh import IDWH

Expand Down Expand Up @@ -65,17 +65,11 @@ def __init__(

@validate_call
def version(self) -> Dict:
"""Get the DWH version.
"""
Get the DWH version.
Returns:
Dict: A dictionary with the following keys (or similar):
DWHVersion,
UpdateDate,
ImplementedDate,
Comment,
MajorVersionNo,
MinorVersionNo,
InterimVersionNo
Dict: A dictionary with the following keys (or similar): DWHVersion, UpdateDate, ImplementedDate, Comment, MajorVersionNo, MinorVersionNo, InterimVersionNo
"""
query = "SET NOCOUNT ON; EXEC [dbo].[GetVersion]"
results = self.fetch(query)
Expand Down
6 changes: 3 additions & 3 deletions src/pyprediktormapclient/dwh/idwh.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from typing import Dict, List, Any
from typing import Dict, List
from abc import ABC, abstractmethod


Expand All @@ -8,9 +8,9 @@ def version(self) -> Dict:
pass

@abstractmethod
def fetch(self, query: str, to_dataframe: bool = False) -> List[Any]:
def fetch(self, query: str, to_dataframe: bool = False) -> List:
pass

@abstractmethod
def execute(self, query: str, *args, **kwargs) -> List[Any]:
def execute(self, query: str, *args, **kwargs) -> List:
pass
3 changes: 0 additions & 3 deletions tests/dwh/test_db.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,6 @@
"""
Helpers
"""

class Config:
arbitrary_types_allowed = True

class mock_pyodbc_connection:
def __init__(self, connection_string):
Expand Down
5 changes: 3 additions & 2 deletions tests/dwh/test_dwh.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,15 @@ def grs():
Test Functions
"""


def test_init_when_instantiate_dwh_but_pyodbc_throws_error_with_tolerance_to_attempts_then_throw_exception(
monkeypatch,
):
driver_index = 0

# Mock the database connection
monkeypatch.setattr(
"pyprediktormapclient.dwh.db.pyodbc.connect",
"pyprediktorutilities.dwh.pyodbc.connect",
mock_pyodbc_connection_throws_error_not_tolerant_to_attempts,
)

Expand All @@ -58,7 +59,7 @@ def test_init_when_instantiate_dwh_but_pyodbc_throws_error_tolerant_to_attempts_

# Mock the database connection
monkeypatch.setattr(
"pyprediktormapclient.dwh.db.pyodbc.connect",
"pyprediktorutilities.dwh.pyodbc.connect",
mock_pyodbc_connection_throws_error_tolerant_to_attempts,
)

Expand Down

0 comments on commit 174beef

Please sign in to comment.