diff --git a/.github/workflows/black.yml b/.github/workflows/black.yml deleted file mode 100644 index 86ca420414..0000000000 --- a/.github/workflows/black.yml +++ /dev/null @@ -1,37 +0,0 @@ -name: black check on push and PR -# -# Run the python formatting in check mode -# -on: [push, pull_request] - -jobs: - black-check: - runs-on: ubuntu-latest - steps: - # Checkout the code - - uses: actions/checkout@v2 - # Use the latest stable version of the github action - - uses: psf/black@stable - with: - # Use options and version identical to the conda environment - # Using pyproject.toml makes sure this testing is consistent with our python directory testing - options: "--check --config python/pyproject.toml" - src: "./python" - # Version should be coordinated with the ctsm_pylib conda environment under the python directory - version: "25.1.0" - # Actions identical to above for each directory and source file we need to check (arrays aren't allowed for src: field) - - uses: psf/black@stable - with: - options: "--check --config python/pyproject.toml" - src: "./cime_config/SystemTests" - version: "25.1.0" - - uses: psf/black@stable - with: - options: "--check --config python/pyproject.toml" - src: "./cime_config/buildlib" - version: "25.1.0" - - uses: psf/black@stable - with: - options: "--check --config python/pyproject.toml" - src: "./cime_config/buildnml" - version: "25.1.0" diff --git a/.github/workflows/fleximod_test.yaml b/.github/workflows/fleximod_test.yaml new file mode 100644 index 0000000000..7f3e5a1404 --- /dev/null +++ b/.github/workflows/fleximod_test.yaml @@ -0,0 +1,31 @@ +name: git-fleximod test +# +# Test git-fleximod update and cleanliness +# Based closely on workflow from CESM repo +# +on: [push, pull_request] + +jobs: + fleximod-test: + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + # oldest supported and latest supported + python-version: ["3.7", "3.x"] + steps: + - id: checkout-CTSM + uses: actions/checkout@v4 + - id: run-fleximod + run: | + $GITHUB_WORKSPACE/bin/git-fleximod update + echo + echo "Update complete, checking status" + echo + $GITHUB_WORKSPACE/bin/git-fleximod test + - id: check-cleanliness + run: | + echo + echo "Checking if git fleximod matches expected externals" + echo + git diff --exit-code diff --git a/.github/workflows/formatting_python.yml b/.github/workflows/formatting_python.yml new file mode 100644 index 0000000000..6fffd4261b --- /dev/null +++ b/.github/workflows/formatting_python.yml @@ -0,0 +1,44 @@ +name: Check Python formatting + +on: + push: + paths: + - 'python/**' + - 'cime_config/SystemTests/**' + - 'cime_config/buildlib/**' + - 'cime_config/buildnml/**' + pull_request: + paths: + - 'python/**' + - 'cime_config/SystemTests/**' + - 'cime_config/buildlib/**' + - 'cime_config/buildnml/**' + +jobs: + lint-and-format-check: + runs-on: ubuntu-latest + steps: + # Checkout the code + - uses: actions/checkout@v4 + + # Set up the conda environment + - uses: conda-incubator/setup-miniconda@v3 + with: + activate-environment: ctsm_pylib + environment-file: python/conda_env_ctsm_py.yml + channels: conda-forge + auto-activate-base: false + + # Run pylint check + - name: Run pylint + run: | + cd python + conda run -n ctsm_pylib make lint + + # Run black check + - name: Run black + # Run this step even if previous step(s) failed + if: success() || failure() + run: | + cd python + conda run -n ctsm_pylib make black diff --git a/.gitmodules b/.gitmodules index 2787973b6d..e569896811 100644 --- a/.gitmodules +++ b/.gitmodules @@ -31,7 +31,7 @@ url = https://github.com/NGEET/fates fxtag = sci.1.82.3_api.39.0.0 fxrequired = AlwaysRequired # Standard Fork to compare to with "git fleximod test" to ensure personal forks aren't committed -fxDONOTUSEurl = https://github.com/NCAR/fates-release +fxDONOTUSEurl = https://github.com/NGEET/fates [submodule "cism"] path = components/cism diff --git a/py_env_create b/py_env_create index 8b7ffaec47..5b4515bc75 100755 --- a/py_env_create +++ b/py_env_create @@ -18,8 +18,8 @@ cd "${SCRIPT_DIR}" condadir="${SCRIPT_DIR}/python" default_new_env_name=ctsm_pylib default_old_env_name=ctsm_pylib_3_7_9 -default_condafile="${condadir}/conda_env_ctsm_py.txt" -default_condafile_old="${condadir}/conda_env_ctsm_py_old_3.7.9.txt" +default_condafile="${condadir}/conda_env_ctsm_py.yml" +default_condafile_old="${condadir}/conda_env_ctsm_py_old_3.7.9.yml" condafile="${default_condafile}" quiet="" @@ -228,26 +228,15 @@ if [[ ${conda_env_does_exist} -gt 0 ]]; then fi # -# Create the environment -# -echo "Create $new_env_name" -if [[ "${quiet}" == "--quiet" ]]; then - (set -x; ${condamamba} create ${yes} --name $new_env_name ${quiet} 1>/dev/null) -else - (set -x; ${condamamba} create ${yes} --name $new_env_name ${verbose}) -fi - -# -# Install the environment +# Create and install the environment # echo "Installing $new_env_name; this can take a few minutes." -cmd="" if [[ "${quiet}" == "--quiet" ]]; then - # -q/--quiet option not available on Derecho - (set -x; ${condamamba} install ${yes} --channel conda-forge --name $new_env_name --file $condafile $option ${quiet} 1>/dev/null) + (set -x; ${condamamba} env create ${yes} --file "${condafile}" --name $new_env_name ${quiet} $option 1>/dev/null) else - (set -x; ${condamamba} install ${yes} --channel conda-forge --name $new_env_name --file $condafile $option ${verbose}) + (set -x; ${condamamba} env create ${yes} --file "${condafile}" --name $new_env_name $option ${verbose}) fi + # # Report on success # diff --git a/python/conda_env_ctsm_py.txt b/python/conda_env_ctsm_py.txt deleted file mode 100644 index 58f32092e6..0000000000 --- a/python/conda_env_ctsm_py.txt +++ /dev/null @@ -1,27 +0,0 @@ -# -# NOTE: On Derecho you may need to "module load conda" -# -# use the top level bash script: -# ../py_env_create # Do this each time you update your CTSM Version -# conda activate ctsm_pylib # Do this anytime you want to run a CTSM python script -# Or the individual conda commands: -# conda create -n ctsm_pylib # Do this one time for each machine -# conda install -n ctsm_pylib --file conda_env_ctsm_py.txt # Do this each time you update your CTSM Version -# conda activate ctsm_pylib # Do this anytime you want to run a CTSM python script -# -python=3.13.2 -xarray=2025.1.2 -tqdm=4.67.1 -scipy=1.15.2 -netcdf4=1.7.2 -requests=2.32.3 -xesmf=0.8.8 -numba=0.61.0 -pylint=3.3.4 -black=25.1.0 # NOTE: This version must be coordinated with ../.github/workflows/black.yml -cartopy=0.24.0 -matplotlib=3.10.1 - -# Used in ctsm_postprocessing repo -pytest=8.3.5 -coverage=7.8.0 diff --git a/python/conda_env_ctsm_py.yml b/python/conda_env_ctsm_py.yml new file mode 100644 index 0000000000..8a951bb3f6 --- /dev/null +++ b/python/conda_env_ctsm_py.yml @@ -0,0 +1,22 @@ +# This file is used by py_env_create to install the latest version of the ctsm_pylib conda environment. +name: ctsm_pylib +channels: + - conda-forge + - defaults +dependencies: + - python=3.13.2 + - xarray=2025.1.2 + - tqdm=4.67.1 + - scipy=1.15.2 + - netcdf4=1.7.2 + - requests=2.32.3 + - xesmf=0.8.8 + - numba=0.61.0 + - pylint=3.3.4 + - black=25.1.0 + - cartopy=0.24.0 + - matplotlib=3.10.1 + + # Used in ctsm_postprocessing repo + - pytest=8.3.5 + - coverage=7.8.0 diff --git a/python/conda_env_ctsm_py_old_3.7.9.txt b/python/conda_env_ctsm_py_old_3.7.9.txt deleted file mode 100644 index 6d39d2c6b8..0000000000 --- a/python/conda_env_ctsm_py_old_3.7.9.txt +++ /dev/null @@ -1,19 +0,0 @@ -# This file is used by py_env_create to install the previous version of the ctsm_pylib environment, -# which used Python 3.7.9. Doing so is only useful for running CTSM python tools in repos from -# before the new ctsm_pylib version (with Python 3.13.2) was introduced. -# -python=3.7.9 -pandas=1.3.5 -tqdm=4.67.1 -scipy=1.7.3 -netcdf4=1.6.0 -requests=2.32.2 -packaging=21.3 -numpy=1.19.5 -xarray=0.17.0 -xesmf=0.7.0 -numba=0.55.2 -pylint=2.8.3 -black=22.3.0 -cartopy=0.20.2 -matplotlib=3.3.2 diff --git a/python/conda_env_ctsm_py_old_3.7.9.yml b/python/conda_env_ctsm_py_old_3.7.9.yml new file mode 100644 index 0000000000..e77bab7634 --- /dev/null +++ b/python/conda_env_ctsm_py_old_3.7.9.yml @@ -0,0 +1,24 @@ +# This file is used by py_env_create to install the previous version of the ctsm_pylib environment, +# which used Python 3.7.9. Doing so is only useful for running CTSM python tools in repos from +# before the new ctsm_pylib version (with Python 3.13.2) was introduced. +# +name: ctsm_pylib_3_7_9 +channels: + - conda-forge + - defaults +dependencies: + - python=3.7.9 + - pandas=1.3.5 + - tqdm=4.67.1 + - scipy=1.7.3 + - netcdf4=1.6.0 + - requests=2.32.2 + - packaging=21.3 + - numpy=1.19.5 + - xarray=0.17.0 + - xesmf=0.7.0 + - numba=0.55.2 + - pylint=2.8.3 + - black=22.3.0 + - cartopy=0.20.2 + - matplotlib=3.3.2