Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
19 changes: 13 additions & 6 deletions .github/workflows/docs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,25 +13,32 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set environment variables
run: |
echo "CURRENT_WEEK=$(date +'%Y-%U')" >> $GITHUB_ENV
- uses: actions/setup-python@v4
with:
python-version: "3.10"
python-version: "3.11"
- uses: actions/cache@v4
with:
path: ${{ env.pythonLocation }}
key: ${{ env.pythonLocation }}-${{ hashFiles('fme/requirements.txt') }}-${{ hashFiles('fme/docs/requirements.txt') }}-${{ hashFiles('fme/constraints.txt') }}
key: v1-${{ env.CURRENT_WEEK }}-${{ env.pythonLocation }}-${{ hashFiles('requirements.txt') }}-${{ hashFiles('docs/requirements.txt') }}-${{ hashFiles('requirements-healpix.txt') }}-${{ hashFiles('constraints.txt') }}
- name: Install dependencies
run: |
python -m pip install uv==0.2.5
uv pip install --system -c constraints.txt -e fme[docs]
python -m pip install uv
# can't use --system here because it doesn't work with --no-build-isolation and a healpix dependency
uv venv --python 3.11
uv pip install -c constraints.txt -e .[docs]
uv pip install --no-build-isolation -c constraints.txt -e .[docs,healpix]
- name: Build docs
run: |
cd fme/docs && make doctest html
source .venv/bin/activate
cd docs && make doctest html
- name: Deploy to GitHub Pages
uses: peaceiris/actions-gh-pages@v3
if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' }}
with:
publish_branch: gh-pages
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: fme/docs/_build/
publish_dir: docs/_build/
force_orphan: true
2 changes: 1 addition & 1 deletion .github/workflows/pre-commit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: "3.10"
python-version: "3.11"

- name: Install dependencies
run: |
Expand Down
22 changes: 13 additions & 9 deletions .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,19 +18,23 @@ jobs:
echo "CURRENT_WEEK=$(date +'%Y-%U')" >> $GITHUB_ENV
- uses: actions/setup-python@v4
with:
python-version: "3.10"
python-version: "3.11"
- uses: actions/cache@v4
with:
path: ${{ env.pythonLocation }}
key: ${{ env.CURRENT_WEEK }}-${{ env.pythonLocation }}-${{ hashFiles('fme/requirements.txt') }}-${{ hashFiles('fme/dev-requirements.txt') }}-${{ hashFiles('constraints.txt') }}
key: v1-${{ env.CURRENT_WEEK }}-${{ env.pythonLocation }}-${{ hashFiles('requirements.txt') }}-${{ hashFiles('requirements-dev.txt') }}-${{ hashFiles('requirements-healpix.txt') }}-${{ hashFiles('constraints.txt') }}
- name: Install dependencies
run: |
python -m pip install uv
uv pip install --system -c constraints.txt -e ./fme[dev]
- name: Run pytest
# can't use --system here because it doesn't work with --no-build-isolation and a healpix dependency
uv venv --python 3.11
uv pip install -c constraints.txt -e .[dev]
uv pip install --no-build-isolation -c constraints.txt -e .[dev,healpix]
- name: Run pytest with code coverage
run: |
make test
cpu-very-fast:
source .venv/bin/activate
make test_cov
cpu-very-fast-no-healpix:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
Expand All @@ -39,15 +43,15 @@ jobs:
echo "CURRENT_WEEK=$(date +'%Y-%U')" >> $GITHUB_ENV
- uses: actions/setup-python@v4
with:
python-version: "3.10"
python-version: "3.11"
- uses: actions/cache@v4
with:
path: ${{ env.pythonLocation }}
key: ${{ env.CURRENT_WEEK }}-${{ env.pythonLocation }}-${{ hashFiles('fme/requirements.txt') }}-${{ hashFiles('fme/dev-requirements.txt') }}-${{ hashFiles('constraints.txt') }}
key: v1-${{ env.CURRENT_WEEK }}-${{ env.pythonLocation }}-${{ hashFiles('requirements.txt') }}-${{ hashFiles('requirements-dev.txt') }}-${{ hashFiles('constraints.txt') }}
- name: Install dependencies
run: |
python -m pip install uv
uv pip install --system -c constraints.txt -e ./fme[dev]
uv pip install --system -c constraints.txt -e .[dev]
- name: Run pytest
run: |
make test_very_fast
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
fme/docs/available_modules.rst
fme/docs/_build
docs/available_modules.rst
docs/_build

.vscode

Expand Down
15 changes: 11 additions & 4 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,29 @@ repos:
rev: v0.8.1
hooks:
- id: ruff
args: ["--fix", "--config", "fme/pyproject.toml"]
args: ["--fix", "--config", "pyproject.toml"]
- id: ruff-format
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v5.0.0
hooks:
- id: check-added-large-files
args: [--maxkb=250]
- id: trailing-whitespace
- id: file-contents-sorter
files: |
(?x)^(
^.*requirements.*\.txt|
constraints.txt|
analysis-deps.txt
)$
- repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.2.0
rev: v1.15.0
hooks:
- id: mypy
additional_dependencies: ["types-PyYaml==5.4.3"]
additional_dependencies: ["types-PyYaml==5.4.3", "wandb==0.19.0"]
args: ["--ignore-missing-imports", "--check-untyped-defs"]
exclude: |
(?x)^(
.+/conf.py |
.+/conftest.py
.+/conftest.py |
)$
6 changes: 3 additions & 3 deletions .readthedocs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ build:

# Build documentation in the "docs/" directory with Sphinx
sphinx:
configuration: fme/docs/conf.py
configuration: docs/conf.py

# Optionally build your docs in additional formats such as PDF and ePub
# formats:
Expand All @@ -29,5 +29,5 @@ sphinx:
# See https://docs.readthedocs.io/en/stable/guides/reproducible-builds.html
python:
install:
- requirements: fme/docs/requirements.txt
- requirements: fme/requirements.txt
- requirements: docs/requirements.txt
- requirements: requirements.txt
24 changes: 18 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,34 @@ IMAGE ?= fme
ENVIRONMENT_NAME ?= fme
DEPLOY_TARGET ?= pypi

ifeq ($(shell uname), Linux)
CONDA_PACKAGES=gxx_linux-64 pip
else
CONDA_PACKAGES=pip
endif

build_docker_image:
docker build --platform=linux/amd64 -f docker/Dockerfile -t $(IMAGE):$(VERSION) .
DOCKER_BUILDKIT=1 docker build --platform=linux/amd64 -f docker/Dockerfile -t $(IMAGE):$(VERSION) --target production .

enter_docker_image: build_docker_image
docker run -it --rm $(IMAGE):$(VERSION) bash


# recommended to deactivate current conda environment before running this
create_environment:
conda create -n $(ENVIRONMENT_NAME) python=3.10 pip
conda create -n $(ENVIRONMENT_NAME) python=3.11 $(CONDA_PACKAGES)
conda run --no-capture-output -n $(ENVIRONMENT_NAME) python -m pip install uv
conda run --no-capture-output -n $(ENVIRONMENT_NAME) uv pip install -c constraints.txt -e ./fme[dev,docs]
conda run --no-capture-output -n $(ENVIRONMENT_NAME) uv pip install -c constraints.txt -e .[dev,docs]
conda run --no-capture-output -n $(ENVIRONMENT_NAME) uv pip install --no-build-isolation -c constraints.txt -e .[dev,docs,healpix]
conda run --no-capture-output -n $(ENVIRONMENT_NAME) uv pip install -r analysis-deps.txt

test:
pytest --durations 40 .

# --cov must come after pytest args to use the sources defined by config
test_cov:
pytest --durations 40 --cov --cov-report=term-missing:skip-covered --cov-config=pyproject.toml .

test_fast:
pytest --durations 40 --fast .

Expand All @@ -29,11 +41,11 @@ test_very_fast:
# requires fme[deploy] to be installed

build_pypi:
rm -rf fme/dist
cd fme && python -m build
rm -rf dist
python -m build

deploy_pypi: build_pypi
cd fme && twine upload --repository $(DEPLOY_TARGET) dist/*
twine upload --repository $(DEPLOY_TARGET) dist/*

deploy_test_pypi: DEPLOY_TARGET = testpypi
deploy_test_pypi: deploy_pypi
6 changes: 1 addition & 5 deletions fme/README.md → PACKAGE_README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,7 @@
[![PyPI](https://img.shields.io/pypi/v/fme.svg)](https://pypi.org/project/fme/)

# FME: Weather/Climate Model Emulation
This package contains code to train and evaluate weather/climate model emulators as seen in
"ACE: A fast, skillful learned global atmospheric model for climate prediction" ([arxiv:2310.02074](https://arxiv.org/abs/2310.02074))
and "Application of the Ai2 Climate Emulator to E3SMv2's global atmosphere model, with a focus on precipitation fidelity"
([JGR-ML](https://agupubs.onlinelibrary.wiley.com/doi/full/10.1029/2024JH000136)).

This package contains code to train and evaluate weather/climate model emulators.

## Installation

Expand Down
28 changes: 4 additions & 24 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,12 @@

Ai2 Climate Emulator (ACE) is a fast machine learning model that simulates global atmospheric variability in a changing climate over time scales ranging from hours to centuries.

This repo contains code accompanying four papers describing ACE models:
This repo contains code accompanying five papers describing ACE models:
- "ACE: A fast, skillful learned global atmospheric model for climate prediction" ([link](https://arxiv.org/abs/2310.02074))
- "Application of the Ai2 Climate Emulator to E3SMv2's global atmosphere model, with a focus on precipitation fidelity" ([link](https://agupubs.onlinelibrary.wiley.com/doi/full/10.1029/2024JH000136))
- "ACE2: Accurately learning subseasonal to decadal atmospheric variability and forced responses" ([link](https://arxiv.org/abs/2411.11268))
- "ACE2: Accurately learning subseasonal to decadal atmospheric variability and forced responses" ([link](https://www.nature.com/articles/s41612-025-01090-0))
- "ACE2-SOM: Coupling to a slab ocean and learning the sensitivity of climate to changes in CO2" ([link](https://arxiv.org/abs/2412.04418))
- "Applying the ACE2 Emulator to SST Green's Functions for the E3SMv3 Global Atmosphere Model" ([link](https://arxiv.org/abs/2505.08742))

## Installation

Expand All @@ -25,25 +26,4 @@ See complete documentation [here](https://ai2-climate-emulator.readthedocs.io/en

## Model checkpoints

Pretrained model checkpoints are available in the [ACE Hugging Face](https://huggingface.co/collections/allenai/ace-67327d822f0f0d8e0e5e6ca4) collection.

## Available datasets
Two versions of the complete dataset described in [arxiv:2310.02074](https://arxiv.org/abs/2310.02074)
are available on a [requester pays](https://cloud.google.com/storage/docs/requester-pays) Google Cloud Storage bucket:
```
gs://ai2cm-public-requester-pays/2023-11-29-ai2-climate-emulator-v1/data/repeating-climSST-1deg-zarrs
gs://ai2cm-public-requester-pays/2023-11-29-ai2-climate-emulator-v1/data/repeating-climSST-1deg-netCDFs
```
The `zarr` format is convenient for ad-hoc analysis. The netCDF version contains our
train/validation split which was used for training and inference.

The datasets used in the [ACE2 paper](https://arxiv.org/abs/2411.11268) are available at:
```
gs://ai2cm-public-requester-pays/2024-11-13-ai2-climate-emulator-v2-amip/data/c96-1deg-shield/
gs://ai2cm-public-requester-pays/2024-11-13-ai2-climate-emulator-v2-amip/data/era5-1deg-1940-2022.zarr/
```

The dataset used in the [ACE2-SOM paper](https://arxiv.org/abs/2412.04418) is available at:
```
gs://ai2cm-public-requester-pays/2024-12-05-ai2-climate-emulator-v2-som/SHiELD-SOM-C96
```
Pretrained model checkpoints, and datasets to run them, are available in the [ACE Hugging Face](https://huggingface.co/collections/allenai/ace-67327d822f0f0d8e0e5e6ca4) collection.
10 changes: 3 additions & 7 deletions analysis-deps.txt
Original file line number Diff line number Diff line change
@@ -1,13 +1,9 @@
# these are some packages which are convenient to have installed for ad-hoc analysis
# but which are not requirements of the "fme" package. We do not relist the fme
# dependencies here.
beaker-py
# these are convenient to have installed for ad-hoc analysis but are not requirements of the "fme" package
Bottleneck
cartopy>=0.22.0
bokeh>=3.1.0
dask[distributed]
ipywidgets
nc-time-axis
jupyterlab
nc-time-axis
pyproj<3.7
seaborn
bokeh>=3.1.0
Loading