-
-
Notifications
You must be signed in to change notification settings - Fork 55
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* new workflow * rename workflow * install * disable * no cd * publish from workflow * add env vars * requirements * loosen requirements * datasets only * datasets * lower datasets version * remove * wip * update * bump python version * pv-site-prediction * seems to be working * update * use filesystem interface * use UTC * set up cron schedule * don't need new requirements any more * tidy up * add lat/long to file name * loop through models * add capacity * add test for file path * new line at end of file * use named arg * change to HF_TOKEN_PUSH * wrong workflow * move to utils module * fix test * fix test * __init__.py * empty * update lat/long and capacity Co-authored-by: Matthew Duffin <[email protected]>
- Loading branch information
1 parent
a401577
commit 50c6c6c
Showing
5 changed files
with
116 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
name: Run forecast | ||
|
||
on: | ||
schedule: | ||
- cron: "0 9 * * *" | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: checkout repo content | ||
uses: actions/checkout@v2 | ||
|
||
- name: setup python | ||
uses: actions/setup-python@v4 | ||
with: | ||
python-version: '3.11' | ||
|
||
- name: install python packages | ||
run: | | ||
python -m pip install --upgrade pip | ||
pip install -r requirements.txt | ||
pip install -e . | ||
- name: upload forecast to Hugging Face | ||
env: | ||
HF_TOKEN: ${{ secrets.HF_TOKEN_PUSH }} | ||
HF_REPO: ${{ secrets.HF_REPO }} | ||
run: | | ||
cd scripts | ||
python hf_upload.py | ||
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import os | ||
from datetime import datetime | ||
from huggingface_hub import login, HfFileSystem | ||
from quartz_solar_forecast.utils.forecast_csv import forecast_for_site | ||
|
||
|
||
def get_file_path(latitude: float, | ||
longitude: float, | ||
capacity_kwp: float, | ||
model: str = "gb", | ||
time: datetime = None) -> str: | ||
return time.strftime(f"data/%Y/%-m/%-d/{model}_{latitude}_{longitude}_{capacity_kwp}_%Y%m%d_%H.csv") | ||
|
||
|
||
if __name__ == "__main__": | ||
|
||
hf_token = os.getenv("HF_TOKEN") | ||
hf_repo = os.getenv("HF_REPO") | ||
|
||
login(hf_token) | ||
fs = HfFileSystem() | ||
now = datetime.utcnow() | ||
latitude = 51.59, | ||
longitude = -1.89 | ||
capacity_kwp = 4 | ||
|
||
for model in ["gb", "xgb"]: | ||
forecast = forecast_for_site(latitude, longitude, capacity_kwp, model, now) | ||
|
||
path = get_file_path(latitude, longitude, capacity_kwp, model, now) | ||
with fs.open(f"datasets/{hf_repo}/{path}", "w") as f: | ||
forecast.to_csv(path_or_buf=f) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
from quartz_solar_forecast.utils.hf_upload import get_file_path | ||
from datetime import datetime | ||
|
||
|
||
def test_get_file_path(): | ||
latitude = 51.75 | ||
longitude = -1.25 | ||
capacity_kwp = 1.25 | ||
date = datetime(2024, 7, 26, 12, 0, 0) | ||
path = get_file_path(latitude, longitude, capacity_kwp, "gb", date) | ||
|
||
assert path == "data/2024/7/26/gb_51.75_-1.25_1.25_20240726_12.csv" |