Skip to content

Conversation

@ram-from-tvl
Copy link
Contributor

@ram-from-tvl ram-from-tvl commented Dec 18, 2025

Pull Request

Description

  1. Dockerfile - Added comment explaining that .git folder is needed for setuptools-git-versioning to read version from git tags
  2. pyproject.toml - Added setuptools-git-versioning>=2.0,<3 to build-system requirements

Fixes #126

Checklist:

  • My code follows OCF's coding style guidelines
  • I have performed a self-review of my own code
  • I have made corresponding changes to the documentation
  • I have added tests that prove my fix is effective or that my feature works
  • I have checked my code and corrected any misspellings

- Add setuptools-git-versioning to build-system requirements
- Add comment explaining .git folder is needed for versioning
- This fixes the issue where version showed as 0.0.0 in Docker logs
Copilot AI review requested due to automatic review settings December 18, 2025 11:02
@ram-from-tvl
Copy link
Contributor Author

Hi @peterdudfield
I have made the requested changes.
Please review the code and let me know if we are good to go.
Thank you!

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR addresses issue #126 by fixing a Docker version problem and implementing backup data generation for missing GSP (Grid Supply Point) data. The solution creates fallback data by scaling national-level solar generation data proportionally based on installed capacity when specific GSP data is unavailable.

Key changes:

  • Implements backup GSP data generation using national data and installed capacity ratios from the database
  • Adds setuptools-git-versioning to build requirements to fix Docker versioning issues
  • Tracks missing GSPs and generates proportional data when national data is available

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.

File Description
solar_consumer/data/fetch_gb_data.py Added logic to detect missing GSP data and generate backup values scaled from national data using database-sourced capacity ratios
pyproject.toml Added setuptools-git-versioning dependency to build requirements to support version detection during Docker builds
Dockerfile Added comment explaining that .git folder is required for setuptools-git-versioning to function

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +190 to +197
for _, national_row in national_df.iterrows():
national_capacity = national_row['installedcapacity_mwp']
if national_capacity == 0 or pd.isna(national_capacity):
continue
for location in locations:
if location.installed_capacity_mw is not None and location.installed_capacity_mw > 0:
factor = location.installed_capacity_mw / national_capacity
new_row = national_row.copy()
Copy link

Copilot AI Dec 18, 2025

Choose a reason for hiding this comment

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

Using iterrows() is inefficient for DataFrame iteration. Consider using vectorized operations or itertuples() for better performance, especially when processing multiple missing GSPs with the full national dataset.

Suggested change
for _, national_row in national_df.iterrows():
national_capacity = national_row['installedcapacity_mwp']
if national_capacity == 0 or pd.isna(national_capacity):
continue
for location in locations:
if location.installed_capacity_mw is not None and location.installed_capacity_mw > 0:
factor = location.installed_capacity_mw / national_capacity
new_row = national_row.copy()
for national_row in national_df.itertuples(index=False):
national_capacity = national_row.installedcapacity_mwp
if national_capacity == 0 or pd.isna(national_capacity):
continue
base_row = national_row._asdict()
for location in locations:
if location.installed_capacity_mw is not None and location.installed_capacity_mw > 0:
factor = location.installed_capacity_mw / national_capacity
new_row = base_row.copy()

Copilot uses AI. Check for mistakes.
try:
connection = DatabaseConnection(url=db_url)
with connection.get_session() as session:
locations = session.query(LocationSQL).filter(LocationSQL.gsp_id.in_(missing_gsps)).all()
Copy link

Copilot AI Dec 18, 2025

Choose a reason for hiding this comment

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

The database query fetches all locations for missing GSPs but is executed inside the loop that processes each GSP. This query should remain outside any iteration loop to avoid potential N+1 query issues if the code structure changes.

Copilot uses AI. Check for mistakes.
Comment on lines +196 to +198
factor = location.installed_capacity_mw / national_capacity
new_row = national_row.copy()
new_row['solar_generation_kw'] *= factor
Copy link

Copilot AI Dec 18, 2025

Choose a reason for hiding this comment

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

The scaling logic creates backup data by multiplying generation values by a capacity factor. Consider extracting this calculation into a separate function to improve testability and clarify the backup data generation algorithm.

Copilot uses AI. Check for mistakes.
@peterdudfield
Copy link
Contributor

Ill let you answer CoPilot code review, and then Ill have a look

@@ -1,5 +1,5 @@
[build-system]
requires = ["setuptools>=61.0"]
requires = ["setuptools>=61.0", "setuptools-git-versioning>=2.0,<3"]
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this is the only change needed for this PR, the other cahgnes dont relate this issue. You ok to change them

@peterdudfield
Copy link
Contributor

Ill close this for the moment, if thats ok

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug: version not showing up in docker

2 participants