Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions .flake8.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
[flake8]
# https://pep8.readthedocs.io/en/latest/intro.html#error-codes
ignore =
# line break after operator
W504
# Max width of GitHub code review is 79 characters
max-line-length = 79
max-complexity = 18
per-file-ignores =
*/__init__.py: F401
exclude =
.git,
docs,
.idea,
.mypy_cache,
.pytest_cache,
57 changes: 35 additions & 22 deletions .github/workflows/build_workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ on:
env:
CANCEL_OTHERS: false
PATHS_IGNORE: '["**/README.md", "**/docs/**"]'
PYTHON_VERSION: "3.13"
PYTHON_VERSION: "3.14"

jobs:
pre-commit-hooks:
Expand Down Expand Up @@ -60,7 +60,7 @@ jobs:
shell: bash -l {0}
strategy:
matrix:
python-version: ["3.10", "3.11", "3.12", "3.13"]
python-version: ["3.10", "3.11", "3.12", "3.13", "3.14"]
fail-fast: false
steps:
- id: skip_check
Expand All @@ -73,43 +73,56 @@ jobs:
uses: actions/checkout@v6

- if: ${{ steps.skip_check.outputs.should_skip != 'true' }}
name: Set up Conda Environment
uses: mamba-org/setup-micromamba@v2
name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v6
with:
python-version: ${{ matrix.python-version }}

- if: ${{ steps.skip_check.outputs.should_skip != 'true' }}
name: Cache pixi packages
uses: actions/cache@v5
env:
# Increase this value to reset cache if deploy inputs have not changed in the workflow
CACHE_NUMBER: 0
with:
environment-name: compass_test
init-shell: bash
condarc: |
channel_priority: strict
channels:
- conda-forge
- e3sm/label/compass
create-args: >-
python=${{ matrix.python-version }}
path: |
~/.cache/rattler/cache
~/.pixi/bin
key: ${{ runner.os }}-${{ matrix.python-version }}-pixi-${{ env.CACHE_NUMBER }}-${{ hashFiles('deploy.py', 'deploy/**', 'pyproject.toml') }}

- if: ${{ steps.skip_check.outputs.should_skip != 'true' }}
name: Install compass
run: |
git config --global url."https://github.com/".insteadOf "git@github.com:"
./conda/configure_compass_env.py \
--env_name compass_test \
--python=${{ matrix.python-version }} \
--mpi=mpich \
--verbose
source load_compass_test_mpich.sh
./deploy.py \
--mache-fork xylar/mache --mache-branch add-target-software-cli-flags \
--no-spack \
--python ${{ matrix.python-version }} \
--recreate
load_script=$(find . -maxdepth 1 -type f -name 'load_compass*.sh' | sort | tail -n 1)
if [ -z "$load_script" ]; then
echo "ERROR: no generated Compass load script found" >&2
exit 1
fi
source "$load_script"
python -c "import compass; import compass.version; print(compass.version.__version__)"
compass --help

- if: ${{ steps.skip_check.outputs.should_skip != 'true' }}
name: Build Sphinx Docs
run: |
source load_compass_test_mpich.sh
load_script=$(find . -maxdepth 1 -type f -name 'load_compass*.sh' | sort | tail -n 1)
source "$load_script"
cd docs
make html
make html-strict

- if: ${{ steps.skip_check.outputs.should_skip != 'true' }}
name: Run Tests
env:
CHECK_IMAGES: False
run: |
source load_compass_test_mpich.sh
load_script=$(find . -maxdepth 1 -type f -name 'load_compass*.sh' | sort | tail -n 1)
source "$load_script"
python -c "import compass"
compass list
compass list --machines
Expand Down
66 changes: 32 additions & 34 deletions .github/workflows/docs_workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,63 +8,61 @@ on:
types: [published]

env:
PYTHON_VERSION: "3.13"
PYTHON_VERSION: "3.14"

jobs:
publish-docs:
runs-on: ubuntu-latest
defaults:
run:
shell: bash -l {0}
env:
docs_version: "latest"
timeout-minutes: 20
steps:
- uses: actions/checkout@v6
with:
persist-credentials: false
fetch-depth: 0

- if: ${{ steps.skip_check.outputs.should_skip != 'true' }}
name: Set up Conda Environment
uses: mamba-org/setup-micromamba@v2
- name: Set up Python ${{ env.PYTHON_VERSION }}
uses: actions/setup-python@v6
with:
environment-name: compass_test
init-shell: bash
condarc: |
channel_priority: strict
channels:
- conda-forge
- e3sm/label/compass
create-args: >-
python=${{ env.PYTHON_VERSION }}
python-version: ${{ env.PYTHON_VERSION }}

- if: ${{ steps.skip_check.outputs.should_skip != 'true' }}
name: Install compass
- name: Cache pixi packages
uses: actions/cache@v5
env:
# Increase this value to reset cache if deploy inputs have not changed in the workflow
CACHE_NUMBER: 0
with:
path: |
~/.cache/rattler/cache
~/.pixi/bin
key: ${{ runner.os }}-${{ env.PYTHON_VERSION }}-pixi-${{ env.CACHE_NUMBER }}-${{ hashFiles('deploy.py', 'deploy/**', 'pyproject.toml') }}

- name: Install compass
run: |
git config --global url."https://github.com/".insteadOf "git@github.com:"
./conda/configure_compass_env.py \
--env_only \
--env_name compass_test \
--python=${{ env.PYTHON_VERSION }} \
--verbose
source load_compass_test.sh
./deploy.py \
--no-spack \
--python ${{ env.PYTHON_VERSION }} \
--recreate
load_script=$(find . -maxdepth 1 -type f -name 'load_compass*.sh' | sort | tail -n 1)
if [ -z "$load_script" ]; then
echo "ERROR: no generated Compass load script found" >&2
exit 1
fi
source "$load_script"

- name: Build Sphinx Docs
run: |
source load_compass_test.sh
load_script=$(find . -maxdepth 1 -type f -name 'load_compass*.sh' | sort | tail -n 1)
source "$load_script"
cd docs
if [[ $GITHUB_REF_NAME == "main" ]]; then
export DOCS_VERSION="latest"
else
export DOCS_VERSION=${GITHUB_REF_NAME}
fi
echo "Docs version: $DOCS_VERSION"
echo "docs_version=$DOCS_VERSION" >> $GITHUB_ENV
make html
- name: Copy Docs and Commit
run: |
source load_compass_test.sh
load_script=$(find . -maxdepth 1 -type f -name 'load_compass*.sh' | sort | tail -n 1)
source "$load_script"
cd docs
# gh-pages branch must already exist
git clone https://github.com/MPAS-Dev/compass.git --branch gh-pages --single-branch gh-pages
Expand All @@ -74,8 +72,8 @@ jobs:
touch .nojekyll
# Add `index.html` to point to the `main` branch automatically.
printf '<meta http-equiv="refresh" content="0; url=./main/index.html" />' > index.html
# Only replace `main` docs with latest changes. Docs for releases should be untouched.
export DOCS_VERSION="${{ env.docs_version }}"
# Replace the docs for the current branch or tag with the latest build.
export DOCS_VERSION="${GITHUB_REF_NAME}"
rm -rf ${DOCS_VERSION}
mkdir ${DOCS_VERSION}
cp -r ../_build/html/* ${DOCS_VERSION}
Expand Down
51 changes: 39 additions & 12 deletions .github/workflows/gis_coarse_meshgen.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,24 +15,52 @@ jobs:
gis-coarse-meshgen:
name: GIS Coarse Mesh Generation
runs-on: ubuntu-latest
defaults:
run:
shell: bash -l {0}
steps:
- uses: actions/checkout@v6
with:
submodules: recursive
path: compass
- name: setup_and_run_step
run: |
# create top level working directory
root=$PWD
pushd compass

# create the compass environment
./conda/configure_compass_env.py --conda $root/mambaForge --env_name compass_test --mpi mpich
- name: Set up Python 3.14
uses: actions/setup-python@v6
with:
python-version: "3.14"

- name: Cache pixi packages
uses: actions/cache@v5
env:
# Increase this value to reset cache if deploy inputs have not changed in the workflow
CACHE_NUMBER: 0
with:
path: |
~/.cache/rattler/cache
~/.pixi/bin
key: ${{ runner.os }}-3.14-pixi-${{ env.CACHE_NUMBER }}-${{ hashFiles('deploy.py', 'deploy/**', 'pyproject.toml') }}

- name: Install compass
run: |
git config --global url."https://github.com/".insteadOf "git@github.com:"
./deploy.py \
--mache-fork xylar/mache --mache-branch add-target-software-cli-flags \
--no-spack \
--python 3.14 \
--recreate
load_script=$(find . -maxdepth 1 -type f -name 'load_compass*.sh' | sort | tail -n 1)
if [ -z "$load_script" ]; then
echo "ERROR: no generated Compass load script found" >&2
exit 1
fi
source "$load_script"

# enable the compass environment
source load_compass_test_mpich.sh
- name: Setup and run step
run: |
load_script=$(find . -maxdepth 1 -type f -name 'load_compass*.sh' | sort | tail -n 1)
source "$load_script"

popd
# create top level working directory
root=$PWD

# download the input GIS coarse mesh
tarball=gis4kmSubSampled_01302025.tgz
Expand Down Expand Up @@ -71,4 +99,3 @@ jobs:
# run the test case
cd $testDir
compass run

18 changes: 18 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -120,3 +120,21 @@ ENV/

# activation scripts
/load_*.sh

# pixi
.pixi/
pixi.lock
pixi-env/

# vs code
.vscode/

# mypy
.mypy_cache/

# ruff
.ruff_cache/

# mache
.mache_cache/
deploy_tmp
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ repos:
rev: 7.3.0
hooks:
- id: flake8
args: ["--config=setup.cfg"]
args: ["--config=.flake8.cfg"]
additional_dependencies: [flake8-isort]

# https://pre-commit.ci/#configuration
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
import netCDF4

import compass.namelist
from compass.io import symlink
from compass.job import write_job_script
from compass.load_script import symlink_load_script
from compass.model import run_model
from compass.step import Step

Expand Down Expand Up @@ -166,14 +166,7 @@ def setup(self):
pre_run_commands=pre_run_cmd,
post_run_commands=post_run_cmd)

# COMPASS does not create symlinks for the load script in step dirs,
# so use the standard approach for creating that symlink in each
# step dir.
if 'LOAD_COMPASS_ENV' in os.environ:
script_filename = os.environ['LOAD_COMPASS_ENV']
# make a symlink to the script for loading the compass conda env.
symlink(script_filename, os.path.join(self.work_dir,
'load_compass_env.sh'))
symlink_load_script(self.work_dir)

def run(self):
"""
Expand Down
11 changes: 2 additions & 9 deletions compass/landice/tests/ensemble_generator/ensemble_member.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
import netCDF4
import yaml

from compass.io import symlink
from compass.job import write_job_script
from compass.landice.extrapolate import extrapolate_variable
from compass.load_script import symlink_load_script
from compass.model import make_graph_file, run_model
from compass.step import Step

Expand Down Expand Up @@ -262,14 +262,7 @@ def setup(self):
target_cores=self.ntasks, min_cores=self.min_tasks,
work_dir=self.work_dir)

# COMPASS does not create symlinks for the load script in step dirs,
# so use the standard approach for creating that symlink in each
# step dir.
if 'LOAD_COMPASS_ENV' in os.environ:
script_filename = os.environ['LOAD_COMPASS_ENV']
# make a symlink to the script for loading the compass conda env.
symlink(script_filename, os.path.join(self.work_dir,
'load_compass_env.sh'))
symlink_load_script(self.work_dir)

# save run info for analysis/viz
with open(os.path.join(self.work_dir, 'run_info.cfg'), 'w') \
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@

from jinja2 import Template

from compass.io import symlink
from compass.job import write_job_script
from compass.load_script import symlink_load_script
from compass.model import make_graph_file, run_model
from compass.step import Step

Expand Down Expand Up @@ -290,14 +290,7 @@ def setup(self): # noqa:C901
graph_filename=os.path.join(self.work_dir,
'graph.info'))

# COMPASS does not create symlinks for the load script in step dirs,
# so use the standard approach for creating that symlink in each
# step dir.
if 'LOAD_COMPASS_ENV' in os.environ:
script_filename = os.environ['LOAD_COMPASS_ENV']
# make a symlink to the script for loading the compass conda env.
symlink(script_filename, os.path.join(self.work_dir,
'load_compass_env.sh'))
symlink_load_script(self.work_dir)

# customize job script
self.config.set('job', 'job_name', self.exp)
Expand Down
Loading
Loading