Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor SmartRedis build system #341

Merged
merged 52 commits into from
Jun 2, 2023
Merged
Show file tree
Hide file tree
Changes from 47 commits
Commits
Show all changes
52 commits
Select commit Hold shift + click to select a range
2221ecb
WIP
billschereriii May 9, 2023
3cf4cd2
Merge
billschereriii May 9, 2023
e9fef6f
Examples work
billschereriii May 12, 2023
6d6933f
Unit tests buildable
billschereriii May 12, 2023
5e76d5d
Unit tests all pass again
billschereriii May 15, 2023
4318801
Adjust tests to run from the source directory to simplify creation of…
billschereriii May 15, 2023
dea8a24
Lib building now via cmake
billschereriii May 16, 2023
609ea05
EOD checkin
billschereriii May 17, 2023
8afe5ab
build mode and link type support in place for SmartRedis and SmartRed…
billschereriii May 17, 2023
0098ec0
Examples are now built with specified build mode and link type
billschereriii May 17, 2023
4427348
Tests are now built with specified build mode and link type
billschereriii May 17, 2023
cf38a4e
Interrim checkin
billschereriii May 19, 2023
4736905
Fix link errrors for Fortran and C++ unit-test
billschereriii May 19, 2023
dbc3eaf
Parallel build support
billschereriii May 19, 2023
35ff643
Merge
billschereriii May 19, 2023
eac9d21
Very slightly less pedantic for Fortran optimized builds
billschereriii May 19, 2023
2cd36d7
Clobber bogus uninitialized variable use warnings in Fortran
billschereriii May 19, 2023
53f432a
Tell the clustered and UDS tests where to look for test executables
billschereriii May 19, 2023
146b170
Test
billschereriii May 19, 2023
3aa7a90
Test
billschereriii May 22, 2023
02becd3
Test
billschereriii May 22, 2023
8b76c9e
Test
billschereriii May 22, 2023
12bb877
Fix? Docker workflow
billschereriii May 22, 2023
c79f9a2
Test
billschereriii May 22, 2023
f4f5bc2
Test
billschereriii May 22, 2023
32fbc10
Test
billschereriii May 22, 2023
de56022
CMake min version is supposed to be before the project() definition
billschereriii May 22, 2023
db135be
Revert moving third-party libraries to live under third-party/install
billschereriii May 22, 2023
ffe4f7b
Minor cleanup
billschereriii May 22, 2023
7d13a00
Build library before pip install
billschereriii May 22, 2023
9bd0c3b
Moar happy?
billschereriii May 22, 2023
379d220
Reenable matrix
billschereriii May 23, 2023
4c5212c
Update to current Intel compiler
billschereriii May 23, 2023
8b1db61
Don't allow unlimited process use
billschereriii May 23, 2023
4273cde
Enable parallel build for Fortran tests
billschereriii May 23, 2023
2d8ea5a
Don't mess with setup.py
billschereriii May 23, 2023
4f43da7
Revert back to working
billschereriii May 23, 2023
9ae2f0c
Nuke dead code in Makefile
billschereriii May 23, 2023
c1b514b
Allow Fortran tests to be built in parallel
billschereriii May 23, 2023
1b6d8d6
Test
billschereriii May 23, 2023
29379ee
Remove test tuils.F90 from Fortran test builds since we have it in th…
billschereriii May 23, 2023
2b509e8
Docs update
billschereriii May 23, 2023
e135d45
Doc update
billschereriii May 23, 2023
931338f
stop using build scripts in .yml file
billschereriii May 23, 2023
dfe812f
Address most feedback received so far
billschereriii May 31, 2023
34e5242
Enable python for python installation builds
billschereriii May 31, 2023
79eabab
Address remaining feedback
billschereriii May 31, 2023
97f1a80
Make SR_BUILD and SR_LINK case insensitive
billschereriii Jun 1, 2023
b5b0d4f
Don't build Fortran library unless needed
billschereriii Jun 1, 2023
c3f236f
Cleaner solution for Redis++
billschereriii Jun 1, 2023
f6ba327
Address MattE feedback
billschereriii Jun 1, 2023
4168ce7
typo
billschereriii Jun 2, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/run_post_merge_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -170,5 +170,5 @@ jobs:
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$PWD/install/lib &&
export SR_LOG_FILE=smartredis_examples_log.txt &&
export SR_LOG_LEVEL=INFO &&
make test-examples
make test-examples SR_FORTRAN=ON SR_PYTHON=ON

28 changes: 12 additions & 16 deletions .github/workflows/run_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,8 @@ jobs:
sudo apt-get install -y intel-oneapi-compiler-fortran intel-oneapi-compiler-dpcpp-cpp-and-cpp-classic
source /opt/intel/oneapi/setvars.sh &&
printenv >> $GITHUB_ENV &&
echo "CC=icc" >> $GITHUB_ENV &&
echo "CXX=icpc" >> $GITHUB_ENV &&
echo "CC=icx" >> $GITHUB_ENV &&
echo "CXX=icpx" >> $GITHUB_ENV &&
echo "FC=ifort" >> $GITHUB_ENV

# Install additional dependencies
Expand All @@ -120,29 +120,25 @@ jobs:
- name: Build SmartRedis python and install
run: python -m pip install -e .[dev,xarray]

- name: Build and install dependencies
run: |
mkdir -p ./third-party &&
cd ./third-party &&
bash ../build-scripts/build-lcov.sh &&
bash ../build-scripts/build-catch.sh
- name: Build and install test dependencies
run: make lcov && make catch2

- name: Install docker, redis-server, and RedisAI
run: |
sudo apt-get -y update && sudo apt-get -y install curl gnupg lsb-release software-properties-common ca-certificates && \
# Add latest redis to apt sources
echo "deb [signed-by=/usr/share/keyrings/redis-archive-keyring.gpg] https://packages.redis.io/deb $(lsb_release -cs) main" | sudo tee /etc/apt/sources.list.d/redis.list && \
curl -fsSL https://packages.redis.io/gpg | gpg --dearmor -o /usr/share/keyrings/redis-archive-keyring.gpg && \
sudo echo "deb [signed-by=/usr/share/keyrings/redis-archive-keyring.gpg] https://packages.redis.io/deb $(lsb_release -cs) main" | sudo tee /etc/apt/sources.list.d/redis.list && \
sudo curl -fsSL https://packages.redis.io/gpg | gpg --dearmor -o /usr/share/keyrings/redis-archive-keyring.gpg && \
# Add latest docker to apt sources
sudo mkdir -m 0755 -p /etc/apt/keyrings &&
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg &&
sudo curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg &&
echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu \
$(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null &&
# Install and update
sudo apt-get -y update && \
sudo apt-get -y install iputils-ping docker-ce docker-ce-cli containerd.io redis-tools=6:6.2.5-1rl1~focal1 redis-server=6:6.2.5-1rl1~focal1 &&
CONTAINER_NAME="redisai_$RANDOM" &&
docker create --name $CONTAINER_NAME --rm redislabs/redisai:${{ matrix.rai_v }}-cpu-bionic && \
sudo docker create --name $CONTAINER_NAME --rm redislabs/redisai:${{ matrix.rai_v }}-cpu-bionic && \
sudo mkdir -p /usr/lib/redis/modules/ &&
sudo docker cp $CONTAINER_NAME:/usr/lib/redis/modules/redisai.so /usr/lib/redis/modules &&
sudo docker cp $CONTAINER_NAME:/usr/lib/redis/modules/backends/ /usr/lib/redis/modules/ &&
Expand All @@ -162,7 +158,7 @@ jobs:
popd &&
export SSDB=$SSDB_SINGLE SMARTREDIS_TEST_CLUSTER=False &&
utils/check_redis.sh $PORT &&
make test-verbose-with-coverage COV_FLAGS="--cov=./src/python/module/smartredis/ --cov-report=xml --cov-append"
make test-verbose-with-coverage COV_FLAGS="--cov=./src/python/module/smartredis/ --cov-report=xml --cov-append" SR_FORTRAN=ON SR_PYTHON=ON

- name: Clustered DB tests
run: |
Expand All @@ -181,7 +177,7 @@ jobs:
redis-cli --cluster create $(echo $SSDB_CLUSTERED | tr "," " ") --cluster-yes &&
export SSDB=$SSDB_CLUSTERED SMARTREDIS_TEST_CLUSTER=True &&
python -m pytest --cov=./src/python/module/smartredis/ --cov-report=xml --cov-append \
--ignore ./tests/docker -vv -s ./tests
--ignore ./tests/docker -vv -s ./tests --build Coverage

- name: UDS DB tests
run: |
Expand All @@ -198,11 +194,11 @@ jobs:
utils/check_redis.sh $SOCKET
export SSDB=$SSDB_UDS SMARTREDIS_TEST_CLUSTER=False &&
python -m pytest --cov=./src/python/module/smartredis/ --cov-report=xml --cov-append \
--ignore ./tests/docker -vv -s ./tests
--ignore ./tests/docker -vv -s ./tests --build Coverage

# Process and upload code coverage (Python was collected during pytest)
- name: Collect coverage from C/C++/Fortran testers
run: third-party/lcov/install/usr/local/bin/lcov -c -d build/CMakeFiles -o coverage.info
run: third-party/lcov/install/usr/local/bin/lcov -c -d build/Coverage/CMakeFiles -o coverage.info

- name: Upload coverage to Codecov
uses: codecov/codecov-action@v3
Expand Down
126 changes: 75 additions & 51 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -24,47 +24,59 @@
# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

project(SmartRedis)
# Enable setting version in the project statement
if (POLICY CMP0048)
cmake_policy(SET CMP0048 NEW)
endif (POLICY CMP0048)

# Project definition for the SmartRedis project
cmake_minimum_required(VERSION 3.13)
project(SmartRedis VERSION "0.4.0")

option(BUILD_PYTHON "Build the python module" ON)
option(BUILD_FORTRAN "Build the fortran client library" OFF)
option(COVERAGE "Build the fortran client library" OFF)
# Configure options for the SmartRedis project
option(SR_PYTHON "Build the python module" OFF)
option(SR_FORTRAN "Build the fortran client library" OFF)
option(SR_PEDANTIC "Build with pickiest compiler settings" OFF)

set(CMAKE_BUILD_TYPE RELEASE)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_INSTALL_PREFIX ${CMAKE_SOURCE_DIR}/install)
set(CMAKE_CXX_VISIBILITY_PRESET default)
set(THREADS_PREFER_PTHREAD_FLAG ON)
set(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR})
include(smartredis_defs)

if (BUILD_FORTRAN)
# If we want to use Fortran, we have to tell CMake to use it
if (SR_FORTRAN)
enable_language(Fortran)
endif()

if (WERROR)
# For now, we only support Pedantic on the main library build.
# If/when we fine-tune the examples and test cases, move this block
# to smartredis_defs.cmake
if (SR_PEDANTIC)
if((CMAKE_CXX_COMPILER_ID STREQUAL "GNU") AND (CMAKE_C_COMPILER_ID STREQUAL "GNU"))
add_compile_options(-Wall -Werror)
else()
message(WARNING "WERROR was specified, but the CMAKE compiler is not GCC")
message(WARNING "SR_PEDANTIC was specified, but the CMAKE compiler is not GCC")
endif()
endif()

if (COVERAGE)
if((CMAKE_CXX_COMPILER_ID STREQUAL "GNU") AND (CMAKE_C_COMPILER_ID STREQUAL "GNU"))
add_compile_options(--coverage)
add_link_options(--coverage)
else()
message(WARNING "COVERAGE was specified, but the CMAKE compiler is not GCC")
if(CMAKE_Fortran_COMPILER_ID STREQUAL "GNU")
set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -Wno-maybe-uninitialized")
endif()
endif()

find_library(REDISPP redis++ PATHS ${CMAKE_SOURCE_DIR}/install/lib NO_DEFAULT_PATH REQUIRED)
find_library(HIREDIS hiredis PATHS ${CMAKE_SOURCE_DIR}/install/lib NO_DEFAULT_PATH REQUIRED)
# Bring in third-party libaries needed for the SmartRedis library
find_library(REDISPP redis++
PATHS ${CMAKE_SOURCE_DIR}/install/lib NO_DEFAULT_PATH
REQUIRED STATIC
)
find_library(HIREDIS hiredis
PATHS ${CMAKE_SOURCE_DIR}/install/lib NO_DEFAULT_PATH
REQUIRED STATIC
)
find_package(Threads REQUIRED)

set(EXT_CLIENT_LIBRARIES ${REDISPP} ${HIREDIS})

# Define source code that goes into the SmartRedis library
set(CLIENT_SRC
src/c/c_client.cpp
src/c/c_configoptions.cpp
Expand All @@ -73,45 +85,47 @@ set(CLIENT_SRC
src/c/c_logcontext.cpp
src/c/c_logger.cpp
src/cpp/address.cpp
src/cpp/addressallcommand.cpp
src/cpp/addressanycommand.cpp
src/cpp/addressatcommand.cpp
src/cpp/client.cpp
src/cpp/dataset.cpp
src/cpp/clusterinfocommand.cpp
src/cpp/command.cpp
src/cpp/keyedcommand.cpp
src/cpp/nonkeyedcommand.cpp
src/cpp/multikeycommand.cpp
src/cpp/singlekeycommand.cpp
src/cpp/commandlist.cpp
src/cpp/commandreply.cpp
src/cpp/compoundcommand.cpp
src/cpp/addressatcommand.cpp
src/cpp/addressanycommand.cpp
src/cpp/addressallcommand.cpp
src/cpp/clusterinfocommand.cpp
src/cpp/configoptions.cpp
src/cpp/dataset.cpp
src/cpp/dbinfocommand.cpp
src/cpp/dbnode.cpp
src/cpp/gettensorcommand.cpp
src/cpp/commandlist.cpp
src/cpp/keyedcommand.cpp
src/cpp/logger.cpp
src/cpp/metadata.cpp
src/cpp/tensorbase.cpp
src/cpp/tensorpack.cpp
src/cpp/dbnode.cpp
src/cpp/commandreply.cpp
src/cpp/redisserver.cpp
src/cpp/rediscluster.cpp
src/cpp/redis.cpp
src/cpp/metadatafield.cpp
src/cpp/stringfield.cpp
src/cpp/multikeycommand.cpp
src/cpp/nonkeyedcommand.cpp
src/cpp/pipelinereply.cpp
src/cpp/redis.cpp
src/cpp/rediscluster.cpp
src/cpp/redisserver.cpp
src/cpp/singlekeycommand.cpp
src/cpp/srobject.cpp
src/cpp/stringfield.cpp
src/cpp/tensorbase.cpp
src/cpp/tensorpack.cpp
src/cpp/threadpool.cpp
src/cpp/utility.cpp
src/cpp/logger.cpp
src/cpp/srobject.cpp
src/cpp/configoptions.cpp
)

# Define include directories for header files
include_directories(SYSTEM
include
install/include
)

if (BUILD_FORTRAN)
# Build the Fortran library
if (SR_FORTRAN)
set(FORTRAN_SRC
src/fortran/errors.F90
src/fortran/client.F90
Expand All @@ -125,20 +139,31 @@ if (BUILD_FORTRAN)
# Note the following has to be before ANY add_library command)
set(CMAKE_Fortran_MODULE_DIRECTORY "${CMAKE_INSTALL_PREFIX}/include")
# Fortran library
add_library(smartredis-fortran SHARED ${FORTRAN_SRC})
set_target_properties(smartredis-fortran PROPERTIES SUFFIX ".so")
add_library(smartredis-fortran ${SMARTREDIS_LINK_MODE} ${FORTRAN_SRC})
set_target_properties(smartredis-fortran PROPERTIES
SUFFIX ${SMARTREDIS_LINK_LIBRARY_SUFFIX}
)
set_target_properties(smartredis-fortran PROPERTIES
OUTPUT_NAME ${SMARTREDIS_FORTRAN_LIB}
)
target_link_libraries(smartredis-fortran PUBLIC smartredis ${EXT_CLIENT_LIBRARIES})
# Install dynamic library and headers
install(TARGETS smartredis-fortran
LIBRARY DESTINATION lib)
endif()


# Build dynamic library
add_library(smartredis SHARED ${CLIENT_SRC})
set_target_properties(smartredis PROPERTIES SUFFIX ".so")
# Build the main SmartRedis library
add_library(smartredis ${SMARTREDIS_LINK_MODE} ${CLIENT_SRC})
set_target_properties(smartredis PROPERTIES
SUFFIX ${SMARTREDIS_LINK_LIBRARY_SUFFIX}
)
set_target_properties(smartredis PROPERTIES
OUTPUT_NAME ${SMARTREDIS_LIB}
)
target_link_libraries(smartredis PUBLIC ${EXT_CLIENT_LIBRARIES} PRIVATE Threads::Threads)

# Install SmartRedis header files
install(DIRECTORY "${CMAKE_SOURCE_DIR}/include/"
DESTINATION "include"
FILES_MATCHING
Expand All @@ -149,13 +174,12 @@ install(DIRECTORY "${CMAKE_SOURCE_DIR}/include/"
install(TARGETS smartredis
LIBRARY DESTINATION lib)

if(BUILD_PYTHON)
# Build the Python library for SmartRedis
if(SR_PYTHON)
message("-- Python client build enabled")
add_subdirectory(${CMAKE_SOURCE_DIR}/third-party/pybind
${CMAKE_SOURCE_DIR}/third-party/pybind/build)

add_library(smartredis_static STATIC ${CLIENT_SRC})

pybind11_add_module(smartredisPy
src/python/src/pyclient.cpp
src/python/src/pyconfigoptions.cpp
Expand All @@ -166,8 +190,8 @@ if(BUILD_PYTHON)
src/python/bindings/bind.cpp)

target_link_libraries(smartredisPy PUBLIC ${EXT_CLIENT_LIBRARIES})
install(TARGETS smartredisPy
LIBRARY DESTINATION lib)
install(TARGETS smartredisPy LIBRARY DESTINATION lib)
install(TARGETS smartredisPy LIBRARY DESTINATION ../src/python/module/smartredis)
else()
message("-- Skipping Python client build")
endif()
1 change: 1 addition & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ include requirements.txt
include requirements-dev.txt
include Makefile
include CMakeLists.txt
include smartredis_defs.cmake
graft src
graft build-scripts
graft include
Expand Down
Loading