-
-
Notifications
You must be signed in to change notification settings - Fork 12
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
Fake data #354
Comments
Hello there @peterdudfield. This definitely looks to be a more complex and interesting change. If possible I'd like to attempt a contribution to this change? If so, could I just clarify the following points, please (apologies if these questions are a bit dumb/obvious!):
What is meant by the route (again, sorry if these are obvious/dumb questions to ask)?
|
Thanks @VikramsDataScience for getting involved.
if os.enviorn['FAKE'].lower() = 'true':
return make_fake_data(....)
Hope this helps, and please do ask more questions |
This repo and code is how I was thinking it could be done |
Apologies @peterdudfield! I've been a little time poor, and distracted lately. I erroneously created a PR (openclimatefix/india-api#76) in the india-api repo to address this issue, but I think I made the changes to the incorrect repo! I've since closed it, because I think we're looking to make similar changes but to this repo? If so, which module should I be looking to modify in this repo? |
No problem. See point 4 above, but we should try to fake all the 'routes' of the api |
Hey @peterdudfield. I've made the changes to what I think are the correct modules, but I'm running python 3.11.5 on my local machine and venv, but it looks like the I've also tried to install 3.9 separately to avoid downgrading my system version. And, from there creating a venv that's built from 3.9, but I'm having a variety of challenges! |
yea, i would stick to python 3.11. Does it stop you submitting code? |
Yeah, exactly! It prevents the commit from going through. Are you okay with me modifying the |
yea, feel free too |
Cool. Thank you. Now that I've got the changes made to the Otherwise, if all is good, I'll create a PR, and we can work together to get it right :). |
yea, of course, |
Sorry @peterdudfield about all the commits! That was me having fun and playing around with the |
Hey @peterdudfield. I've created the PR. It was initially failing the CI checks, but I've modified the I also quite foolishly left the modified relative imports that I used for testing in my push, not realising that the dockerfile already sets the PYTHONPATH. The CI tests seem to be passing now. When you've got some time, could you review the changes in the PR, and let me know if I'm on the right track, please? |
* Fake data Issue #354 * Fake data Issue #354 * Fake data Issue #354 * Changed relative imports and removed pre-commit from requirements.txt * Using more flexible python3 version to attempt to fix pre-commit.ci build issue * Written new Unit Test for fake forecast with specified GSP ID * Written unit tests for all endpoints/routes and modified gsp.py to support new tests * Removed duplicated Test Cases * 1st test case for fake environment * Fixed accidental activation of fake environment in gsp.py module * Written and tested remaining test cases for is_fake * Moved isintance check to prior to is_fake condition * Added 2 Tests to test_national.py and cleaned up some logic in test_gsp test cases * Modified gsp.py and national.py modules and accompanying test cases to address feedback * Fixed incorrect for loop iteration through list (should be singular ForecastSQL object) to forecasts object in the test_national.py test cases * Modified test cases to use NationalForecastValue, ForecastValue, and the ManyForecasts as the return objects * Modified test cases to uss pytest.fixture() to yield values from db_session * Possible fix for test_read_latest_all_gsp_normalized() and test_read_latest_all_gsp() * 1st experiment for test_read_truth_national_gsp() and test_read_forecast_values_gsp() * 1st experiment with make_fake_gsp_yields() * 2nd experiment with make_fake_gsp_yields() - modified test_gsp routes * 3rd experiment with make_fake_gsp_yields() - modified List Comprehension * 4th experiment with make_fake_gsp_yields() - hard coded _gsp_id_ * Removed yield and fixture * Experiment: Create a separate tests/fake/test_gsp_fake.py test case module
* Fake data Issue #354 (#360) * Fake data Issue #354 * Fake data Issue #354 * Fake data Issue #354 * Changed relative imports and removed pre-commit from requirements.txt * Using more flexible python3 version to attempt to fix pre-commit.ci build issue * Written new Unit Test for fake forecast with specified GSP ID * Written unit tests for all endpoints/routes and modified gsp.py to support new tests * Removed duplicated Test Cases * 1st test case for fake environment * Fixed accidental activation of fake environment in gsp.py module * Written and tested remaining test cases for is_fake * Moved isintance check to prior to is_fake condition * Added 2 Tests to test_national.py and cleaned up some logic in test_gsp test cases * Modified gsp.py and national.py modules and accompanying test cases to address feedback * Fixed incorrect for loop iteration through list (should be singular ForecastSQL object) to forecasts object in the test_national.py test cases * Modified test cases to use NationalForecastValue, ForecastValue, and the ManyForecasts as the return objects * Modified test cases to uss pytest.fixture() to yield values from db_session * Possible fix for test_read_latest_all_gsp_normalized() and test_read_latest_all_gsp() * 1st experiment for test_read_truth_national_gsp() and test_read_forecast_values_gsp() * 1st experiment with make_fake_gsp_yields() * 2nd experiment with make_fake_gsp_yields() - modified test_gsp routes * 3rd experiment with make_fake_gsp_yields() - modified List Comprehension * 4th experiment with make_fake_gsp_yields() - hard coded _gsp_id_ * Removed yield and fixture * Experiment: Create a separate tests/fake/test_gsp_fake.py test case module * split national tests * role back changes in tests * fix national test * rename * is_fake to is_fake() * add to readme, don't use any caching in tests * role back, * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * tests run locally --------- Co-authored-by: Vikram Pande <[email protected]> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Detailed Description
It would be great to run the api with fake data. This means users could run this locally without having to connect to a database.
The FE users could then use this API with fake data.
Context
Possible Implementation
The text was updated successfully, but these errors were encountered: