Skip to content

feat(people-and-planet-ai): Modernize the weather-forecasting sample - #14764

Merged
iennae merged 2 commits into
mainfrom
feat/modernize-ppai-weather-forecasting
Nov 30, 2026
Merged

iennae merged 2 commits into
mainfrom
feat/modernize-ppai-weather-forecasting

Conversation

@iennae

@iennae iennae commented Nov 5, 2026 •

Copy link
Copy Markdown
Contributor

Description

Replaces the people-and-planet-ai/weather-forecasting sample with an end-to-end storm nowcasting tutorial built on current Google Cloud services. The previous sample trained and served a custom PyTorch model, which needed a separate serving container and a multi-notebook flow.

The new sample shows how to combine:

  • multi-resolution satellite and terrain data from Earth Engine (NASA GPM IMERG V07, NOAA GOES, MERIT DEM);
  • an Apache Beam pipeline that loads hourly storm observations into BigQuery;
  • zero-shot precipitation forecasting with BigQuery ML AI.FORECAST (TimesFM 2.5);
  • WeatherNext 3 ensemble forecasts from Earth Engine;
  • multimodal flood-risk analysis with Gemini through the Google Gen AI SDK.

README.ipynb covers a historical hurricane hindcast (Hurricane Melissa, Steps 1–5) and a live Bay Area microclimate forecast (Step 6). Each step is a standalone script with its own region tag, so the documentation can include them individually.

Notable decisions

  • Shared notebook setup. The setup cell uses the reusable scripts/notebook-setup helper (chore(scripts): add reusable notebook_setup sparse-checkout helper #14768) instead of its own clone and install logic. The notebook runs the same way in Colab, in Colab Enterprise, and in a local checkout of the repository.
  • Python 3.12. noxfile_config.py tests on Python 3.12, the repository's minimum supported version.
  • Legacy files removed. serving/, notebooks/, tests/, images/ and create_dataset.py from the old sample are deleted. The Weather forecasting entry in people-and-planet-ai/README.md now points to the new notebook and describes the new sample.

Dependency notes

pillow is pinned to 12.3.0 because apache-beam 2.77.0 requires pillow<13. The fixed 13.x line will be adopted once apache-beam 2.78.0 is released. earthengine-api, google-genai and numpy are also held below their latest releases for compatibility with apache-beam[gcp] 2.77.0. Each pin is annotated in requirements.txt.

Trying the notebook before merge

The launch badges point at main, so they won't work until this PR merges. To try it now, open the notebook from this PR's head commit:

Then, in the setup cell, set BRANCH = "feat/modernize-ppai-weather-forecasting" before running it.

Checklist

Testing

  • I have tested this change on a live environment and verified it works as intended.

Compliance & Style


Post-Approval Actions

  • Please merge this PR for me once it is approved

@iennae
iennae requested review from a team as code owners November 5, 2026 15:26
@product-auto-label product-auto-label Bot added samples Issues that are directly related to samples. api: people-and-planet-ai labels Nov 5, 2026
@snippet-bot

snippet-bot Bot commented Nov 5, 2026 •

Copy link
Copy Markdown

Here is the summary of changes.

You are about to add 4 region tags.

This comment is generated by snippet-bot.
If you find problems with this result, please file an issue at:
https://github.com/googleapis/repo-automation-bots/issues.
To update this comment, add snippet-bot:force-run label or use the checkbox below:

  • Refresh this comment

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Code Review

This pull request modernizes the weather forecasting sample by replacing the custom PyTorch FCN model with a pipeline that integrates Google Earth Engine, BigQuery ML (TimesFM 2.5), Google DeepMind's WeatherNext 3, and Gemini 3.8 Flash for multimodal storm risk nowcasting. The changes include new scripts for data ingestion, time-series loading via Apache Beam, zero-shot forecasting, multimodal analysis, and visualization, alongside updated documentation and comprehensive tests. Feedback on the changes highlights a critical issue in fetch_weather_patch.py where raw netCDF scale factors and offsets are incorrectly applied to already-calibrated GOES thermal IR bands, which would corrupt downstream calculations and visualizations.

@iennae iennae changed the title Feat/modernize ppai weather forecasting feat(ppai): modernize ppai weather forecasting Nov 5, 2026
@iennae
iennae force-pushed the feat/modernize-ppai-weather-forecasting branch 6 times, most recently from e6954b8 to a273ad8 Compare November 10, 2026 21:40
@iennae
iennae force-pushed the feat/modernize-ppai-weather-forecasting branch 3 times, most recently from e6864d4 to a1cc3b5 Compare November 13, 2026 21:15
… Earth Engine, Apache Beam, BigQuery ML AI.FORECAST, and Gemini 3.8 Flash

Problem:
The legacy people-and-planet-ai/weather-forecasting sample spanned 45 files across four separate notebooks, four duplicate test harnesses, and a custom PyTorch/HuggingFace Cloud Run serving container with checked-in model weights (serving/model/pytorch_model.bin). It relied on the deprecated NASA/GPM_L3/IMERG_V06 Earth Engine collection, hardcoded NOAA/GOES/16/MCMIPF (which ceased operation in April 2025 in favor of GOES-19), used legacy Vertex AI custom training and gcloud AI Platform commands, and included an outdated user feedback form.

Solution:
- Consolidate the multi-notebook workflow into a single end-to-end tutorial notebook (README.ipynb) orchestrating standalone, single-task Python modules aligned with JoTa task_rules.yaml and DevSite Dataflow Python ML references.
- Add fetch_weather_patch.py to query calibrated half-hourly precipitation from NASA GPM IMERG V07 (NASA/GPM_L3/IMERG_V07), cloud-top brightness and moisture bands from NOAA GOES-19 (NOAA/GOES/19/MCMIPF) and GOES-16 (NOAA/GOES/16/MCMIPF), and terrain elevation from MERIT DEM (MERIT/DEM/v1_0_3), featuring Hurricane Melissa (Oct 2025, Jamaica) and Hurricane Helene (Sept 2024, Southern Appalachians) case studies.
- Add load_weather_time_series.py (dataflow_weather_load_time_series) to transform and load hourly satellite observations into BigQuery using Apache Beam.
- Add forecast_precipitation.py (bigquery_weather_forecast_precipitation) for zero-shot multi-hour precipitation nowcasting using BigQuery ML AI.FORECAST with TimesFM 2.5.
- Add analyze_storm_risk.py (googlegenaisdk_weather_analyze_storm_risk) for structured multimodal flood-risk synthesis combining multi-sensor satellite composites and forecasted precipitation curves using the Google Gen AI SDK (gemini-3.8-flash on global).
- Document scaling to global medium-range ensemble forecasts using Google DeepMind WeatherNext 3 in Earth Engine and BigQuery.
- Remove legacy notebooks, serving scaffolding, binary weights, static PNGs, and outdated feedback forms, and add fast offline unit tests in test_weather_forecasting.py.
@iennae
iennae force-pushed the feat/modernize-ppai-weather-forecasting branch from a1cc3b5 to 7d17195 Compare November 13, 2026 23:53
@iennae iennae changed the title feat(ppai): modernize ppai weather forecasting feat(people-and-planet-ai): Modernize the weather-forecasting sample Nov 14, 2026

@XrossFox XrossFox left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Generally speaking, i think it looks good, but i left a few comments hoping they are helpful. I've also tested that the notebooks are running on collab, and collab enterprise.

@XrossFox XrossFox self-assigned this Nov 24, 2026
…er-forecasting

Problem:
Review of PR #14764 identified several polish and correctness issues in people-and-planet-ai/weather-forecasting:
- Several unittest.mock.patch.object calls in test_weather_forecasting.py lacked autospec=True, masking that fetch_weather_patch.py passed the legacy opt_url keyword argument to ee.Initialize instead of url.
- visualize.py replaced its original 2023 copyright year with 2026 and included an unnecessary shebang for a non-CLI library module.
- Error messages in load_weather_time_series.py (and forecast_precipitation.py) omitted dataset_id alongside table_id.
- README.ipynb configured PROJECT_ID via gcloud before authenticating in Google Colab, and the cleanup cell only removed gs://{BUCKET_NAME}/temp without cleaning up a newly created staging bucket.

Solution:
- Add autospec=True to all patch.object calls in test_weather_forecasting.py, add test_load_weather_time_series_error, and update ee.Initialize calls in fetch_weather_patch.py from opt_url= to url=.
- Restore '# Copyright 2023 Google LLC' and remove the unused shebang in visualize.py.
- Include dataset_id ('{dataset_id}.{table_id}') in stderr diagnostics for both load_weather_time_series.py and forecast_precipitation.py while continuing to omit project_id.
- Reorder README.ipynb so Colab authentication runs before project configuration, track CREATED_BUCKET when creating the staging bucket, and remove the full bucket on cleanup only when created during the notebook run.
@iennae
iennae merged commit b3ffe5b into main Nov 30, 2026
14 of 19 checks passed
@iennae
iennae deleted the feat/modernize-ppai-weather-forecasting branch November 30, 2026 23:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

api: people-and-planet-ai samples Issues that are directly related to samples.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants