Skip to content

Commit

Permalink
#20 Add conda variants for cells example
Browse files Browse the repository at this point in the history
  • Loading branch information
kwabenantim committed Nov 6, 2024
1 parent 1e82dc2 commit 659fca1
Show file tree
Hide file tree
Showing 13 changed files with 53 additions and 33 deletions.
22 changes: 11 additions & 11 deletions .github/workflows/test-cells-conda.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: test-cells
name: test-cells-conda

on:
workflow_dispatch:
Expand All @@ -7,7 +7,7 @@ on:
- "**"

jobs:
test-cells:
test-cells-conda:
runs-on: ubuntu-latest

strategy:
Expand All @@ -16,7 +16,7 @@ jobs:
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12", "3.13"]

concurrency:
group: test-cells-${{ github.ref }}-${{ matrix.python-version }}
group: test-cells-conda-${{ github.ref }}-${{ matrix.python-version }}
cancel-in-progress: true

defaults:
Expand All @@ -39,7 +39,6 @@ jobs:
use-mamba: true
miniforge-version: latest
python-version: ${{ matrix.python-version }}
activate-environment: test_cells
channels: conda-forge

- name: Install cppwg
Expand All @@ -48,8 +47,7 @@ jobs:
python -m pip install .
- name: Install requirements
run: |
mamba install --yes --file requirements.txt
run: mamba install --yes --file requirements.txt
working-directory: examples/cells

- name: Set config paths
Expand Down Expand Up @@ -78,14 +76,16 @@ jobs:
grep "Unknown class" build/cppwg.log
working-directory: examples/cells

- name: Install conda-build tools
run: mamba install boa conda-build conda-verify

- name: Build
run: conda build conda-recipe
working-directory: examples/cells
run: conda mambabuild recipe -m variants/python${{ matrix.python-version }}.yaml
working-directory: examples/cells/conda

- name: Install
run: conda install --use-local pycells
working-directory: examples/cells
run: mamba install --use-local pycells

- name: Test
run: python -m unittest discover -s tests
run: python -m unittest discover tests
working-directory: examples/cells
2 changes: 1 addition & 1 deletion .github/workflows/test-cells-ubuntu.yml
Original file line number Diff line number Diff line change
Expand Up @@ -64,5 +64,5 @@ jobs:
working-directory: examples/cells

- name: Test
run: python -m unittest discover -s tests
run: python -m unittest discover tests
working-directory: examples/cells
3 changes: 0 additions & 3 deletions examples/cells/conda-recipe/build.sh

This file was deleted.

8 changes: 8 additions & 0 deletions examples/cells/conda/recipe/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/bin/bash -ex

export CMAKE_PREFIX_PATH="$PREFIX;$CMAKE_PREFIX_PATH"
export PETSC_DIR="$PREFIX"
export PETSC_ARCH=
export VTK_DIR="$PREFIX"

$PYTHON -m pip install -v --no-build-isolation .
Original file line number Diff line number Diff line change
Expand Up @@ -6,26 +6,20 @@ package:
version: {{ version }}

source:
path: ..
path: ../..

build:
number: {{ build }}

requirements:
build:
- cmake
- ninja
- pip
- python
- scikit-build
- setuptools

host:
- mpi4py
- mpich
- openmpi
- petsc
- petsc4py
- pip
- python
- scikit-build-core
- vtk

test:
Expand Down
2 changes: 2 additions & 0 deletions examples/cells/conda/variants/python3.10.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
python:
- 3.10.*
2 changes: 2 additions & 0 deletions examples/cells/conda/variants/python3.11.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
python:
- 3.11.*
2 changes: 2 additions & 0 deletions examples/cells/conda/variants/python3.12.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
python:
- 3.12.*
2 changes: 2 additions & 0 deletions examples/cells/conda/variants/python3.13.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
python:
- 3.13.*
2 changes: 2 additions & 0 deletions examples/cells/conda/variants/python3.8.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
python:
- 3.8.*
2 changes: 2 additions & 0 deletions examples/cells/conda/variants/python3.9.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
python:
- 3.9.*
2 changes: 1 addition & 1 deletion examples/cells/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
mpich
openmpi
mpi4py
petsc
petsc4py
Expand Down
23 changes: 16 additions & 7 deletions examples/cells/src/cpp/utils/PetscUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,11 @@ void PetscUtils::Initialise()
{
if (!PetscUtils::IsInitialised())
{
#if PETSC_VERSION_GE(3, 19, 0)
PetscInitialize(PETSC_NULLPTR, PETSC_NULLPTR, PETSC_NULLPTR, PETSC_NULLPTR);
#else
PetscInitialize(PETSC_NULL, PETSC_NULL, PETSC_NULL, PETSC_NULL);
#endif
}
}

Expand All @@ -27,7 +31,7 @@ int PetscUtils::GetSize()
{
if (!PetscUtils::IsInitialised())
{
return -1;
PetscUtils::Initialise();
}

PetscInt size;
Expand All @@ -39,7 +43,7 @@ int PetscUtils::GetRank()
{
if (!PetscUtils::IsInitialised())
{
return -1;
PetscUtils::Initialise();
}

PetscInt rank;
Expand All @@ -49,9 +53,14 @@ int PetscUtils::GetRank()

Vec PetscUtils::CreateVec(int size)
{
Vec vec;
VecCreate(PETSC_COMM_WORLD, &vec);
VecSetSizes(vec, PETSC_DECIDE, size);
VecSetType(vec, VECMPI);
return vec;
if (!PetscUtils::IsInitialised())
{
PetscUtils::Initialise();
}

Vec v;
VecCreate(PETSC_COMM_WORLD, &v);
VecSetSizes(v, PETSC_DECIDE, size);
VecSetFromOptions(v);
return v;
}

0 comments on commit 659fca1

Please sign in to comment.