Skip to content

Commit e10c530

Browse files
authored
Merge pull request #108 from cindytsai/EasyInstall
Easy Install and MISC Fix (finally 😄)
2 parents 2d085c2 + b223a15 commit e10c530

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

58 files changed

+1615
-626
lines changed

.github/tests/test-DataIO/DataIOTest.py

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ def yt_inline_ProjectionPlot( fields ):
2424
# Do yt operation
2525
prjz = yt.ProjectionPlot(ds, 'z', fields)
2626

27-
# Include this line, otherwise yt will save one copy in each rank.
27+
# Save figure only on root process
2828
if yt.is_root():
2929
prjz.save()
3030

@@ -37,13 +37,6 @@ def yt_inline_ProfilePlot():
3737

3838
def yt_inline_ParticlePlot():
3939
ds = yt_libyt.libytDataset()
40-
41-
## ParticleProjectionPlot
42-
#==========================
43-
# par = yt.ParticleProjectionPlot(ds, "z")
44-
45-
## ParticlePlot
46-
#==========================
4740
par = yt.ParticlePlot(ds, "particle_position_x", "particle_position_y", "Level", center = 'c')
4841

4942
if yt.is_root():
Lines changed: 36 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Test if it can run on multiplatform and both in serial (gcc) and parallel (openmpi)
1+
# Test if libyt can build with different options, download dependencies, and install and link correctly.
22

33
name: CMake Build Test
44

@@ -24,80 +24,74 @@ jobs:
2424
platform:
2525
- os: ubuntu-latest
2626
mpi: 'openmpi'
27-
- os: macos-latest
27+
check_shared_lib: ldd lib/libyt.so
28+
- os: macos-12
2829
mpi: 'mpich'
30+
check_shared_lib: otool -l lib/libyt.dylib
2931
python-version: ['3.7', '3.8', '3.9', '3.10', '3.11', '3.12']
3032

3133
steps:
3234
- name: Checkout libyt repo
33-
uses: actions/checkout@v3
35+
uses: actions/checkout@v4
3436

3537
- name: CMake Version
3638
run: cmake --version
3739

3840
- name: Setup Python ${{ matrix.python-version }} environment
39-
uses: actions/setup-python@v4
41+
uses: actions/setup-python@v5
4042
with:
4143
python-version: ${{ matrix.python-version }}
4244
architecture: 'x64'
4345
cache: 'pip'
4446
- run: |
4547
python -m pip install --upgrade pip
46-
pip install -r ${{ github.workspace }}/.github/tools/requirements.txt
48+
pip install numpy
4749
4850
- name: Setup MPI environment
4951
uses: mpi4py/setup-mpi@v1
5052
with:
5153
mpi: ${{ matrix.platform.mpi }}
5254

53-
- name: Install yt, mpi4py, and yt_libyt
54-
run: |
55-
pip install mpi4py yt
56-
pip install yt-libyt
57-
5855
- name: Update GitHub Environment Variables
5956
run: |
60-
echo "LIBYT_PARALLEL_INSTALL_PATH=${{ github.workspace }}/libyt_parallel" >> $GITHUB_ENV
61-
echo "LIBYT_SERIAL_INSTALL_PATH=${{ github.workspace }}/libyt_serial" >> $GITHUB_ENV
57+
echo "LIBYT_TEST_INSTALL_FOLDER=${{ github.workspace }}/libyt_installation" >> $GITHUB_ENV
6258
63-
- name: Build libyt -- Parallel (MPI)
59+
- name: Test Option -DSERIAL_MODE=ON
6460
run: |
6561
cd ${{ github.workspace }}
6662
rm -rf build
67-
cmake -B build -S .
63+
cmake -B build -S . -DSERIAL_MODE=ON
6864
cmake --build build
69-
cmake --install build --prefix "${{ env.LIBYT_PARALLEL_INSTALL_PATH }}"
65+
cmake --install build --prefix "${{ env.LIBYT_TEST_INSTALL_FOLDER }}/libyt-serial-on"
66+
cd "${{ env.LIBYT_TEST_INSTALL_FOLDER }}/libyt-serial-on"
67+
${{ matrix.platform.check_shared_lib }}
7068
71-
- name: Build libyt -- Serial (GCC)
69+
- name: Test Option -DINTERACTIVE_MODE=ON
7270
run: |
7371
cd ${{ github.workspace }}
74-
rm -rf build-serial
75-
cmake -B build-serial -S . -DSERIAL_MODE=ON
76-
cmake --build build-serial
77-
cmake --install build-serial --prefix "${{ env.LIBYT_SERIAL_INSTALL_PATH }}"
78-
79-
- name: Prepare Test
80-
run: |
81-
cd ${{ github.workspace }}/example
82-
cp ${{ github.workspace }}/.github/tests/test-DataIO/DataIOTest.py .
83-
84-
- name: Generate Density Data for Testing
85-
run: |
86-
cd ${{ github.workspace }}/example
87-
cp ${{ github.workspace }}/.github/tools/generate_density_data.cpp .
88-
g++ -o generate_density_data generate_density_data.cpp
89-
./generate_density_data
72+
rm -rf build
73+
cmake -B build -S . -DINTERACTIVE_MODE=ON
74+
cmake --build build
75+
cmake --install build --prefix "${{ env.LIBYT_TEST_INSTALL_FOLDER }}/libyt-interactive-on"
76+
cd "${{ env.LIBYT_TEST_INSTALL_FOLDER }}/libyt-interactive-on"
77+
${{ matrix.platform.check_shared_lib }}
9078
91-
- name: Test Run and DataIO Test - example - Serial
79+
- name: Test Option -DJUPYTER_KERNEL=ON
9280
run: |
93-
cd ${{ github.workspace }}/example
94-
make clean
95-
make OPTIONS=-DSERIAL_MODE LIBYT_PATH="${{ env.LIBYT_SERIAL_INSTALL_PATH }}"
96-
./example DataIOTest.py
81+
cd ${{ github.workspace }}
82+
rm -rf build
83+
cmake -B build -S . -DJUPYTER_KERNEL=ON
84+
cmake --build build
85+
cmake --install build --prefix "${{ env.LIBYT_TEST_INSTALL_FOLDER }}/libyt-jupyter-on"
86+
cd "${{ env.LIBYT_TEST_INSTALL_FOLDER }}/libyt-jupyter-on"
87+
${{ matrix.platform.check_shared_lib }}
9788
98-
- name: Test Run and DataIO Test - example - Parallel (MPI 3)
89+
- name: Test Option -DSUPPORT_TIMER=ON
9990
run: |
100-
cd ${{ github.workspace }}/example
101-
make clean
102-
make LIBYT_PATH="${{ env.LIBYT_PARALLEL_INSTALL_PATH }}"
103-
OMPI_MCA_osc=sm,pt2pt mpirun -np 3 ./example DataIOTest.py
91+
cd ${{ github.workspace }}
92+
rm -rf build
93+
cmake -B build -S . -DSUPPORT_TIMER=ON
94+
cmake --build build
95+
cmake --install build --prefix "${{ env.LIBYT_TEST_INSTALL_FOLDER }}/libyt-timer-on"
96+
cd "${{ env.LIBYT_TEST_INSTALL_FOLDER }}/libyt-timer-on"
97+
${{ matrix.platform.check_shared_lib }}
Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
# Test if example can run on multiplatform and both in serial (gcc) and parallel (openmpi)
2+
3+
name: Example Test Run
4+
5+
on:
6+
push:
7+
branches: [ main ]
8+
paths-ignore:
9+
- 'doc/**'
10+
- '**.md'
11+
pull_request:
12+
branches: [ main ]
13+
paths-ignore:
14+
- 'doc/**'
15+
- '**.md'
16+
workflow_dispatch:
17+
18+
jobs:
19+
example-test-run:
20+
runs-on: ${{ matrix.platform.os }}
21+
strategy:
22+
fail-fast: false
23+
matrix:
24+
platform:
25+
- os: ubuntu-latest
26+
mpi: 'openmpi'
27+
- os: macos-12
28+
mpi: 'mpich'
29+
python-version: ['3.7', '3.8', '3.9', '3.10', '3.11', '3.12']
30+
31+
steps:
32+
- name: Checkout libyt repo
33+
uses: actions/checkout@v4
34+
35+
- name: CMake Version
36+
run: cmake --version
37+
38+
- name: Setup Python ${{ matrix.python-version }} environment
39+
uses: actions/setup-python@v5
40+
with:
41+
python-version: ${{ matrix.python-version }}
42+
architecture: 'x64'
43+
cache: 'pip'
44+
- run: |
45+
python -m pip install --upgrade pip
46+
pip install -r ${{ github.workspace }}/.github/tools/requirements.txt
47+
48+
- name: Setup MPI environment
49+
uses: mpi4py/setup-mpi@v1
50+
with:
51+
mpi: ${{ matrix.platform.mpi }}
52+
53+
- name: Install yt, mpi4py, and yt_libyt
54+
run: |
55+
pip install mpi4py yt yt_libyt
56+
57+
- name: Update GitHub Environment Variables
58+
run: |
59+
echo "LIBYT_PARALLEL_INSTALL_PATH=${{ github.workspace }}/libyt_parallel" >> $GITHUB_ENV
60+
echo "LIBYT_SERIAL_INSTALL_PATH=${{ github.workspace }}/libyt_serial" >> $GITHUB_ENV
61+
62+
- name: Build libyt -- Parallel (MPI)
63+
run: |
64+
cd ${{ github.workspace }}
65+
rm -rf build
66+
cmake -B build -S . -DINTERACTIVE_MODE=ON -DJUPYTER_KERNEL=ON
67+
cmake --build build
68+
cmake --install build --prefix "${{ env.LIBYT_PARALLEL_INSTALL_PATH }}"
69+
70+
- name: Build libyt -- Serial (GCC)
71+
run: |
72+
cd ${{ github.workspace }}
73+
rm -rf build-serial
74+
cmake -B build-serial -S . -DSERIAL_MODE=ON -DINTERACTIVE_MODE=ON -DJUPYTER_KERNEL=ON
75+
cmake --build build-serial
76+
cmake --install build-serial --prefix "${{ env.LIBYT_SERIAL_INSTALL_PATH }}"
77+
78+
- name: Prepare Test
79+
run: |
80+
cd ${{ github.workspace }}/example/amr-example
81+
cp ${{ github.workspace }}/.github/tests/test-DataIO/DataIOTest.py .
82+
83+
- name: Generate Density Data for Testing
84+
run: |
85+
cd ${{ github.workspace }}/example/amr-example
86+
cp ${{ github.workspace }}/.github/tools/generate_density_data.cpp .
87+
g++ -o generate_density_data generate_density_data.cpp
88+
./generate_density_data
89+
90+
- name: Test Run and DataIO Test - example - Serial
91+
run: |
92+
cd ${{ github.workspace }}/example/amr-example
93+
make clean
94+
make OPTIONS=-DSERIAL_MODE LIBYT_PATH="${{ env.LIBYT_SERIAL_INSTALL_PATH }}"
95+
./example DataIOTest.py
96+
97+
- name: Test Run and DataIO Test - example - Parallel (MPI Size 3)
98+
run: |
99+
cd ${{ github.workspace }}/example/amr-example
100+
make clean
101+
make LIBYT_PATH="${{ env.LIBYT_PARALLEL_INSTALL_PATH }}"
102+
OMPI_MCA_osc=sm,pt2pt mpirun -np 3 ./example DataIOTest.py

.gitignore

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,11 @@
22
*.pyc
33
libyt.so
44
libyt.so.*
5-
doc/_site
5+
doc/_site
6+
doc/_build/
7+
vendor/cppzmq/
8+
vendor/nlohmann_json/
9+
vendor/xeus/
10+
vendor/xeus-zmq/
11+
vendor/xtl/
12+
vendor/libzmq/

CMakeLists.txt

Lines changed: 12 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,14 @@ option(JUPYTER_KERNEL "Use Jupyter notebook interface"
1010
option(SUPPORT_TIMER "Support time profiling" OFF)
1111

1212
## set paths ##
13+
# It is recommended that we always provide PYTHON_PATH and MPI_PATH.
14+
# libyt will also try to find the package if the paths weren't provided.
1315
set(PYTHON_PATH "" CACHE PATH "Path to Python installation prefix (Always)")
1416
set(MPI_PATH "" CACHE PATH "Path to MPI installation prefix (-DSERIAL_MODE=OFF)")
1517
set(READLINE_PATH "" CACHE PATH "Path to Readline installation prefix (-DINTERACTIVE_MODE=ON)")
18+
19+
## set paths (optional) ##
20+
# libyt will get the dependencies if it cannot find one when needed.
1621
set(nlohmann_json_DIR "" CACHE PATH "Path to nlohmann_jsonConfig.cmake (-DJUPYTER_KERNEL=ON)")
1722
set(cppzmq_DIR "" CACHE PATH "Path to cppzmqConfig.cmake (-DJUPYTER_KERNEL=ON)")
1823
set(xtl_DIR "" CACHE PATH "Path to xtlConfig.cmake (-DJUPYTER_KERNEL=ON)")
@@ -26,35 +31,19 @@ set(CMAKE_CXX_STANDARD 14)
2631
set(CMAKE_CXX_STANDARD_REQUIRED ON)
2732

2833
## build static/shared library ##
29-
option(BUILD_SHARED_LIBS "Building using shared libraries" ON )
34+
option(BUILD_SHARED_LIBS "Building using shared libraries" ON )
3035

3136
## find dependencies ##
37+
set(Python_ROOT_DIR ${PYTHON_PATH})
38+
find_package(Python 3.7 COMPONENTS Development NumPy REQUIRED)
39+
3240
if (NOT SERIAL_MODE)
3341
set(MPI_HOME ${MPI_PATH})
3442
find_package(MPI REQUIRED)
3543
endif ()
3644

37-
if (JUPYTER_KERNEL)
38-
find_package(xeus-zmq 1.0 REQUIRED)
39-
endif ()
40-
41-
set(Python_ROOT_DIR ${PYTHON_PATH})
42-
find_package(Python COMPONENTS Development NumPy REQUIRED)
43-
44-
## config files ##
45-
if (JUPYTER_KERNEL)
46-
set(LIBYT_KERNELSPEC_RELATIVE_PATH "share/jupyter/kernels/libyt_kernel")
47-
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/${LIBYT_KERNELSPEC_RELATIVE_PATH}/kernel.json
48-
./${LIBYT_KERNELSPEC_RELATIVE_PATH}/kernel.json COPYONLY)
49-
endif ()
50-
5145
## sub directory ##
46+
add_subdirectory(vendor) # for vendoring
5247
add_subdirectory(src) # for library
53-
#add_subdirectory(example) # for example exe
54-
55-
###### INSTALLATION RULE ###############################################################################################
56-
if (JUPYTER_KERNEL)
57-
include(GNUInstallDirs)
58-
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${LIBYT_KERNELSPEC_RELATIVE_PATH}/kernel.json
59-
DESTINATION "${LIBYT_KERNELSPEC_RELATIVE_PATH}")
60-
endif ()
48+
add_subdirectory(share) # for share
49+
add_subdirectory(example) # for example exe

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
# libyt
2-
[![CMake Build Test](https://github.com/yt-project/libyt/actions/workflows/cmake-build-test.yml/badge.svg)](https://github.com/yt-project/libyt/actions/workflows/cmake-build-test.yml)
2+
[![CMake Build Test](https://github.com/yt-project/libyt/actions/workflows/cmake-build-test.yml/badge.svg?branch=main)](https://github.com/yt-project/libyt/actions/workflows/cmake-build-test.yml)
3+
[![Example Test Run](https://github.com/yt-project/libyt/actions/workflows/example-test-run.yml/badge.svg?branch=main)](https://github.com/yt-project/libyt/actions/workflows/example-test-run.yml)
34
[![Documentation Status](https://readthedocs.org/projects/libyt/badge/?version=latest)](https://libyt.readthedocs.io/en/latest/?badge=latest)
45

56
`libyt` is an open source C library for simulation, that allows researchers to analyze and visualize data using [`yt`](https://yt-project.org/) or other Python packages in parallel during simulation runtime. In this way, we can skip the step of writing data to local disk before doing analysis using Python. This greatly reduce the disk usage, and increase the temporal resolution.

0 commit comments

Comments
 (0)