Skip to content

Commit

Permalink
Fix the cleanup order of intermediate products for tests that raise e…
Browse files Browse the repository at this point in the history
…rrors and ensure an error is not raised when cleaning up a replacement file that was never created

Change input of ConfigurerBase to buildfile
Change to using conda build with libmamba solver rather than boa (deprecated for rattler-build)
Remove pinning of visual studio compiler
Try running yggconfig in separate step for conda installations
  • Loading branch information
langmm committed May 29, 2024
1 parent 4436807 commit fba7a47
Show file tree
Hide file tree
Showing 12 changed files with 65 additions and 240 deletions.
15 changes: 15 additions & 0 deletions .github/workflows/test-install.yml
Original file line number Diff line number Diff line change
Expand Up @@ -498,6 +498,9 @@ jobs:
name: (CONDA) Install dependencies & package from existing build (re-attempt)
run: python utils/setup_test_env.py install ${{ matrix.install-method }} --without-build
--use-mamba
- if: matrix.install-method == 'conda' || matrix.install-method == 'mamba'
name: (CONDA) Configure
run: yggconfig
- if: (matrix.install-method == 'conda' || matrix.install-method == 'mamba') &&
runner.os == 'macOS'
name: (MACOS,CONDA) Set allow_multiple_omp config
Expand Down Expand Up @@ -896,6 +899,9 @@ jobs:
name: (CONDA) Install dependencies & package from existing build (re-attempt)
run: python utils/setup_test_env.py install ${{ matrix.install-method }} --without-build
--use-mamba
- if: matrix.install-method == 'conda' || matrix.install-method == 'mamba'
name: (CONDA) Configure
run: yggconfig
- if: (matrix.install-method == 'conda' || matrix.install-method == 'mamba') &&
runner.os == 'macOS'
name: (MACOS,CONDA) Set allow_multiple_omp config
Expand Down Expand Up @@ -1270,6 +1276,9 @@ jobs:
name: (CONDA) Install dependencies & package from existing build (re-attempt)
run: python utils/setup_test_env.py install ${{ matrix.install-method }} --without-build
--use-mamba
- if: matrix.install-method == 'conda' || matrix.install-method == 'mamba'
name: (CONDA) Configure
run: yggconfig
- if: (matrix.install-method == 'conda' || matrix.install-method == 'mamba') &&
runner.os == 'macOS'
name: (MACOS,CONDA) Set allow_multiple_omp config
Expand Down Expand Up @@ -1625,6 +1634,9 @@ jobs:
name: (CONDA) Install dependencies & package from existing build (re-attempt)
run: python utils/setup_test_env.py install ${{ matrix.install-method }} --without-build
--use-mamba
- if: matrix.install-method == 'conda' || matrix.install-method == 'mamba'
name: (CONDA) Configure
run: yggconfig
- if: (matrix.install-method == 'conda' || matrix.install-method == 'mamba') &&
runner.os == 'macOS'
name: (MACOS,CONDA) Set allow_multiple_omp config
Expand Down Expand Up @@ -1979,6 +1991,9 @@ jobs:
name: (CONDA) Install dependencies & package from existing build (re-attempt)
run: python utils/setup_test_env.py install ${{ matrix.install-method }} --without-build
--use-mamba
- if: matrix.install-method == 'conda' || matrix.install-method == 'mamba'
name: (CONDA) Configure
run: yggconfig
- if: (matrix.install-method == 'conda' || matrix.install-method == 'mamba') &&
runner.os == 'macOS'
name: (MACOS,CONDA) Set allow_multiple_omp config
Expand Down
1 change: 0 additions & 1 deletion recipe/meta.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ requirements:
- python-build
- scikit-build-core
- setuptools_scm
- vs2019_win-64 # [win]
- {{ compiler('c') }}
- {{ compiler('cxx') }}
host:
Expand Down
18 changes: 18 additions & 0 deletions tests/drivers/test_CMakeModelDriver.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,29 +43,47 @@ def test_CMakeModelDriver_no_C_library(scripts): # pragma: windows
def test_CMakeModelDriver_error_cmake(scripts):
r"""Test CMakeModelDriver error for invalid cmake args."""
makedir, target = os.path.split(scripts['cmake'])
builddir = os.path.join(makedir, 'build')
assert not os.path.isfile(builddir)
with pytest.raises(RuntimeError):
CMakeModelDriver('test', target,
sourcedir=makedir, configurer_flags='-P',
target_language='c',
overwrite=True, remove_products=True)
assert not os.path.isfile(builddir)


@pytest.mark.language('cmake')
def test_CMakeModelDriver_error_notarget(scripts):
r"""Test CMakeModelDriver error for invalid target."""
makedir, target = os.path.split(scripts['cmake'])
builddir = os.path.join(makedir, 'build')
assert not os.path.isfile(builddir)
with pytest.raises(RuntimeError):
CMakeModelDriver('test', 'invalid',
sourcedir=makedir, target_language='c',
overwrite=True, remove_products=True)
assert not os.path.isfile(builddir)


@pytest.mark.language('cmake')
def test_CMakeModelDriver_error_nofile():
r"""Test CMakeModelDriver error for missing CMakeLists.txt."""
sourcedir = os.path.dirname(__file__)
working_dir = sourcedir
builddir = os.path.join(sourcedir, 'invalid_build')
buildfile = os.path.join(sourcedir, 'CMakeLists.txt')
assert not os.path.isdir(builddir)
assert not os.path.isfile(buildfile)
with pytest.raises(RuntimeError):
CMakeModelDriver('test', 'invalid', target_language='c',
buildfile=buildfile,
sourcedir=sourcedir,
builddir=os.path.basename(builddir),
working_dir=working_dir,
overwrite=True, remove_products=True)
assert not os.path.isdir(builddir)
assert not os.path.isfile(buildfile)


class TestCMakeModelDriver(base_class):
Expand Down
2 changes: 0 additions & 2 deletions tests/test_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -228,8 +228,6 @@ def test_find_all():
# Multiple files
mdir, mpat, mans = make_temp_multiple()
mout = tools.find_all(mpat, mdir)
print(mout)
print(mans)
assert isinstance(mout, list)
assert mout == mans

Expand Down
10 changes: 0 additions & 10 deletions utils/requirements/requirements.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,16 +47,6 @@
}
}
},
{
"vs2019_win-64": {
"os": "win",
"method": "conda_recipe",
"flags": {
"build": true,
"build_only": true
}
}
},
{
"cmake>=3.16": {
"method": "conda_recipe",
Expand Down
6 changes: 0 additions & 6 deletions utils/requirements/requirements.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,6 @@ general:
flags:
build: True
build_only: True
- vs2019_win-64:
os: win
method: conda_recipe
flags:
build: True
build_only: True
- cmake>=3.16:
method: conda_recipe
flags:
Expand Down
27 changes: 16 additions & 11 deletions utils/setup_test_env.py
Original file line number Diff line number Diff line change
Expand Up @@ -1176,15 +1176,17 @@ def build_conda_recipe(recipe='recipe', param=None,
build_flags = ''
else:
build_flags = '-q'
# if param.use_mamba:
# conda_build = f"{CONDA_CMD} mambabuild"
# build_pkgs = ["boa"]
# # if _is_win and _on_gha:
# # build_pkgs.append("\"conda-build<3.23.0\"")
# build_flags += ' -c conda-forge'
# else:
conda_build = f"{CONDA_CMD} build"
build_pkgs = ["conda-build", "conda-verify"]
if param.use_mamba:
conda_build = f"{CONDA_CMD} mambabuild"
build_pkgs = ["boa"]
# if _is_win and _on_gha:
# build_pkgs.append("\"conda-build<3.23.0\"")
build_flags += ' -c conda-forge'
else:
conda_build = f"{CONDA_CMD} build"
build_pkgs = ["conda-build", "conda-verify"]
build_flags += ' --solver=libmamba'
# Must always build in base to avoid errors (and don't change the
# version of Python used in the environment)
# https://github.com/conda/conda/issues/9124
Expand Down Expand Up @@ -1737,12 +1739,15 @@ def install_pkg(method, param=None, without_build=False,
f"cd {_pkg_dir}",
f"{param.python_cmd} -m pip install{flags} {src}",
f"cd {os.getcwd()}"]
if param.method != 'conda':
cmds += config_pkg(param=param, return_commands=True,
allow_missing=False)
if return_commands:
# cmds += config_pkg(param=param, return_commands=True,
# allow_missing=False)
return cmds
call_script(cmds, param=param)
config_pkg(param=param, allow_missing=False, use_shell=True)
env_vars = {k: os.environ.get(k, None) for k in ['CC', 'CXX', 'CPP']}
print(f"AFTER INSTALL: {env_vars}")
# config_pkg(param=param, allow_missing=False, use_shell=True)


def verify_pkg(install_opts=None):
Expand Down
3 changes: 3 additions & 0 deletions utils/test-install-base.yml
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,9 @@ jobs:
- name: (CONDA) Install dependencies & package from existing build (re-attempt)
if: ${{ steps.conda_install.outcome == 'failure' && (matrix.install-method == 'conda' || matrix.install-method == 'mamba')}}
run: python utils/setup_test_env.py install ${{ matrix.install-method }} --without-build --use-mamba
- name: (CONDA) Configure
if: matrix.install-method == 'conda' || matrix.install-method == 'mamba'
run: yggconfig
- name: (MACOS,CONDA) Set allow_multiple_omp config
if: (matrix.install-method == 'conda' || matrix.install-method == 'mamba') && runner.os == 'macOS'
run: |
Expand Down
3 changes: 3 additions & 0 deletions yggdrasil/drivers/BuildModelDriver.py
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,9 @@ def parse_arguments(self, args, **kwargs):
if self.is_valid_buildfile(y):
self.buildfile = y
break
if not os.path.isabs(self.buildfile):
self.buildfile = os.path.normpath(
os.path.join(self.sourcedir, self.buildfile))
# Build directory
if self.builddir is None:
self.builddir = self.builddir_base
Expand Down
Loading

0 comments on commit fba7a47

Please sign in to comment.