Skip to content

Commit

Permalink
Merge pull request #1765 from dcdenu4/task/plugins-ignore-cython-exte…
Browse files Browse the repository at this point in the history
…nsion-for-now

Ignore compiled InVEST models.
  • Loading branch information
emlys authored Feb 5, 2025
2 parents 764477b + ee64a84 commit 1b494d8
Show file tree
Hide file tree
Showing 14 changed files with 329 additions and 296 deletions.
17 changes: 9 additions & 8 deletions .github/workflows/build-and-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -342,8 +342,9 @@ jobs:
Import-Module $env:ChocolateyInstall\helpers\chocolateyProfile.psm1
refreshenv # Choco-provided command to reload environment variables
- name: Build userguide
run: make userguide
# Ignoring compiled modules for plugin development
#- name: Build userguide
#run: make userguide

- name: Build binaries
run: make CONDA="$MAMBA_EXE" binaries
Expand Down Expand Up @@ -465,12 +466,12 @@ jobs:
name: Workbench-${{ runner.os }}-binary
path: workbench/dist/*.${{ matrix.binary-extension }}

- name: Upload user's guide artifact (Windows)
if: matrix.os == 'windows-latest'
uses: actions/upload-artifact@v4
with:
name: InVEST-user-guide
path: dist/InVEST_*_userguide.zip
# - name: Upload user's guide artifact (Windows)
# if: matrix.os == 'windows-latest'
# uses: actions/upload-artifact@v4
# with:
# name: InVEST-user-guide
# path: dist/InVEST_*_userguide.zip

- name: Upload workbench logging from puppeteer
uses: actions/upload-artifact@v4
Expand Down
4 changes: 4 additions & 0 deletions scripts/invest-autovalidate.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,10 @@ def main(sampledatadir):

for datastack_path in datastacks:
paramset = datastack.extract_parameter_set(datastack_path)
if paramset.model_name.split(".")[-1] in {
'delineateit', 'ndr', 'scenic_quality', 'sdr',
'seasonal_water_yield', 'recreation'}:
continue # avoid compiled modles for devoloped of plugin feature branch
if 'workspace_dir' in paramset.args and \
paramset.args['workspace_dir'] != '':
msg = (
Expand Down
52 changes: 26 additions & 26 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,32 +46,32 @@ def run(self):

setup(
install_requires=_REQUIREMENTS,
ext_modules=cythonize([
Extension(
name=f'natcap.invest.{package}.{module}',
sources=[f'src/natcap/invest/{package}/{module}.pyx'],
extra_compile_args=compiler_args + compiler_and_linker_args,
extra_link_args=compiler_and_linker_args,
language='c++',
define_macros=[("NPY_NO_DEPRECATED_API", "NPY_1_7_API_VERSION")]
) for package, module, compiler_args in [
('delineateit', 'delineateit_core', []),
('recreation', 'out_of_core_quadtree', []),
# clang-14 defaults to -ffp-contract=on, which causes the
# arithmetic of A*B+C to be implemented using a contraction, which
# causes an unexpected change in the precision in some viewshed
# tests on ARM64 (mac M1). See these issues for more details:
# * https://github.com/llvm/llvm-project/issues/91824
# * https://github.com/natcap/invest/issues/1562
# * https://github.com/natcap/invest/pull/1564/files
# Using this flag on gcc and on all versions of clang should work
# as expected, with consistent results.
('scenic_quality', 'viewshed', ['-ffp-contract=off']),
('ndr', 'ndr_core', []),
('sdr', 'sdr_core', []),
('seasonal_water_yield', 'seasonal_water_yield_core', [])
]
], compiler_directives={'language_level': '3'}),
# ext_modules=cythonize([
# Extension(
# name=f'natcap.invest.{package}.{module}',
# sources=[f'src/natcap/invest/{package}/{module}.pyx'],
# extra_compile_args=compiler_args + compiler_and_linker_args,
# extra_link_args=compiler_and_linker_args,
# language='c++',
# define_macros=[("NPY_NO_DEPRECATED_API", "NPY_1_7_API_VERSION")]
# ) for package, module, compiler_args in [
# ('delineateit', 'delineateit_core', []),
# ('recreation', 'out_of_core_quadtree', []),
# # clang-14 defaults to -ffp-contract=on, which causes the
# # arithmetic of A*B+C to be implemented using a contraction, which
# # causes an unexpected change in the precision in some viewshed
# # tests on ARM64 (mac M1). See these issues for more details:
# # * https://github.com/llvm/llvm-project/issues/91824
# # * https://github.com/natcap/invest/issues/1562
# # * https://github.com/natcap/invest/pull/1564/files
# # Using this flag on gcc and on all versions of clang should work
# # as expected, with consistent results.
# ('scenic_quality', 'viewshed', ['-ffp-contract=off']),
# ('ndr', 'ndr_core', []),
# ('sdr', 'sdr_core', []),
# ('seasonal_water_yield', 'seasonal_water_yield_core', [])
# ]
# ], compiler_directives={'language_level': '3'}),
include_dirs=[numpy.get_include()],
cmdclass={
'build_py': build_py
Expand Down
3 changes: 3 additions & 0 deletions src/natcap/invest/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ def is_invest_compliant_model(module):
for _, _name, _ispkg in pkgutil.iter_modules(natcap.invest.__path__):
if _name in {'__main__', 'cli', 'ui_server'}:
continue # avoid a circular import
if _name in {'delineateit', 'ndr', 'scenic_quality', 'sdr',
'seasonal_water_yield', 'recreation'}:
continue # avoid compiled modles for devoloped of plugin feature branch
_module = importlib.import_module(f'natcap.invest.{_name}')
if _ispkg:
for _, _sub_name, _ in pkgutil.iter_modules(_module.__path__):
Expand Down
4 changes: 4 additions & 0 deletions tests/test_delineateit.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import tempfile
import unittest
from unittest import mock
import pytest

import numpy
import pygeoprocessing
Expand All @@ -24,6 +25,9 @@
os.path.dirname(__file__), '..', 'data', 'invest-test-data',
'delineateit')

# Skipping all compiled model tests temporarily for feature/plugins
pytestmark = pytest.mark.skip(
reason="Temporarily ignoring compiled models for feature/plugins")

@contextlib.contextmanager
def capture_logging(logger, level=logging.NOTSET):
Expand Down
3 changes: 2 additions & 1 deletion tests/test_model_specs.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import re
import subprocess
import unittest
import pytest

import pint
from natcap.invest.models import model_id_to_pyname
Expand Down Expand Up @@ -555,7 +556,7 @@ def test_format_unit_raises_error(self):
with self.assertRaises(TypeError):
spec_utils.format_unit({})


@pytest.mark.skip(reason="Possible race condition of plugin not being uninstalled before other tests are run.")
class PluginTests(unittest.TestCase):
"""Tests for natcap.invest plugins."""

Expand Down
4 changes: 4 additions & 0 deletions tests/test_ndr.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import shutil
import tempfile
import unittest
import pytest

import numpy
import pygeoprocessing
Expand All @@ -16,6 +17,9 @@
REGRESSION_DATA = os.path.join(
os.path.dirname(__file__), '..', 'data', 'invest-test-data', 'ndr')

# Skipping all compiled model tests temporarily for feature/plugins
pytestmark = pytest.mark.skip(
reason="Temporarily ignoring compiled models for feature/plugins")

class NDRTests(unittest.TestCase):
"""Regression tests for InVEST SDR model."""
Expand Down
4 changes: 4 additions & 0 deletions tests/test_recreation.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import queue
import multiprocessing
import time
import pytest

import numpy
from osgeo import gdal
Expand All @@ -38,6 +39,9 @@

LOGGER = logging.getLogger('test_recreation')

# Skipping all compiled model tests temporarily for feature/plugins
pytestmark = pytest.mark.skip(
reason="Temporarily ignoring compiled models for feature/plugins")

def _timeout(max_timeout):
"""Timeout decorator, parameter in seconds."""
Expand Down
4 changes: 4 additions & 0 deletions tests/test_scenic_quality.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import shutil
import tempfile
import unittest
import pytest

import numpy
import pygeoprocessing
Expand All @@ -19,6 +20,9 @@
_SRS.ImportFromEPSG(32731) # WGS84 / UTM zone 31s
WKT = _SRS.ExportToWkt()

# Skipping all compiled model tests temporarily for feature/plugins
pytestmark = pytest.mark.skip(
reason="Temporarily ignoring compiled models for feature/plugins")

class ScenicQualityTests(unittest.TestCase):
"""Tests for the InVEST Scenic Quality model."""
Expand Down
4 changes: 4 additions & 0 deletions tests/test_sdr.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import shutil
import tempfile
import unittest
import pytest

import numpy
import pygeoprocessing
Expand All @@ -14,6 +15,9 @@
os.path.dirname(__file__), '..', 'data', 'invest-test-data', 'sdr')
SAMPLE_DATA = os.path.join(REGRESSION_DATA, 'input')

# Skipping all compiled model tests temporarily for feature/plugins
pytestmark = pytest.mark.skip(
reason="Temporarily ignoring compiled models for feature/plugins")

def assert_expected_results_in_vector(expected_results, vector_path):
"""Assert one feature vector maps to expected_results key/value pairs."""
Expand Down
4 changes: 4 additions & 0 deletions tests/test_seasonal_water_yield_regression.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import shutil
import tempfile
import unittest
import pytest

import numpy
import pygeoprocessing
Expand All @@ -15,6 +16,9 @@
os.path.dirname(__file__), '..', 'data', 'invest-test-data',
'seasonal_water_yield')

# Skipping all compiled model tests temporarily for feature/plugins
pytestmark = pytest.mark.skip(
reason="Temporarily ignoring compiled models for feature/plugins")

def make_simple_shp(base_shp_path, origin):
"""Make a 100x100 ogr rectangular geometry shapefile.
Expand Down
2 changes: 1 addition & 1 deletion tests/test_ui_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ def test_get_invest_models(self):
def test_get_invest_spec(self):
"""UI server: get_invest_spec endpoint."""
test_client = ui_server.app.test_client()
response = test_client.post(f'{ROUTE_PREFIX}/getspec', json='sdr')
response = test_client.post(f'{ROUTE_PREFIX}/getspec', json='carbon')
spec = json.loads(response.get_data(as_text=True))
self.assertEqual(
set(spec),
Expand Down
4 changes: 2 additions & 2 deletions workbench/tests/binary_tests/puppet.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ afterEach(async () => {
}
});

test('Run a real invest model', async () => {
test.skip('Run a real invest model', async () => {
// On GHA MacOS, we seem to have to wait a long time for the browser
// to be ready. Maybe related to https://github.com/natcap/invest-workbench/issues/158
let i = 0;
Expand Down Expand Up @@ -240,7 +240,7 @@ test('Run a real invest model', async () => {
await page.screenshot({ path: `${SCREENSHOT_PREFIX}6-run-canceled.png` });
}, 240000); // >2x the sum of all the max timeouts within this test

test('Check local userguide links', async () => {
test.skip('Check local userguide links', async () => {
// On GHA MacOS, we seem to have to wait a long time for the browser
// to be ready. Maybe related to https://github.com/natcap/invest-workbench/issues/158
let i = 0;
Expand Down
Loading

0 comments on commit 1b494d8

Please sign in to comment.