Skip to content

Commit 506700a

Browse files
authored
Pixibuild (#82)
1 parent cd79d46 commit 506700a

16 files changed

+1146
-168
lines changed

.github/workflows/build_and_test.yaml

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -84,13 +84,8 @@ jobs:
8484
# ────────────────────────────────────────────────────────────────
8585
# Pytest checks
8686
# ────────────────────────────────────────────────────────────────
87-
- name: Install Pixi Python deps
88-
run: |
89-
pixi --version
90-
pixi install
91-
9287
- name: Run pytest checks on HDF5 output
93-
run: pixi run pytest
88+
run: pixi run -e dashboard pytest
9489

9590
- uses: actions/upload-artifact@v4
9691
if: failure()

.github/workflows/build_and_test_mac.yaml

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -88,13 +88,8 @@ jobs:
8888
# ────────────────────────────────────────────────────────────────
8989
# Pytest checks
9090
# ────────────────────────────────────────────────────────────────
91-
- name: Install Pixi Python deps
92-
run: |
93-
pixi --version
94-
pixi install
95-
9691
- name: Run pytest checks on HDF5 output
97-
run: pixi run pytest
92+
run: pixi run -e dashboard pytest
9893

9994
- uses: actions/upload-artifact@v4
10095
if: failure()

.github/workflows/pixi_build.yaml

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,10 @@ jobs:
1414
build:
1515
name: ${{ matrix.os }}
1616
runs-on: ${{ matrix.os }}
17-
env:
18-
FANS_BUILD_DIR: build
1917
strategy:
2018
fail-fast: false
2119
matrix:
22-
os: [macos-latest, ubuntu-latest]
20+
os: [ubuntu-latest]
2321
steps:
2422
- name: Checkout code
2523
uses: actions/checkout@v5
@@ -32,6 +30,12 @@ jobs:
3230
- name: Run pytest checks on HDF5 output
3331
run: pixi run test
3432

33+
- name: Upload test logs
34+
uses: actions/upload-artifact@v4
35+
with:
36+
name: test-logs
37+
path: test/*.log
38+
3539
- uses: actions/upload-artifact@v4
3640
if: failure()
3741
with:

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -210,3 +210,4 @@ test/input_files/**/*.json
210210
# pixi environments
211211
.pixi
212212
*.egg-info
213+
*.conda

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
## latest
44

5+
- Introduce pixi build workflow and conftest.py for pytest-fixture [#82](https://github.com/DataAnalyticsEngineering/FANS/pull/82)
6+
- Use dashboard environment for regular pytest [#81](https://github.com/DataAnalyticsEngineering/FANS/pull/81)
57
- Fix bug in J2 plasticity routine [#80](https://github.com/DataAnalyticsEngineering/FANS/pull/80)
68

79
## v0.4.2

pixi.lock

Lines changed: 1035 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pixi.toml

Lines changed: 41 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22
channels = ["conda-forge"]
33
name = "FANS"
44
platforms = ["linux-64", "osx-64", "osx-arm64"]
5+
preview = ["pixi-build"]
6+
7+
[dependencies]
8+
fans = { path = "." }
59

610
[feature.dashboard.dependencies]
711
python = ">=3.13.5,<3.14"
@@ -23,10 +27,44 @@ precommit = "pre-commit run --all-files"
2327
h52xdmf = { args = ["file"], cmd = "cd \"$INIT_CWD\" && python -m fans_dashboard.plotting.h52xdmf -t -v {{file}}" }
2428

2529
[tasks]
26-
test = {depends-on = [
27-
{ task = "pytest", environment = "dashboard" }, # Will be changed later with pixi-build
28-
]}
30+
test = { cmd = "pytest -v -s --from-pixi", cwd = "test/pytest", depends-on = ["test-fans"] }
31+
test-fans = { cmd = "./run_tests.sh -n {{n}}", args = [
32+
{ arg = "n", default = "2" }, # Number of threads
33+
], cwd = "test" }
2934

3035
[environments]
3136
default = {features = ["dashboard"]}
3237
dashboard = { features = ["dashboard"], no-default-feature = true }
38+
39+
################## Pixi build part
40+
41+
[package]
42+
name = "fans"
43+
version = "0.4.2"
44+
45+
[package.build]
46+
backend = { name = "pixi-build-cmake", version = "0.3.*" }
47+
48+
[package.build.config]
49+
extra-args = [
50+
"-DFANS_LIBRARY_FOR_MICRO_MANAGER=ON",
51+
]
52+
53+
[workspace.target.osx-arm64.build-variants]
54+
cxx_compiler_version = ["18"]
55+
56+
[workspace.target.linux-64.build-variants]
57+
cxx_compiler = ["clangxx"]
58+
cxx_compiler_version = ["18"]
59+
60+
[package.build-dependencies]
61+
cmake = "==4.0.3"
62+
pybind11 = "*"
63+
pkg-config = "*"
64+
ninja = "1.13.*"
65+
66+
[package.host-dependencies]
67+
hdf5 = { version = "*", build = "* mpi_openmpi*" }
68+
fftw = { version = "*", build = "* mpi_openmpi*" } # works
69+
openmpi-mpicxx = "*"
70+
eigen = "*"

test/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ This will run all test cases and generate result files in `build/test/`.
3131
After running the tests, the results are verified using pytest. We recommend running pytest via a pre-configured Pixi task,
3232

3333
```bash
34-
pixi run pytest
34+
pixi run -e dashboard pytest
3535
```
3636

3737
Note: The validation tests expect result files to be in `build/test/` directory, so make sure to run the tests first.

test/pytest/conftest.py

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
import pytest
2+
import os
3+
4+
5+
def pytest_addoption(parser):
6+
parser.addoption(
7+
"--from-pixi",
8+
action="store_true",
9+
default=False,
10+
help="Run tests from pixi task.",
11+
)
12+
13+
14+
@pytest.fixture(
15+
params=[
16+
"test_J2Plasticity",
17+
"test_LinearElastic",
18+
"test_LinearThermal",
19+
"test_PseudoPlastic",
20+
]
21+
)
22+
def test_files(request):
23+
json_base_dir = os.path.join(
24+
os.path.dirname(os.path.abspath(__file__)), "../input_files/"
25+
)
26+
# Determine the HDF5 base directory based on the --from-pixi option
27+
# if run from pixi, use output directory; otherwise, use build/test directory, as it is the one used by ctest
28+
if request.config.getoption("--from-pixi"):
29+
h5_base_dir = os.path.join(
30+
os.path.dirname(os.path.abspath(__file__)), "../output"
31+
)
32+
else:
33+
h5_base_dir = os.path.join(
34+
os.path.dirname(os.path.abspath(__file__)), "../../build/test/"
35+
)
36+
37+
json_path = os.path.join(json_base_dir, f"{request.param}.json")
38+
h5_path = os.path.join(h5_base_dir, f"{request.param}.h5")
39+
40+
if os.path.exists(json_path) and os.path.exists(h5_path):
41+
return json_path, h5_path
42+
43+
assert False, f"Required test files not found: {json_path} or {h5_path}"

test/pytest/test_displacement_averaging.py

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -5,30 +5,6 @@
55
from fans_dashboard.core.utils import identify_hierarchy, extract_and_organize_data
66

77

8-
@pytest.fixture(
9-
params=[
10-
"test_J2Plasticity",
11-
"test_LinearElastic",
12-
"test_LinearThermal",
13-
"test_PseudoPlastic",
14-
]
15-
)
16-
def test_files(request):
17-
json_base_dir = os.path.join(
18-
os.path.dirname(os.path.abspath(__file__)), "../input_files/"
19-
)
20-
h5_base_dir = os.path.join(
21-
os.path.dirname(os.path.abspath(__file__)), "../../build/test/"
22-
)
23-
24-
json_path = os.path.join(json_base_dir, f"{request.param}.json")
25-
h5_path = os.path.join(h5_base_dir, f"{request.param}.h5")
26-
27-
if os.path.exists(json_path) and os.path.exists(h5_path):
28-
return json_path, h5_path
29-
pytest.skip(f"Required test files not found: {json_path} or {h5_path}")
30-
31-
328
def test_displacement_averaging(test_files):
339
"""
3410
This test verifies that the average of displacement fluctuations is zero for all

0 commit comments

Comments
 (0)