-
-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Formatting and Saving Forecast Data with Tests #24
base: main
Are you sure you want to change the base?
Formatting and Saving Forecast Data with Tests #24
Conversation
Hi @peterdudfield , I wanted to let you know that I have tested the functionality locally by running the following commands:
Both tests passed successfully, and I verified the database entries for accuracy. However, as this is my first time writing tests, I approached this with a lot of learning. I referenced the project's documentation, general testing guidelines, and external resources (like GPT) to ensure I followed best practices. While I’ve made my best effort, I’m open to any feedback or suggestions for improvement. Please let me know if there are specific areas I should revisit or refine—I’d be happy to make the necessary adjustments. Thank you for your guidance and support! |
Hi @peterdudfield, I've resolved the issue now, and the CI pipeline should function as expected. Let me know if you'd like me to squash these commits to clean up the history. |
Hey this looks really great. Thanks so much for doing this. Some quick points Could you add some requirements to the pyproject to get the ci working In the format stage, I think we should just make 1 forecasts object, which had many Forecast Values. Sorry if it does that already |
Hey @peterdudfield, thanks for the feedback and suggestions! I’m currently out of town for a few days and don’t have access to everything I need to make the updates. I’ll address this and update the PR in the next few days. Thanks for your patience! |
I’ve been working on ensuring that the formatting stage creates a single Currently, I’m encountering an issue where multiple Steps Taken So Far: I ensured I checked that the Despite these changes, when I add the Would you have any advice or suggestions for: Avoiding duplicate Any help would be greatly appreciated! |
Thats not a problem, just make one. The |
I've updated both the However, the test code was initially written to test locally with a hardcoded database configuration (e.g., localhost). It’s not well-suited for CI as it currently relies on a local PostgreSQL setup. I’ve been unable to figure out how to rewrite it for CI yet. Would it be okay to push the current changes as they are, and we can address the test improvements (to make them CI-ready) in a separate PR? Let me know what you think! |
Thanks so much for this, ive added a comment or two, that should actually get it working in CI. I reckon lets try and see if we can do it in this PR |
tests/conftest.py
Outdated
Generator: A SQLAlchemy session object. | ||
""" | ||
# Create database engine and tables | ||
engine = create_engine(TEST_DB_URL) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you should still do with PostgresContainer("postgres:15.5") as postgres:
see other examples here https://github.com/openclimatefix/pv-site-datamodel/blob/main/tests/conftest.py#L26
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @peterdudfield,I’m still looking into this and will make the necessary changes. I’m sorry if it’s taking too long—would it be okay to give me a few more days to finalize it? I’ll update you as soon as it’s done.
Welcome to Codecov 🎉Once you merge this PR into your default branch, you're all set! Codecov will compare coverage reports and display results in all future pull requests. Thanks for integrating Codecov - We've got you covered ☂️ |
Thanks for doing those changes, just one more test to fix. If I get time, ill try to look why its failing. |
No worries! I think I might have an idea why the tests are failing. It could be an issue both with the test I wrote and the code logic itself. I have my university exams in the next few days, so if it's okay with you, I'd like to revisit it afterward and make the necessary corrections. Once again, thank you for your patience—I’ve learned a lot through this PR process! |
no problem, good luck and take your time |
Pull Request
Description
This pull request addresses the functionality required for:
It tackles the following issues:
Key changes include:
Added
format_to_forecast_sql
to transform fetched forecast data intoForecastSQL
objects.Implemented
save_forecasts_to_db
to persist these formatted forecasts in the database.Applied code formatting (Black) and addressed all linting issues (Ruff).
How Has This Been Tested?
Tests were added for both:
format_to_forecast_sql
).save_forecasts_to_db
).The tests verify:
To reproduce:
pytest tests/test_format_forecast.py
to validate the formatting logic.pytest tests/test_save_forecasts.py
to validate the saving logic.Checklist: