Skip to content

Commit

Permalink
Merge pull request #108 from cindytsai/EasyInstall
Browse files Browse the repository at this point in the history
Easy Install and MISC Fix (finally 😄)
  • Loading branch information
cindytsai authored May 31, 2024
2 parents f8c1831 + a8c45c7 commit 49ec75e
Show file tree
Hide file tree
Showing 58 changed files with 1,615 additions and 626 deletions.
9 changes: 1 addition & 8 deletions .github/tests/test-DataIO/DataIOTest.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ def yt_inline_ProjectionPlot( fields ):
# Do yt operation
prjz = yt.ProjectionPlot(ds, 'z', fields)

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

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

def yt_inline_ParticlePlot():
ds = yt_libyt.libytDataset()

## ParticleProjectionPlot
#==========================
# par = yt.ParticleProjectionPlot(ds, "z")

## ParticlePlot
#==========================
par = yt.ParticlePlot(ds, "particle_position_x", "particle_position_y", "Level", center = 'c')

if yt.is_root():
Expand Down
78 changes: 36 additions & 42 deletions .github/workflows/cmake-build-test.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Test if it can run on multiplatform and both in serial (gcc) and parallel (openmpi)
# Test if libyt can build with different options, download dependencies, and install and link correctly.

name: CMake Build Test

Expand All @@ -24,80 +24,74 @@ jobs:
platform:
- os: ubuntu-latest
mpi: 'openmpi'
- os: macos-latest
check_shared_lib: ldd lib/libyt.so
- os: macos-12
mpi: 'mpich'
check_shared_lib: otool -l lib/libyt.dylib
python-version: ['3.7', '3.8', '3.9', '3.10', '3.11', '3.12']

steps:
- name: Checkout libyt repo
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: CMake Version
run: cmake --version

- name: Setup Python ${{ matrix.python-version }} environment
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
architecture: 'x64'
cache: 'pip'
- run: |
python -m pip install --upgrade pip
pip install -r ${{ github.workspace }}/.github/tools/requirements.txt
pip install numpy
- name: Setup MPI environment
uses: mpi4py/setup-mpi@v1
with:
mpi: ${{ matrix.platform.mpi }}

- name: Install yt, mpi4py, and yt_libyt
run: |
pip install mpi4py yt
pip install yt-libyt
- name: Update GitHub Environment Variables
run: |
echo "LIBYT_PARALLEL_INSTALL_PATH=${{ github.workspace }}/libyt_parallel" >> $GITHUB_ENV
echo "LIBYT_SERIAL_INSTALL_PATH=${{ github.workspace }}/libyt_serial" >> $GITHUB_ENV
echo "LIBYT_TEST_INSTALL_FOLDER=${{ github.workspace }}/libyt_installation" >> $GITHUB_ENV
- name: Build libyt -- Parallel (MPI)
- name: Test Option -DSERIAL_MODE=ON
run: |
cd ${{ github.workspace }}
rm -rf build
cmake -B build -S .
cmake -B build -S . -DSERIAL_MODE=ON
cmake --build build
cmake --install build --prefix "${{ env.LIBYT_PARALLEL_INSTALL_PATH }}"
cmake --install build --prefix "${{ env.LIBYT_TEST_INSTALL_FOLDER }}/libyt-serial-on"
cd "${{ env.LIBYT_TEST_INSTALL_FOLDER }}/libyt-serial-on"
${{ matrix.platform.check_shared_lib }}
- name: Build libyt -- Serial (GCC)
- name: Test Option -DINTERACTIVE_MODE=ON
run: |
cd ${{ github.workspace }}
rm -rf build-serial
cmake -B build-serial -S . -DSERIAL_MODE=ON
cmake --build build-serial
cmake --install build-serial --prefix "${{ env.LIBYT_SERIAL_INSTALL_PATH }}"
- name: Prepare Test
run: |
cd ${{ github.workspace }}/example
cp ${{ github.workspace }}/.github/tests/test-DataIO/DataIOTest.py .
- name: Generate Density Data for Testing
run: |
cd ${{ github.workspace }}/example
cp ${{ github.workspace }}/.github/tools/generate_density_data.cpp .
g++ -o generate_density_data generate_density_data.cpp
./generate_density_data
rm -rf build
cmake -B build -S . -DINTERACTIVE_MODE=ON
cmake --build build
cmake --install build --prefix "${{ env.LIBYT_TEST_INSTALL_FOLDER }}/libyt-interactive-on"
cd "${{ env.LIBYT_TEST_INSTALL_FOLDER }}/libyt-interactive-on"
${{ matrix.platform.check_shared_lib }}
- name: Test Run and DataIO Test - example - Serial
- name: Test Option -DJUPYTER_KERNEL=ON
run: |
cd ${{ github.workspace }}/example
make clean
make OPTIONS=-DSERIAL_MODE LIBYT_PATH="${{ env.LIBYT_SERIAL_INSTALL_PATH }}"
./example DataIOTest.py
cd ${{ github.workspace }}
rm -rf build
cmake -B build -S . -DJUPYTER_KERNEL=ON
cmake --build build
cmake --install build --prefix "${{ env.LIBYT_TEST_INSTALL_FOLDER }}/libyt-jupyter-on"
cd "${{ env.LIBYT_TEST_INSTALL_FOLDER }}/libyt-jupyter-on"
${{ matrix.platform.check_shared_lib }}
- name: Test Run and DataIO Test - example - Parallel (MPI 3)
- name: Test Option -DSUPPORT_TIMER=ON
run: |
cd ${{ github.workspace }}/example
make clean
make LIBYT_PATH="${{ env.LIBYT_PARALLEL_INSTALL_PATH }}"
OMPI_MCA_osc=sm,pt2pt mpirun -np 3 ./example DataIOTest.py
cd ${{ github.workspace }}
rm -rf build
cmake -B build -S . -DSUPPORT_TIMER=ON
cmake --build build
cmake --install build --prefix "${{ env.LIBYT_TEST_INSTALL_FOLDER }}/libyt-timer-on"
cd "${{ env.LIBYT_TEST_INSTALL_FOLDER }}/libyt-timer-on"
${{ matrix.platform.check_shared_lib }}
102 changes: 102 additions & 0 deletions .github/workflows/example-test-run.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
# Test if example can run on multiplatform and both in serial (gcc) and parallel (openmpi)

name: Example Test Run

on:
push:
branches: [ main ]
paths-ignore:
- 'doc/**'
- '**.md'
pull_request:
branches: [ main ]
paths-ignore:
- 'doc/**'
- '**.md'
workflow_dispatch:

jobs:
example-test-run:
runs-on: ${{ matrix.platform.os }}
strategy:
fail-fast: false
matrix:
platform:
- os: ubuntu-latest
mpi: 'openmpi'
- os: macos-12
mpi: 'mpich'
python-version: ['3.7', '3.8', '3.9', '3.10', '3.11', '3.12']

steps:
- name: Checkout libyt repo
uses: actions/checkout@v4

- name: CMake Version
run: cmake --version

- name: Setup Python ${{ matrix.python-version }} environment
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
architecture: 'x64'
cache: 'pip'
- run: |
python -m pip install --upgrade pip
pip install -r ${{ github.workspace }}/.github/tools/requirements.txt
- name: Setup MPI environment
uses: mpi4py/setup-mpi@v1
with:
mpi: ${{ matrix.platform.mpi }}

- name: Install yt, mpi4py, and yt_libyt
run: |
pip install mpi4py yt yt_libyt
- name: Update GitHub Environment Variables
run: |
echo "LIBYT_PARALLEL_INSTALL_PATH=${{ github.workspace }}/libyt_parallel" >> $GITHUB_ENV
echo "LIBYT_SERIAL_INSTALL_PATH=${{ github.workspace }}/libyt_serial" >> $GITHUB_ENV
- name: Build libyt -- Parallel (MPI)
run: |
cd ${{ github.workspace }}
rm -rf build
cmake -B build -S . -DINTERACTIVE_MODE=ON -DJUPYTER_KERNEL=ON
cmake --build build
cmake --install build --prefix "${{ env.LIBYT_PARALLEL_INSTALL_PATH }}"
- name: Build libyt -- Serial (GCC)
run: |
cd ${{ github.workspace }}
rm -rf build-serial
cmake -B build-serial -S . -DSERIAL_MODE=ON -DINTERACTIVE_MODE=ON -DJUPYTER_KERNEL=ON
cmake --build build-serial
cmake --install build-serial --prefix "${{ env.LIBYT_SERIAL_INSTALL_PATH }}"
- name: Prepare Test
run: |
cd ${{ github.workspace }}/example/amr-example
cp ${{ github.workspace }}/.github/tests/test-DataIO/DataIOTest.py .
- name: Generate Density Data for Testing
run: |
cd ${{ github.workspace }}/example/amr-example
cp ${{ github.workspace }}/.github/tools/generate_density_data.cpp .
g++ -o generate_density_data generate_density_data.cpp
./generate_density_data
- name: Test Run and DataIO Test - example - Serial
run: |
cd ${{ github.workspace }}/example/amr-example
make clean
make OPTIONS=-DSERIAL_MODE LIBYT_PATH="${{ env.LIBYT_SERIAL_INSTALL_PATH }}"
./example DataIOTest.py
- name: Test Run and DataIO Test - example - Parallel (MPI Size 3)
run: |
cd ${{ github.workspace }}/example/amr-example
make clean
make LIBYT_PATH="${{ env.LIBYT_PARALLEL_INSTALL_PATH }}"
OMPI_MCA_osc=sm,pt2pt mpirun -np 3 ./example DataIOTest.py
9 changes: 8 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,11 @@
*.pyc
libyt.so
libyt.so.*
doc/_site
doc/_site
doc/_build/
vendor/cppzmq/
vendor/nlohmann_json/
vendor/xeus/
vendor/xeus-zmq/
vendor/xtl/
vendor/libzmq/
35 changes: 12 additions & 23 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,14 @@ option(JUPYTER_KERNEL "Use Jupyter notebook interface"
option(SUPPORT_TIMER "Support time profiling" OFF)

## set paths ##
# It is recommended that we always provide PYTHON_PATH and MPI_PATH.
# libyt will also try to find the package if the paths weren't provided.
set(PYTHON_PATH "" CACHE PATH "Path to Python installation prefix (Always)")
set(MPI_PATH "" CACHE PATH "Path to MPI installation prefix (-DSERIAL_MODE=OFF)")
set(READLINE_PATH "" CACHE PATH "Path to Readline installation prefix (-DINTERACTIVE_MODE=ON)")

## set paths (optional) ##
# libyt will get the dependencies if it cannot find one when needed.
set(nlohmann_json_DIR "" CACHE PATH "Path to nlohmann_jsonConfig.cmake (-DJUPYTER_KERNEL=ON)")
set(cppzmq_DIR "" CACHE PATH "Path to cppzmqConfig.cmake (-DJUPYTER_KERNEL=ON)")
set(xtl_DIR "" CACHE PATH "Path to xtlConfig.cmake (-DJUPYTER_KERNEL=ON)")
Expand All @@ -26,35 +31,19 @@ set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

## build static/shared library ##
option(BUILD_SHARED_LIBS "Building using shared libraries" ON )
option(BUILD_SHARED_LIBS "Building using shared libraries" ON )

## find dependencies ##
set(Python_ROOT_DIR ${PYTHON_PATH})
find_package(Python 3.7 COMPONENTS Development NumPy REQUIRED)

if (NOT SERIAL_MODE)
set(MPI_HOME ${MPI_PATH})
find_package(MPI REQUIRED)
endif ()

if (JUPYTER_KERNEL)
find_package(xeus-zmq 1.0 REQUIRED)
endif ()

set(Python_ROOT_DIR ${PYTHON_PATH})
find_package(Python COMPONENTS Development NumPy REQUIRED)

## config files ##
if (JUPYTER_KERNEL)
set(LIBYT_KERNELSPEC_RELATIVE_PATH "share/jupyter/kernels/libyt_kernel")
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/${LIBYT_KERNELSPEC_RELATIVE_PATH}/kernel.json
./${LIBYT_KERNELSPEC_RELATIVE_PATH}/kernel.json COPYONLY)
endif ()

## sub directory ##
add_subdirectory(vendor) # for vendoring
add_subdirectory(src) # for library
#add_subdirectory(example) # for example exe

###### INSTALLATION RULE ###############################################################################################
if (JUPYTER_KERNEL)
include(GNUInstallDirs)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${LIBYT_KERNELSPEC_RELATIVE_PATH}/kernel.json
DESTINATION "${LIBYT_KERNELSPEC_RELATIVE_PATH}")
endif ()
add_subdirectory(share) # for share
add_subdirectory(example) # for example exe
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# libyt
[![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)
[![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)
[![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)
[![Documentation Status](https://readthedocs.org/projects/libyt/badge/?version=latest)](https://libyt.readthedocs.io/en/latest/?badge=latest)

`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.
Expand Down
Loading

0 comments on commit 49ec75e

Please sign in to comment.