Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
82578be
Trying testing of CI
fmalatino May 5, 2025
b6d5ae9
Adding python -m to run_tests.sh
fmalatino May 5, 2025
0f98b47
Missed one python -m
fmalatino May 5, 2025
85bdaa0
Debug print of install.log
fmalatino May 5, 2025
ecf1763
Linting
fmalatino May 5, 2025
7fe2fdf
Debugging workflow; cat of config.log in cFMS
fmalatino May 6, 2025
ab75d92
Debugging; looking at config.log in FMS
fmalatino May 6, 2025
b4cb06a
Added diffutils install to workflow
fmalatino May 6, 2025
652ce3a
Adding installs to Ubuntu base in lint workflow
fmalatino May 6, 2025
56182d1
Added nc-configs to compiler flags in compile_c_libs.sh
fmalatino May 6, 2025
ae81e8a
Adding compiler flags for unit test workflow
fmalatino May 6, 2025
9e139d2
Making the install editable
fmalatino May 6, 2025
ab9ebb8
Compiling cFMS into pyfms
fmalatino May 7, 2025
2412501
Trying with just one test
fmalatino May 7, 2025
a82ea4d
Merging in main
fmalatino May 7, 2025
408f5ec
Trying to run all tests and linting
fmalatino May 7, 2025
ec4dcdf
Running just test_build and test_init
fmalatino May 7, 2025
81e9821
Adding in test_define_domains
fmalatino May 7, 2025
47aa10d
Printing contents of install dir
fmalatino May 7, 2025
392a0f6
Seeing if adding editable install after regular install exposes share…
fmalatino May 7, 2025
145627d
Using oversubscribe
fmalatino May 7, 2025
315fcd8
Trying all tests
fmalatino May 7, 2025
d3b2195
needed more oversubscribes
fmalatino May 7, 2025
8bed8de
Debug CI: fixing path specified in MANIFEST.in
fmalatino May 9, 2025
35013aa
Updating cFMS to latest commit
fmalatino May 19, 2025
b2c9751
Trying with 2 pip install calls
fmalatino May 19, 2025
acf1909
Updating compile script to reflect changes in cFMS
fmalatino May 19, 2025
5dcad38
Custom build_py instead of custom install in setup.py
fmalatino May 20, 2025
1d184e1
Lint
fmalatino May 20, 2025
37d49d4
Removing comment
fmalatino May 20, 2025
b43ee27
Adding pyproject.toml to be inline with latest setuptools
fmalatino May 20, 2025
e0b60c8
Linting
fmalatino May 20, 2025
a185d7f
Using overriding build instead of build_py in setup.py
fmalatino May 24, 2025
e305274
Merge main
fmalatino May 29, 2025
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
2 changes: 1 addition & 1 deletion .github/workflows/lint.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:
python-version: '3.11.7'
- name: Install OpenMPI for gt4py
run: |
sudo apt-get install libopenmpi-dev
sudo apt-get install libopenmpi-dev netcdf-bin libnetcdf-dev libnetcdff-dev nco libyaml-dev diffutils
- name: Install Python packages
run: |
python -m pip install --upgrade pip setuptools wheel
Expand Down
29 changes: 29 additions & 0 deletions .github/workflows/unit_tests.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: "pyfms unit tests"
on: [push, pull_request]

# cancel running jobs if theres a newer push
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
pyfms_unit_tests:
runs-on: ubuntu-latest
steps:
- name: Checkout out hash that triggered CI
uses: actions/checkout@v4
with:
submodules: 'recursive'
- name: Step Python
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 netcdf-bin libnetcdf-dev libnetcdff-dev nco libyaml-dev diffutils
- name: install packages
run: |
pip install .[test]
- name: run tests
run: |
./run_tests.sh
1 change: 1 addition & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
global-include cLIBFMS/lib/libcFMS.*
15 changes: 9 additions & 6 deletions compile_c_libs.sh
Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@
#!/bin/bash

curr_dir=$PWD/cFMS
install_fms=$curr_dir/FMS/LIBFMS
set -xe

pyfms_dir=$PWD/pyfms
cfms_dir=$PWD/cFMS
install_fms=$cfms_dir/FMS/LIBFMS

export FC=mpif90
export CC=mpicc

cd $curr_dir/FMS
cd $cfms_dir/FMS
autoreconf -iv
export FCFLAGS="$FCFLAGS -fPIC"
export CFLAGS="$CFLAGS -fPIC"
export FCFLAGS="$FCFLAGS `nf-config --fflags` -fPIC"
export CFLAGS="$CFLAGS `nc-config --cflags` -fPIC"
./configure --enable-portable-kinds --with-yaml --prefix=$install_fms
make install

Expand All @@ -21,5 +24,5 @@ export CFLAGS="$CFLAGS -I$install_fms/include"
export LDFLAGS="$LDFLAGS -lFMS -L$install_fms/lib"

autoreconf -iv
./configure --prefix=$curr_dir/cLIBFMS
./configure --with-fms=$install_fms --prefix=$pyfms_dir/cLIBFMS
make install
4 changes: 2 additions & 2 deletions pyfms/cfms.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
import pyfms


_libpath = os.path.dirname(__file__) + "/../cFMS/cLIBFMS/lib/libcFMS.so"
_lib = ctypes.cdll.LoadLibrary(_libpath)
_libpath: str = os.path.dirname(__file__) + "/cLIBFMS/lib/libcFMS.so"
_lib: type[ctypes.CDLL] = ctypes.cdll.LoadLibrary(_libpath)


def init(libpath: str = None):
Expand Down
3 changes: 3 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[build-system]
requires = ["setuptools >= 64"]
build-backend = "setuptools.build_meta"
22 changes: 11 additions & 11 deletions run_tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,39 +14,39 @@ function run_test() {
eval $1
if [ $? -ne 0 ] ; then exit 1 ; fi }

run_test "pytest tests/test_build.py"
run_test "python -m pytest tests/test_build.py"

test="tests/test_fms.py"
create_input $test
run_test "pytest -m parallel $test"
run_test "python -m pytest -m parallel $test"
remove_input $test

test="tests/py_mpp/test_define_domains.py"
create_input $test
run_test "mpirun -n 8 python -m pytest -m 'parallel' $test"
run_test "mpirun -n 8 --oversubscribe python -m pytest -m 'parallel' $test"
remove_input $test

test="tests/py_mpp/test_getset_domains.py"
create_input $test
run_test "mpirun -n 4 python -m pytest -m 'parallel' tests/py_mpp/test_getset_domains.py"
run_test "mpirun -n 4 --oversubscribe python -m pytest -m 'parallel' tests/py_mpp/test_getset_domains.py"
remove_input $test

test="tests/py_mpp/test_update_domains.py"
create_input $test
run_test "mpirun -n 4 python -m pytest -m 'parallel' tests/py_mpp/test_update_domains.py"
run_test "mpirun -n 4 --oversubscribe python -m pytest -m 'parallel' tests/py_mpp/test_update_domains.py"
remove_input $test

run_test "pytest tests/py_horiz_interp"
run_test "python -m pytest tests/py_horiz_interp"

run_test "pytest tests/py_data_override/test_generate_files.py"
run_test "mpirun -n 6 python -m pytest -m 'parallel' tests/py_data_override/test_data_override.py"
run_test "python -m pytest tests/py_data_override/test_generate_files.py"
run_test "mpirun -n 6 --oversubscribe python -m pytest -m 'parallel' tests/py_data_override/test_data_override.py"
remove_input "tests/py_data_override/test_data_override.py"

run_test "pytest tests/py_diag_manager/test_generate_files.py"
run_test "python -m pytest tests/py_diag_manager/test_generate_files.py"
run_test "mpirun -n 1 python -m pytest tests/py_diag_manager/test_diag_manager.py"

pytest tests/utils/test_constants.py
run_test "python -m pytest tests/utils/test_constants.py"

pytest tests/test_init.py
run_test "python -m pytest tests/test_init.py"

rm -rf INPUT *logfile* *warnfile*
21 changes: 14 additions & 7 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,14 @@
from typing import List

from setuptools import find_namespace_packages, setup
from setuptools.command.install import install
from setuptools.command.build import build


class CustomInstall(install):
class CustomBuild(build):
def run(self):
# subprocess.run(["./compile_c_libs.sh"], capture_output=True, text=True)
with open("install.log", "w") as f:
subprocess.run(["./compile_c_libs.sh"], stdout=f)
install.run(self)
build.run(self)


test_requirements = ["pytest", "pytest-subtests", "coverage"]
Expand All @@ -21,7 +20,15 @@ def run(self):
"develop": develop_requirements,
}

requirements: List[str] = ["dacite", "h5netcdf", "numpy", "pyyaml", "mpi4py", "xarray"]
requirements: List[str] = [
"dacite",
"h5netcdf",
"numpy",
"pyyaml",
"mpi4py",
"xarray",
"netcdf4",
]

setup(
author="NOAA/GFDL",
Expand All @@ -38,9 +45,9 @@ def run(self):
name="pyfms",
license="",
packages=find_namespace_packages(include=["pyfms", "pyfms.*"]),
cmdclass={"install": CustomInstall},
cmdclass={"build": CustomBuild},
include_package_data=True,
url="https://github.com/fmalatino/pyFMS.git",
version="2024.12.0",
version="2024.02.0",
zip_safe=False,
)
4 changes: 3 additions & 1 deletion tests/test_build.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,6 @@


def test_shared_object_exists():
assert os.path.exists(os.path.dirname(__file__) + "/../cFMS/cLIBFMS/lib/libcFMS.so")
assert os.path.exists(
os.path.dirname(__file__) + "/../pyfms/cLIBFMS/lib/libcFMS.so"
)
6 changes: 6 additions & 0 deletions tests/test_init.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
import os
import sys

import pytest

import pyfms


curr_dir = os.path.dirname(os.path.abspath(__file__))
par_dir = os.path.dirname(curr_dir)


def test_write_module():
myfile = open("module1.py", "w")
myfile.write(
Expand All @@ -28,6 +33,7 @@ def test_share_same_library():


def test_load_library_same_object():
sys.path.append(par_dir)

"""
Test to ensure the ctypes CDLL Library object
Expand Down