Skip to content
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

Open
wants to merge 40 commits into
base: main
Choose a base branch
from
Open

Upload Tryolabs model #118

wants to merge 40 commits into from

Conversation

diegomarvid
Copy link
Collaborator

@diegomarvid diegomarvid commented Apr 25, 2024

Tryolabs model implementation

  • Added a .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 the readme.
  • Updated 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.
  • Deleted open_meteo/open_meteo.py file. It didn't have anything that was used inside the main code.
  • Created weather/open_meteo.py file for our logic to get Weather Data from Open Meteo.
  • Created a forecasts/v2.py function that uses tryolabs model.
  • Updated 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.

@diegomarvid diegomarvid added the enhancement New feature or request label Apr 25, 2024
@diegomarvid diegomarvid self-assigned this Apr 25, 2024
@peterdudfield peterdudfield removed the enhancement New feature or request label May 3, 2024
@peterdudfield
Copy link
Contributor

Let me know @diegomarvid if this is ready for a review yet

quartz_solar_forecast/forecast.py Outdated Show resolved Hide resolved
README.md Outdated Show resolved Hide resolved
import requests


class WeatherService:
Copy link

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

Copy link
Collaborator

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.

@@ -0,0 +1,7 @@
#!/bin/bash
Copy link
Contributor

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?

def predict_ocf(
site: PVSite, model=None, ts: datetime | str = None, nwp_source: str = "icon"
):
"""Run the forecast with the OCF model"""
Copy link
Contributor

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()
Copy link
Contributor

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)
Copy link
Contributor

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,
Copy link
Contributor

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
Copy link
Contributor

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(
Copy link
Contributor

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

# 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")
Copy link
Contributor

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

Copy link
Contributor

@peterdudfield peterdudfield left a 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?

@peterdudfield
Copy link
Contributor

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?

Copy link
Contributor

@zakwatts zakwatts left a 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.

Copy link
Contributor

Choose a reason for hiding this comment

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

thanks for adding this

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.

None yet

5 participants