Skip to content

Commit

Permalink
Fix to use with pv site production (#32)
Browse files Browse the repository at this point in the history
* Make the sqlalchemy dependency more flexible

* Expose types

* add site relationship on GenerationSQL

Co-authored-by: Simon Lemieux <[email protected]>
  • Loading branch information
peterdudfield and simlmx authored Jan 27, 2023
1 parent ab7478b commit b823474
Show file tree
Hide file tree
Showing 5 changed files with 5 additions and 1 deletion.
Empty file.
2 changes: 2 additions & 0 deletions sdk/python/pvsite_datamodel/sqlmodels.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
SQLAlchemy definition of the pvsite database schema
"""
from __future__ import annotations

# This means we can use Typing of objects that have jet to be defined

import uuid
Expand Down Expand Up @@ -89,6 +90,7 @@ class GenerationSQL(Base, CreatedMixin):
datetime_interval: DatetimeIntervalSQL = relationship(
"DatetimeIntervalSQL", back_populates="generation"
)
site: SiteSQL = relationship("SiteSQL", back_populates="generation")


class ForecastSQL(Base, CreatedMixin):
Expand Down
2 changes: 1 addition & 1 deletion sdk/python/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@ psycopg2-binary==2.9.5
pytest==7.2.1
python-dateutil==2.8.2
setuptools==65.6.3
SQLAlchemy==1.4.44
SQLAlchemy >= 1.4.44, == 1.4.*
testcontainers==3.7.1
1 change: 1 addition & 0 deletions sdk/python/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,5 @@
setup(
long_description=long_description,
long_description_content_type="text/markdown",
package_data={"pvsite_datamodel": ["pvsite-datamodel/py.typed"]},
)
1 change: 1 addition & 0 deletions sdk/python/tests/test_read.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ def test_gets_generation_for_single_input_site(self, generations, db_session):

assert len(generations) == 10
assert generations[0].datetime_interval is not None
assert generations[0].site is not None

def test_gets_generation_for_multiple_input_sites(self, generations, db_session):
query: Query = db_session.query(SiteSQL)
Expand Down

0 comments on commit b823474

Please sign in to comment.