diff --git a/.github/workflows/lint.yaml b/.github/workflows/lint.yaml index 0d15d592..48ea1b9b 100644 --- a/.github/workflows/lint.yaml +++ b/.github/workflows/lint.yaml @@ -6,21 +6,19 @@ jobs: lint: runs-on: ubuntu-latest steps: - - name: Checkout Pace repository - uses: actions/checkout@v3.5.2 - with: - submodules: 'recursive' - - name: Step Python 3.11.7 - uses: actions/setup-python@v4.6.0 - with: - python-version: '3.11.7' - - name: Install OpenMPI for gt4py - run: | - sudo apt-get install libopenmpi-dev - - name: Install Python packages - run: | - python -m pip install --upgrade pip - pip install -r requirements_dev.txt -r requirements_lint.txt - - name: Run lint via pre-commit - run: | - pre-commit run --all-files + - name: Checkout repository + uses: actions/checkout@v4 + with: + submodules: 'recursive' + + - name: Step Python 3.11.9 + uses: actions/setup-python@v5 + with: + python-version: '3.11.9' + + - name: Install pre-commit + run: pip install pre-commit + + - name: Run lint via pre-commit + run: | + pre-commit run --all-files diff --git a/.github/workflows/main_unit_tests.yaml b/.github/workflows/main_unit_tests.yaml index 3804edbd..b98df73c 100644 --- a/.github/workflows/main_unit_tests.yaml +++ b/.github/workflows/main_unit_tests.yaml @@ -42,35 +42,29 @@ jobs: submodules: 'recursive' path: pace/${{inputs.component_name}} - - name: install packages - if: ${{ ! inputs.component_trigger }} + - name: Install packages run: | cd ${GITHUB_WORKSPACE}/pace - pip3 install --upgrade pip setuptools wheel - pip3 install -r requirements_dev.txt -c constraints.txt + pip install .[test] - - name: "External trigger: Install packages" - if: ${{ inputs.component_trigger }} - # Ignore `constraints.txt` when running as part of the NDSL pipeline - # to avoid false positives in package dependency resolution. + - name: Print versions run: | - cd ${GITHUB_WORKSPACE}/pace - pip3 install --upgrade pip setuptools wheel - pip3 install -r requirements_dev.txt + python --version + pip --version + pip list - - name: prepare input files + - name: Prepare input files run: | cd ${GITHUB_WORKSPACE}/pace mkdir tests/main/input - python3 examples/generate_eta_files.py - mv *eta*.nc tests/main/input + python examples/generate_eta_files.py tests/main/input - - name: run tests + - name: Run tests run: | cd ${GITHUB_WORKSPACE}/pace - pytest -x tests/main + python -m pytest -x tests/main - - name: run baroclinic + - name: Run baroclinic test case run: | cd ${GITHUB_WORKSPACE}/pace mpiexec -np 6 --oversubscribe python -m pace.run examples/configs/baroclinic_c12.yaml diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 5671f561..3205f125 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -1,23 +1,22 @@ # Contributing -pace is actively developed by AI2, so please contact us if there is interest in making contributions in the near-term. -Contributors names will be added to [`CONTRIBUTORS.md`](https://github.com/VulcanClimateModeling/fv3core/blob/master/CONTRIBUTORS.md). +pace is actively developed by NOAA/NASA, so please contact us if there is interest in making contributions in the near-term. +Contributors names will be added to [`CONTRIBUTORS.md`](https://github.com/NOAA-GFDL/pace/blob/develop/CONTRIBUTORS.md). ## Linting -Dependencies for linting are maintained in `requirements_lint.txt`, and can be installed with: +We rely on `pre-commit` for linting, which is included in the `[dev]` extra. ```shell -pip install -c constraints.txt -r requirements_lint.txt +pip install -e .[dev] ``` Correcting and checking your code complies with all requirements can be run with: ```shell -make lint +pre-commit run --all-files ``` -We manage the list of syntax requirements using [pre-commit](https://pre-commit.com/). **This runs all checks and is required to pass as one of the continuous integration tests.** The list of checkes includes `black`, `isort`, and `flake8`, among a few others, found in `.pre-commit-config.yaml`. diff --git a/README.md b/README.md index 58d674e6..30e9a0a2 100644 --- a/README.md +++ b/README.md @@ -9,7 +9,7 @@ Pace is an implementation of the FV3GFS / SHiELD atmospheric model developed by 🚧 **WARNING** This repo is under active development - supported features and procedures can change rapidly and without notice. 🚧 -The repository model code is split between [pyFV3](https://github.com/NOAA-GFDL/pyFV3) for the dynamical core and [pySHiELD](https://github.com/NOAA-GFDL/pySHiELD) for the physics parametrization. A full depencies looks like the following: +The repository model code is split between [pyFV3](https://github.com/NOAA-GFDL/pyFV3) for the dynamical core and [pySHiELD](https://github.com/NOAA-GFDL/pySHiELD) for the physics parametrization. A full dependencies looks like the following: ```mermaid flowchart TD @@ -60,14 +60,26 @@ git submodule update --init --recursive We recommend creating a python `venv` or `conda` environment specifically for Pace. ```shell -python3 -m venv venv_name -source venv_name/bin/activate +python -m venv .venv +source .venv/bin/activate ``` -Inside of your pace `venv` or conda environment pip install the Python requirements, GT4Py, and Pace: +Inside of your pace `venv` or `conda` environment, install pace and its dependencies. For developers, we recommend an editable install with the `[dev]` extra: ```shell -pip3 install -r requirements_dev.txt -c constraints.txt +pip install -e .[dev] +``` + +For running tests, we recommend to install pace with the `[test]` extra (avoid pulling other dev dependencies): + +```shell +pip install .[test] +``` + +For just running pace, you don't need any extra: + +```shell +pip install . ``` Shell scripts to install Pace on specific machines such as Gaea can be found in `examples/build_scripts/`. @@ -80,8 +92,7 @@ Before starting any run, including unit tests, the user must ensure that the pro ```shell mkdir tests/main/input -python3 examples/generate_eta_files.py -mv *eta*.nc tests/main/input +python examples/generate_eta_files.py tests/main/input ``` These commands will generate the files necessary and place them in the `tests/main/input` directory. Once the files are generated the `baroclinic_c12.yaml` configuration can be used to generate a run: @@ -93,7 +104,7 @@ mpirun -n 6 python3 -m pace.run examples/configs/baroclinic_c12.yaml mpirun -n 6 --oversubscribe python3 -m pace.run examples/configs/baroclinic_c12.yaml ``` -After the run completes, you will see an output direcotry `output.zarr`. An example to visualize the output is provided in `examples/plot_output.py`. See the [driver example](examples/README.md) section for more details. +After the run completes, you will see an output directory `output.zarr`. An example to visualize the output is provided in `examples/plot_output.py`. See the [driver example](examples/README.md) section for more details. ### Environment variable configuration diff --git a/constraints.txt b/constraints.txt deleted file mode 100644 index 44dee2aa..00000000 --- a/constraints.txt +++ /dev/null @@ -1,537 +0,0 @@ -# -# This file is autogenerated by pip-compile with Python 3.11 -# by the following command: -# -# pip-compile --output-file=constraints.txt requirements_dev.txt requirements_docs.txt requirements_lint.txt -# -aenum==3.1.15 - # via dace -aiohttp==3.9.5 - # via gcsfs -aiosignal==1.3.1 - # via aiohttp -alabaster==0.7.12 - # via sphinx -appdirs==1.4.4 - # via fv3config -asciitree==0.3.3 - # via zarr -asttokens==2.4.1 - # via - # devtools - # stack-data -astunparse==1.6.3 - # via dace -attrs==23.2.0 - # via - # aiohttp - # gt4py - # jsonschema - # pytest-subtests - # referencing -babel==2.9.1 - # via sphinx -backports-entry-points-selectable==1.1.1 - # via virtualenv -black==24.4.0 - # via gt4py -boltons==24.0.0 - # via gt4py -cached-property==1.5.2 - # via gt4py -cachetools==5.3.3 - # via google-auth -certifi==2024.2.2 - # via - # netcdf4 - # requests -cfgv==3.3.1 - # via pre-commit -cftime==1.6.3 - # via - # -r requirements_dev.txt - # ndsl - # netcdf4 -charset-normalizer==3.3.2 - # via requests -click==8.1.7 - # via - # black - # dask - # gt4py -cloudpickle==3.0.0 - # via dask -cmake==3.29.2 - # via - # dace - # gt4py -comm==0.2.2 - # via ipykernel -commonmark==0.9.1 - # via recommonmark -contourpy==1.3.0 - # via matplotlib -coverage==7.5.0 - # via pytest-cov -cycler==0.12.1 - # via matplotlib -cytoolz==0.12.3 - # via gt4py -dacite==1.8.1 - # via - # fv3config - # pace -dask==2024.4.2 - # via - # -r requirements_dev.txt - # ndsl -debugpy==1.8.1 - # via ipykernel -decorator==5.1.1 - # via - # gcsfs - # ipython -deepdiff==7.0.1 - # via gt4py -devtools==0.12.2 - # via gt4py -dill==0.3.8 - # via dace -distlib==0.3.2 - # via virtualenv -distro==1.9.0 - # via scikit-build -docutils==0.16 - # via - # recommonmark - # sphinx - # sphinx-rtd-theme -executing==2.0.1 - # via - # devtools - # stack-data -f90nml==1.4.4 - # via - # -r requirements_dev.txt - # fv3config - # ndsl - # pyfv3 - # pyshield -factory-boy==3.3.0 - # via gt4py -faker==24.11.0 - # via factory-boy -fasteners==0.19 - # via zarr -fastjsonschema==2.19.1 - # via nbformat -filelock==3.0.12 - # via virtualenv -fonttools==4.53.1 - # via matplotlib -fparser==0.1.4 - # via dace -frozendict==2.4.2 - # via gt4py -frozenlist==1.4.1 - # via - # aiohttp - # aiosignal -fsspec==2024.3.1 - # via - # dask - # fv3config - # gcsfs - # ndsl -fv3config==0.9.0 - # via -r requirements_dev.txt -gcsfs==2024.3.1 - # via fv3config -google-api-core==2.18.0 - # via - # google-cloud-core - # google-cloud-storage -google-auth==2.29.0 - # via - # gcsfs - # google-api-core - # google-auth-oauthlib - # google-cloud-core - # google-cloud-storage -google-auth-oauthlib==1.2.0 - # via gcsfs -google-cloud-core==2.4.1 - # via google-cloud-storage -google-cloud-storage==2.16.0 - # via gcsfs -google-crc32c==1.5.0 - # via - # google-cloud-storage - # google-resumable-media -google-resumable-media==2.7.0 - # via google-cloud-storage -googleapis-common-protos==1.63.0 - # via google-api-core -gprof2dot==2022.7.29 - # via pytest-profiling -gridtools-cpp==2.3.4 - # via gt4py -h5netcdf==1.3.0 - # via ndsl -h5py==3.11.0 - # via h5netcdf -identify==2.2.13 - # via pre-commit -idna==3.7 - # via - # requests - # yarl -imagesize==1.2.0 - # via sphinx -importlib-metadata==7.1.0 - # via dask -iniconfig==2.0.0 - # via pytest -ipykernel==6.29.4 - # via nbmake -ipython==8.23.0 - # via ipykernel -jedi==0.19.1 - # via ipython -jinja2==3.1.3 - # via - # dace - # gt4py - # sphinx -jsonschema==4.21.1 - # via nbformat -jsonschema-specifications==2023.12.1 - # via jsonschema -jupyter-client==8.6.1 - # via - # ipykernel - # nbclient -jupyter-core==5.7.2 - # via - # ipykernel - # jupyter-client - # nbformat -kiwisolver==1.4.7 - # via matplotlib -lark==1.1.9 - # via gt4py -locket==1.0.0 - # via partd -mako==1.3.3 - # via gt4py -markupsafe==2.1.5 - # via - # jinja2 - # mako -matplotlib==3.9.2 - # via ndsl -matplotlib-inline==0.1.7 - # via - # ipykernel - # ipython -mpi4py==3.1.5 - # via - # -r requirements_dev.txt - # ndsl - # pace -mpmath==1.3.0 - # via sympy -multidict==6.0.5 - # via - # aiohttp - # yarl -mypy-extensions==1.0.0 - # via black -nanobind==1.9.2 - # via gt4py -nbclient==0.6.8 - # via nbmake -nbformat==5.10.4 - # via - # nbclient - # nbmake -nbmake==1.5.3 - # via -r requirements_dev.txt -nest-asyncio==1.6.0 - # via - # ipykernel - # nbclient -netcdf4==1.7.1 - # via - # -r requirements_dev.txt - # ndsl - # pace -networkx==3.3 - # via dace -ninja==1.11.1.1 - # via gt4py -nodeenv==1.6.0 - # via pre-commit -numcodecs==0.12.1 - # via zarr -numpy==1.26.4 - # via - # -r requirements_dev.txt - # cftime - # contourpy - # dace - # gt4py - # h5py - # matplotlib - # ndsl - # netcdf4 - # numcodecs - # pace - # pandas - # pyfv3 - # pyshield - # scipy - # xarray - # zarr -oauthlib==3.2.2 - # via requests-oauthlib -ordered-set==4.1.0 - # via deepdiff -packaging==24.0 - # via - # black - # dace - # dask - # gt4py - # h5netcdf - # ipykernel - # matplotlib - # pytest - # scikit-build - # setuptools-scm - # sphinx - # xarray -pandas==2.2.2 - # via xarray -parso==0.8.4 - # via jedi -partd==1.4.1 - # via dask -pathspec==0.12.1 - # via black -pexpect==4.9.0 - # via ipython -pillow==10.4.0 - # via matplotlib -platformdirs==2.6.2 - # via - # black - # jupyter-core - # virtualenv -pluggy==1.5.0 - # via pytest -ply==3.11 - # via dace -pre-commit==2.14.0 - # via -r requirements_lint.txt -prompt-toolkit==3.0.43 - # via ipython -proto-plus==1.23.0 - # via google-api-core -protobuf==4.25.3 - # via - # google-api-core - # googleapis-common-protos - # proto-plus -psutil==5.9.8 - # via ipykernel -ptyprocess==0.7.0 - # via pexpect -pure-eval==0.2.2 - # via stack-data -pyasn1==0.6.0 - # via - # pyasn1-modules - # rsa -pyasn1-modules==0.4.0 - # via google-auth -pybind11==2.12.0 - # via gt4py -pygments==2.17.2 - # via - # devtools - # ipython - # nbmake - # sphinx -pyparsing==3.1.4 - # via matplotlib -pytest==8.1.1 - # via - # -r requirements_dev.txt - # nbmake - # pytest-cov - # pytest-datadir - # pytest-profiling - # pytest-regressions - # pytest-subtests -pytest-cov==5.0.0 - # via -r requirements_dev.txt -pytest-datadir==1.5.0 - # via pytest-regressions -pytest-profiling==1.7.0 - # via -r requirements_dev.txt -pytest-regressions==2.5.0 - # via -r requirements_dev.txt -pytest-subtests==0.12.1 - # via -r requirements_dev.txt -python-dateutil==2.9.0.post0 - # via - # faker - # jupyter-client - # matplotlib - # pandas -pytz==2024.1 - # via - # babel - # pandas -pyyaml==6.0.1 - # via - # dace - # dask - # fv3config - # pace - # pre-commit - # pytest-regressions -pyzmq==26.0.2 - # via - # ipykernel - # jupyter-client -recommonmark==0.7.1 - # via -r requirements_docs.txt -referencing==0.35.0 - # via - # jsonschema - # jsonschema-specifications -requests==2.31.0 - # via - # gcsfs - # google-api-core - # google-cloud-storage - # requests-oauthlib - # sphinx -requests-oauthlib==2.0.0 - # via google-auth-oauthlib -rpds-py==0.18.0 - # via - # jsonschema - # referencing -rsa==4.9 - # via google-auth -scikit-build==0.18.1 - # via dace -scipy==1.13.0 - # via - # -r requirements_dev.txt - # ndsl -setuptools-scm==8.0.4 - # via fparser -six==1.16.0 - # via - # asttokens - # astunparse - # pytest-profiling - # python-dateutil - # virtualenv -snowballstemmer==2.1.0 - # via sphinx -sphinx==4.1.2 - # via - # -r requirements_docs.txt - # recommonmark - # sphinx-argparse - # sphinx-gallery - # sphinx-rtd-theme -sphinx-argparse==0.3.1 - # via -r requirements_docs.txt -sphinx-gallery==0.10.1 - # via -r requirements_docs.txt -sphinx-rtd-theme==0.5.2 - # via -r requirements_docs.txt -sphinxcontrib-applehelp==1.0.2 - # via sphinx -sphinxcontrib-devhelp==1.0.2 - # via sphinx -sphinxcontrib-htmlhelp==2.0.0 - # via sphinx -sphinxcontrib-jsmath==1.0.1 - # via sphinx -sphinxcontrib-qthelp==1.0.3 - # via sphinx -sphinxcontrib-serializinghtml==1.1.5 - # via sphinx -stack-data==0.6.3 - # via ipython -sympy==1.12 - # via dace -tabulate==0.9.0 - # via gt4py -toml==0.10.2 - # via pre-commit -toolz==0.12.1 - # via - # cytoolz - # dask - # partd -tornado==6.4 - # via - # ipykernel - # jupyter-client -traitlets==5.14.3 - # via - # comm - # ipykernel - # ipython - # jupyter-client - # jupyter-core - # matplotlib-inline - # nbclient - # nbformat -typing-extensions==4.12.2 - # via - # gt4py - # ipython - # setuptools-scm -tzdata==2024.1 - # via pandas -urllib3==2.2.1 - # via requests -virtualenv==20.7.2 - # via pre-commit -wcwidth==0.2.13 - # via prompt-toolkit -websockets==12.0 - # via dace -wheel==0.43.0 - # via - # astunparse - # scikit-build -xarray==2025.01.2 - # via - # -r requirements_dev.txt - # ndsl - # pace - # pyfv3 - # pyshield -xxhash==3.0.0 - # via gt4py -yarl==1.9.4 - # via aiohttp -zarr==2.18.2 - # via - # -r requirements_dev.txt - # pace -zipp==3.18.1 - # via importlib-metadata - -# The following packages are considered to be unsafe in a requirements file: -# setuptools diff --git a/examples/README.md b/examples/README.md index 55143967..873e04aa 100644 --- a/examples/README.md +++ b/examples/README.md @@ -89,12 +89,14 @@ Another example is `baroclinic_init.py`, which initializes a barcolinic wave and ```bash $ mpirun -n 6 python3 baroclinic_init.py ./configs/baroclinic_c12.yaml ``` + ## Docker To run a baroclinic c12 case with Docker in a single command, run `run_docker.sh`. This example will start from the Python 3.8 docker image, install extra dependencies and Python packages, and execute the example, leaving the output in this directory. To visualize the output, two example scripts are provided: + 1. `plot_output.py`: To use it, you must install matplotlib (e.g. with `pip install matplotlib`). 2. `plot_cube.py`: this uses plotting tools in [fv3viz](https://github.com/ai2cm/fv3net/tree/master/external/fv3viz). Note the requirements aren't part of pace by default and need to be installed accordingly. It is recommended to use the post processing docker provided at the top level `docker/postprocessing.Dockerfile`. diff --git a/examples/build_scripts/build_gaea_c4.sh b/examples/build_scripts/build_gaea_c4.sh index def7af3f..608cf9fb 100644 --- a/examples/build_scripts/build_gaea_c4.sh +++ b/examples/build_scripts/build_gaea_c4.sh @@ -19,9 +19,8 @@ cd pace # create a conda environment for pace conda create -y --name my_name python=3.8 -# enter the environment and update it +# enter the environment conda activate my_name -pip3 install --upgrade pip setuptools wheel -# install the Pace dependencies, GT4Py, and Pace -pip3 install -r requirements_dev.txt -c constraints.txt +# install Pace dependencies and its dependencies +pip3 install .[test] diff --git a/examples/build_scripts/build_gaea_c5.sh b/examples/build_scripts/build_gaea_c5.sh index 94ad5611..627c8a06 100644 --- a/examples/build_scripts/build_gaea_c5.sh +++ b/examples/build_scripts/build_gaea_c5.sh @@ -19,9 +19,8 @@ cd pace # create a conda environment for pace conda create -y --name my_name python=3.8 -# enter the environment and update it +# enter the environment conda activate my_name -pip3 install --upgrade pip setuptools wheel -# install the Pace dependencies, GT4Py, and Pace -pip3 install -r requirements_dev.txt -c constraints.txt +# install Pace dependencies and its dependencies +pip3 install .[test] diff --git a/examples/build_scripts/build_gaea_c5_gcc.sh b/examples/build_scripts/build_gaea_c5_gcc.sh index 87bac83a..782ac5f6 100644 --- a/examples/build_scripts/build_gaea_c5_gcc.sh +++ b/examples/build_scripts/build_gaea_c5_gcc.sh @@ -28,9 +28,8 @@ cd pace # create a conda environment for pace conda create -y --name my_name python=3.11.7 -# enter the environment and update it +# enter the environment conda activate my_name -pip3 install --upgrade pip setuptools wheel -# install the Pace dependencies, GT4Py, and Pace -pip3 install -r requirements_dev.txt -c constraints.txt +# install Pace dependencies and its dependencies +pip3 install .[test] diff --git a/examples/build_scripts/build_ppan.sh b/examples/build_scripts/build_ppan.sh index d6bf1bbd..ef88d081 100644 --- a/examples/build_scripts/build_ppan.sh +++ b/examples/build_scripts/build_ppan.sh @@ -24,12 +24,11 @@ cd $PACE_DIR # create a conda environment with cartopy and its dependencies installed conda create -c conda-forge -y --name $ENVIRONMENT_NAME python=3.8 matplotlib==3.5.2 cartopy==0.18.0 -# enter the environment and update it +# enter the environment conda activate $ENVIRONMENT_NAME -pip3 install --upgrade --no-cache-dir pip setuptools wheel -# install the Pace dependencies, GT4Py, and Pace -pip3 install --no-cache-dir -r requirements_dev.txt -c constraints.txt +# install Pace dependencies and its dependencies +pip3 install --no-cache-dir .[test] # clone fv3net git clone https://github.com/ai2cm/fv3net.git $FV3NET_DIR diff --git a/examples/build_scripts/build_ppan_intel.sh b/examples/build_scripts/build_ppan_intel.sh index c14dad78..f3ee3fdd 100644 --- a/examples/build_scripts/build_ppan_intel.sh +++ b/examples/build_scripts/build_ppan_intel.sh @@ -31,12 +31,11 @@ cd $PACE_DIR # create a conda environment with cartopy and its dependencies installed conda create -c conda-forge -y --name $ENVIRONMENT_NAME python=3.11.7 matplotlib==3.5.2 cartopy==0.18.0 -# enter the environment and update it +# enter the environment conda activate $ENVIRONMENT_NAME -pip3 install --upgrade --no-cache-dir pip setuptools wheel -# install the Pace dependencies, GT4Py, and Pace -pip3 install --no-cache-dir -r requirements_dev.txt -c constraints.txt +# install Pace dependencies and its dependencies +pip3 install --no-cache-dir .[test] # clone fv3net git clone https://github.com/ai2cm/fv3net.git $FV3NET_DIR diff --git a/examples/create_venv.sh b/examples/create_venv.sh index 312932f1..f523ae25 100755 --- a/examples/create_venv.sh +++ b/examples/create_venv.sh @@ -10,10 +10,9 @@ python3 -m venv venv . venv/bin/activate rundir=$(pwd) -cd ${SCRIPT_DIR}/../../ +cd ${SCRIPT_DIR}/../ -pip3 install --upgrade setuptools wheel -pip3 install -r requirements_dev.txt -c constraints.txt +pip install -e .[dev] deactivate cd $rundir diff --git a/examples/generate_eta_files.py b/examples/generate_eta_files.py index 1fb4d5ee..78f7cf34 100755 --- a/examples/generate_eta_files.py +++ b/examples/generate_eta_files.py @@ -1,3 +1,6 @@ +import sys +from pathlib import Path + import numpy as np import xarray as xr @@ -6,11 +9,18 @@ This notebook uses the python xarray module to create an eta_file containing ak and bk coefficients for km=79 and km=91. The coefficients are written out to -eta79.nc and eta91.nc netcdf files respectively +`eta79.nc` and `eta91.nc` netcdf files respectively in the +given folder (defaults to `./` if not provided). -To run this script: `python3 ./generate_eta_files.py` +To run this script: `python3 ./generate_eta_files.py ` """ +folder = Path("." if len(sys.argv) < 2 else sys.argv[1]) +if not folder.exists(): + raise ValueError(f"Cannot open folder '{folder}'. Make sure it exists.") +if not folder.is_dir(): + raise ValueError(f"Expected '{folder}' to be a directory.") + # km = 79 ak = xr.DataArray( dims=["km1"], @@ -189,7 +199,7 @@ ), ) coefficients = xr.Dataset(data_vars={"ak": ak, "bk": bk}) -coefficients.to_netcdf("eta79.nc") +coefficients.to_netcdf(Path(folder) / "eta79.nc") # km = 91 @@ -394,6 +404,4 @@ ), ) coefficients = xr.Dataset(data_vars={"ak": ak, "bk": bk}) -coefficients.to_netcdf("eta91.nc") - -# km = +coefficients.to_netcdf(Path(folder) / "eta91.nc") diff --git a/pyproject.toml b/pyproject.toml index b76d062e..0ccea7b6 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,3 +1,3 @@ [tool.black] line-length = 88 -target_version = ['py36', 'py37', 'py38'] +target_version = ['py38'] diff --git a/requirements_dev.txt b/requirements_dev.txt deleted file mode 100644 index 89271475..00000000 --- a/requirements_dev.txt +++ /dev/null @@ -1,20 +0,0 @@ -pytest -pytest-subtests -pytest-regressions -pytest-profiling -pytest-cov -scipy -nbmake -mpi4py -xarray -zarr <3.0.0 -dask -netCDF4 -cftime -fv3config -f90nml -numpy --e NDSL --e pySHiELD --e pyFV3 --e . diff --git a/requirements_docs.txt b/requirements_docs.txt index 54bae3b4..a36d014b 100644 --- a/requirements_docs.txt +++ b/requirements_docs.txt @@ -1,3 +1,4 @@ +fv3config recommonmark sphinx sphinx-argparse diff --git a/requirements_lint.txt b/requirements_lint.txt deleted file mode 100644 index 416634f5..00000000 --- a/requirements_lint.txt +++ /dev/null @@ -1 +0,0 @@ -pre-commit diff --git a/setup.py b/setup.py index a095679b..ab282cb7 100644 --- a/setup.py +++ b/setup.py @@ -7,26 +7,42 @@ def local_pkg(name: str, relative_path: str) -> str: """Returns an absolute path to a local package.""" - path = f"{name} @ file://{Path(os.path.abspath(__file__)).parent / relative_path}" - return path + return f"{name} @ file://{Path(os.path.abspath(__file__)).parent / relative_path} " requirements: List[str] = [ - "ndsl", + local_pkg("NDSL", "NDSL"), + local_pkg("pyFV3", "pyFV3"), + local_pkg("pySHiELD", "pySHiELD"), "dacite", - "pyyaml", - "mpi4py", - "numpy", - "netCDF4", + "f90nml", + "numpy < 2.0.0", # numpy 2.x has breaking API changes "xarray", - "zarr", + "zarr < 3.0.0", # zarr 3.x has breaking API changes +] + +test_requirements = [ + "mpi4py", + "nbmake", + "pytest", ] +dev_requirements = [ + *test_requirements, + "pip-tools", # for pip-compile + "pre-commit", +] + +extras_require = { + "dev": dev_requirements, + "test": test_requirements, +} + setup( author="Allen Institute for AI", author_email="oliver.elbert@noaa.gov", - python_requires=">=3.8", + python_requires=">=3.8,<3.12", classifiers=[ "Development Status :: 2 - Pre-Alpha", "Intended Audience :: Developers", @@ -35,8 +51,11 @@ def local_pkg(name: str, relative_path: str) -> str: "Programming Language :: Python :: 3", "Programming Language :: Python :: 3.8", "Programming Language :: Python :: 3.9", + "Programming Language :: Python :: 3.10", + "Programming Language :: Python :: 3.11", ], install_requires=requirements, + extras_require=extras_require, name="pace", license="BSD license", packages=find_namespace_packages(include=["pace", "pace.*"]),