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
Upload Tryolabs model #118
base: main
Are you sure you want to change the base?
Conversation
Let me know @diegomarvid if this is ready for a review yet |
import requests | ||
|
||
|
||
class WeatherService: |
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.
This version of the WeatherService
doesn't have the local cache that we developed for training. I think it coud be a useful feature for users to have
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.
@Ludecan For now we decided not to include this, because this code is only meant for inference and we don't expect to have a lot of sequentially requests.
download_models.sh
Outdated
@@ -0,0 +1,7 @@ | |||
#!/bin/bash |
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.
could you move this to forecasts? Or perhaps into scripts? This keeps the top level nice and clear.
Could you also add what model this downloads? and when do you need to use this script?
quartz_solar_forecast/forecast.py
Outdated
def predict_ocf( | ||
site: PVSite, model=None, ts: datetime | str = None, nwp_source: str = "icon" | ||
): | ||
"""Run the forecast with the OCF model""" |
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.
could you re add the :param of what they are please
site: PVSite, ts: datetime | str = None): | ||
"""Run the forecast with the tryolabs model""" | ||
|
||
solar_power_predictor = TryolabsSolarPowerPredictor() |
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.
could you add a few # comments, just saying what the code is doing, for example setting up model
file_id: | ||
Google id of the model file | ||
""" | ||
gdown.download(f'https://drive.google.com/uc?id={file_id}', filename, quiet=False) |
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.
where does the model get saved?
start_date: str, | ||
kwp: float, | ||
orientation: float, | ||
tilt: float, |
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.
is it worth adding some default values fomr orientation and tilt?
final_data.loc[final_data["is_day"]==0, "prediction"] = 0 | ||
df = final_data[[self.DATE_COLUMN, "prediction"]] | ||
df = df.rename(columns={"prediction": "power_wh"}) | ||
return df |
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.
what happens if data is None?
f"Invalid date format or range. Please use YYYY-MM-DD and ensure end_date is greater than start_date. Error: {str(e)}" | ||
) | ||
|
||
def get_minutely_weather( |
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.
should it be refactored to get_15_minutely_weather
? I saw def get_minutely_weather
and thought you were getting weather data by the minute
tests/test_forecast_no_ts.py
Outdated
# check current ts agrees with dataset | ||
assert predications_df.index.min() == current_ts | ||
|
||
print(predications_df) | ||
print(f"Current time: {current_ts}") | ||
print(f"Max: {predications_df['power_wh'].max()}") | ||
|
||
current_ts = pd.Timestamp.now().floor("15min") |
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.
do you need to repeat this, of can you use the one above?
I know sometimes it'll fail as the test might run over the 15 minute block, if this becomes a problem, then we should use freeze_gun
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.
Ive just looked at the code and it looks really good. Ill try running it a bit later.
Ive written lots of small comments, so sorry if its looks a lot of work.
I wonder if you could do a plot of a days forecast using
- ocf icon
- ocf gfs
- tryolabs
The results should be fairly similar and it will help build up trsut of the differnt models.
Perhaps this could be added to the readme?
Im just looking at your comment in the PR @diegomarvid. We could create a HuggingFace repo, and put the models in there. What do you think? |
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.
After your changes are made @peterdudfield It looks good to me. So I'll approve for now.
images/model_data_comparison.png
Outdated
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.
thanks for adding this
Tryolabs model implementation
.python-version
file to specify python version 3.10.0. It doesn't work if python version is older than 3.10. We need to specify this in thereadme
.requirements.txt
with new dependencies.gdown
will not be necessary at production, but it's handy to download the model while we don't have a model hub.open_meteo/open_meteo.py
file. It didn't have anything that was used inside the main code.weather/open_meteo.py
file for our logic to get Weather Data from Open Meteo.forecasts/v2.py
function that uses tryolabs model.forecast.py
function to use both models based on a provided model file. By default it uses the model OCF saved inside the library.We need a centralized location where users can download models we will use in the library. This is a good practice. Saving the models inside the library makes it bigger, harder to maintain, and harder to change the models after the library is released.