Unable to load weather forecasts from Open weather when replicating the lab on GCP

I get a file not found error when trying to load weather forecasts from the open weather API. Is there a restriction on using it on GCP? I can use some guidance.

My file does exist in the URI shown below as part of the error.

My error below:


FileNotFoundError Traceback (most recent call last)
in <cell line: 2>()
1 # Load the data
----> 2 weather_forecasts = load_weather_forecast()
3
4 # Plot measured wind speed and forecasts for different periods into the future
5 plot_forecast(weather_forecasts)

in load_weather_forecast()
871 “”“Loads the wind data and forecast for three locations and returns it in a form of dictionary.
872 “””
→ 873 with open(“gs://acai_testdata/Climate Change/Wind Power Forecasting/Design/forecasting/work/data/weather_forecast.pkl”, “rb”) as f:
874 weather_forecasts = pickle.load(f)
875 return weather_forecasts

FileNotFoundError: [Errno 2] No such file or directory: ‘gs://acai_testdata/Climate Change/Wind Power Forecasting/Design/forecasting/work/data/weather_forecast.pkl’

1 Like

Hi @vkbalasub,

Could you mention the name of the notebook so that I’m able to understand better and, if possible, help you ?

Best,
Mubsi

1 Like

The notebook is C2_W2_Lab3_Wind_Energy_Design_2.ipynb ( Wind Power Forecasting: Design Phase (Part 2)). The error is generated in the utils.py provided for the lab that calls the function (Load weather forecasts).

1 Like

Hi @vkbalasub,

Thanks for sharing the information.

This is the function, right ?

def load_weather_forecast() -> Dict[str, Dict[List[datetime], List[float]]]:
    """Loads the wind data and forecast for three locations and returns it in a form of dictionary.
    """
    with open("data/weather_forecast.pkl", "rb") as f:
        weather_forecasts = pickle.load(f)
    return weather_forecasts

It is loading the data from the “data” folder. Are you sure you have downloaded this folder as well, in order for the notebook to run locally ?
Screenshot 2023-09-07 at 9.04.23 PM

Best,
Mubsi

1 Like

Hi @vkbalasub,

Please look at my reply above.

1 Like

In order to get faster replies from me, I’d recommend to tag me every time your replies are directed towards me.

1 Like

Hi @vkbalasub, there is no restriction on running this lab or loading any of its parts in GCP. Looks like the utils is not able to locate the pkl file that contains the data, make sure that all the files are in the correct paths. I would recommend not using spaces in your directories (such as Climate Change, Wind Power) as this can sometimes cause issues. Also maybe its better to use the relative path to the weather_forecast.pkl instead of the full URI (I don’t know how these work in GCP)

1 Like

It is pointed to the right directory and file is present there - (“gs://acai_testdata/Climate Change/Wind Power Forecasting/Design/forecasting/work/data/weather_forecast.pkl”, “rb”).

The other files are accessible with the URI as provided except the pickle file. I have tried removing the spaces as suggested in the directory names but didn’t help either. It seems to be very specific to reading the pickle file.

code is as below:

def load_weather_forecast() → Dict[str, Dict[List[datetime], List[float]]]:
“”“Loads the wind data and forecast for three locations and returns it in a form of dictionary.
“””
with open(“gs://acai_testdata/Climate Change/Wind Power Forecasting/Design/forecasting/work/data/weather_forecast.pkl”, “rb”) as f:
weather_forecasts = pickle.load(f)
return weather_forecasts

1 Like

Hi @vkbalasub,

With everything you said above and your original error, maybe check using !ls command what you see when you put the same file path, do you see the pkl file or not

1 Like