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

Make the DB client a static var #42

Draft
wants to merge 7 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
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
60 changes: 60 additions & 0 deletions .github/workflows/smartsim.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
name: smartsim
defaults:
run:
shell: bash -o pipefail -i {0}
on:
push:
branches:
- main
- 'smartsim*'
- 'static_client'
- 'releases/**'
pull_request:
types: [opened, reopened]
workflow_dispatch:
inputs:
debug_enabled:
type: boolean
description: 'Tmate debugging session'
required: false
default: false

jobs:
build:
runs-on: ubuntu-22.04

container:
image: ghcr.io/foamscience/openfoam-smartsim:cpu
options: --user openfoam
env:
CATCH_TIMEOUT: 20
FOAM_FOAMUT: "/tmp/foamUT"
SSDB: "redis:6379"

services:
redis:
image: redislabs/redisai

steps:
- name: Checkout repository
uses: actions/checkout@v3

- name: Setup tmate session
uses: mxschmitt/action-tmate@v3
if: ${{ github.event_name == 'workflow_dispatch' && inputs.debug_enabled }}
with:
detached: true

- name: Compile and Test
run: |
cd 2023-01/smartsim
source /usr/lib/openfoam/openfoam2212/etc/bashrc
mkdir -p $FOAM_USER_LIBBIN
./Allwmake
git clone https://github.com/FoamScience/foamUT $FOAM_FOAMUT
sed -i 's/mpirun/mpirun --oversubscribe/g' $FOAM_FOAMUT/Alltest
ln -s "$PWD"/smartsim_function_object/smartSimFunctionObject "$FOAM_FOAMUT"/smartSimFunctionObject
ln -s "$PWD"/smartsim_function_object/tests "$FOAM_FOAMUT"/tests/smartSimFOTests
cd $FOAM_FOAMUT || exit 1
rm -rf tests/exampleTests
./Alltest "$@"
3 changes: 3 additions & 0 deletions 2023-01/smartsim/Allwmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/usr/bin/bash

wmake smartsim_function_object/smartSimFunctionObject
34 changes: 34 additions & 0 deletions 2023-01/smartsim/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# Dockerfile to build SmartSim/SmartRedis-ready images for developing OpenFOAM-related stuff
#FROM opencfd/openfoam-dev
# The images from OpenCFD do not play nice with Github, so I use my own ones
FROM ghcr.io/foamscience/jammy-openfoam:v2212
LABEL maintainer="Mohammed Elwardi Fadeli <[email protected]>"

# Dependencies
USER root
RUN apt update && apt install -y python3-dev python3-pip git-core git-lfs cmake unzip vim wget
RUN apt clean && apt autoremove --yes && rm -rf /var/lib/{cache,log}/

USER openfoam

# Software versions; overriding these has no effect on resulting containers; but nice to have
# as environment variables to remove version confusion
ENV SMARTREDIS_VERSION="6bfcf1deb0d726df75610fe8a352b9ecb13c44f7"
ENV SMARTSIM_VERSION="0.5.1"

# Install SmartSim (maybe get the development version for this too?)
RUN pip3 install -U smartsim[ml]==$SMARTSIM_VERSION
ENV PATH=$PATH:/home/openfoam/.local/bin

# Build SmartRedis
ENV FOAM_SMARTREDIS=$HOME/smartredis
RUN git clone https://github.com/CrayLabs/SmartRedis $FOAM_SMARTREDIS &&\
cd $FOAM_SMARTREDIS && git reset --hard $SMARTREDIS_VERSION
RUN cd $FOAM_SMARTREDIS && smart clobber && smart build --device=cpu && make lib

# Environment variables to use for linking SmartRedis libs to OpenFOAM bins/libs
ENV SMARTREDIS_INCLUDE=$FOAM_SMARTREDIS/install/include
ENV SMARTREDIS_LIB=$FOAM_SMARTREDIS/install/lib
ENV LD_LIBRARY_PATH=$SMARTREDIS_LIB:$LD_LIBRARY_PATH
RUN find /usr/lib/openfoam -iname DiagonalMatrix.H -exec sudo sed -i 's/DiagonalMatrix<Type>/DiagonalMatrix/g' {} \;
RUN sudo chmod 777 -R /home/openfoam/data
13 changes: 5 additions & 8 deletions 2023-01/smartsim/configure-smartredis.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,11 @@
# Define environmental variables for including and linking SmartRedis in
# OpenFOAM applications and libraries.

echo Warning: make sure you sourced configure-smartredis.sh in its folder.
# Otherwise, the include files for OpenFOAM application/library compilations will be wrong.

export FOAM_SMARTREDIS=$PWD/smartredis
export FOAM_SMARTREDIS_INCLUDE=$FOAM_SMARTREDIS/include
export FOAM_SMARTREDIS_DEP_INCLUDE=$FOAM_SMARTREDIS/install/include
export FOAM_SMARTREDIS_LIB=$FOAM_SMARTREDIS/install/lib
export FOAM_SMARTREDIS_BUILD_LIB=$FOAM_SMARTREDIS/build
export LD_LIBRARY_PATH=$FOAM_SMARTREDIS_BUILD_LIB:$LD_LIBRARY_PATH
if [ ! -d "$FOAM_SMARTREDIS" ]; then
echo "$FOAM_SMARTREDIS does not exist, please source configure-smartredis.sh from its folder"
fi
export SMARTREDIS_INCLUDE=$FOAM_SMARTREDIS/install/include
export SMARTREDIS_LIB=$FOAM_SMARTREDIS/install/lib
export LD_LIBRARY_PATH=$FOAM_SMARTREDIS_LIB:$LD_LIBRARY_PATH
export SSDB="127.0.0.1:8000" # for multinode setup let smartsim do this
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@ EXE_INC = \
-I$(LIB_SRC)/TurbulenceModels/incompressible/lnInclude \
-I$(LIB_SRC)/transportModels \
-I$(LIB_SRC)/transportModels/incompressible/singlePhaseTransportModel \
-I$(FOAM_SMARTREDIS_INCLUDE) \
-I$(FOAM_SMARTREDIS_DEP_INCLUDE)
-I$(SMARTREDIS_INCLUDE)

EXE_LIBS = \
-lfiniteVolume \
Expand All @@ -19,5 +18,5 @@ EXE_LIBS = \
-lincompressibleTurbulenceModels \
-lincompressibleTransportModels \
-latmosphericModels \
-L$(FOAM_SMARTREDIS_LIB) -lhiredis -lredis++ \
-L$(FOAM_SMARTREDIS_BUILD_LIB) -lsmartredis
-L$(SMARTREDIS_LIB) -lhiredis -lredis++ \
-lsmartredis
32 changes: 30 additions & 2 deletions 2023-01/smartsim/smartredis/.github/workflows/build_wheels.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,31 @@
#
# BSD 2-Clause License
#
# Copyright (c) 2021-2023, Hewlett Packard Enterprise
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
#
# 1. Redistributions of source code must retain the above copyright notice, this
# list of conditions and the following disclaimer.
#
# 2. Redistributions in binary form must reproduce the above copyright notice,
# this list of conditions and the following disclaimer in the documentation
# and/or other materials provided with the distribution.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
# 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.
#

name: build_wheels

on: [push, pull_request]
Expand All @@ -18,7 +46,7 @@ jobs:
strategy:
fail-fast: false
matrix:
os: [ubuntu-20.04, macos-10.15]
os: [ubuntu-20.04, macos-12]
gcc_v: [8] # Version of GFortran we want to use.
env:
FC: gfortran-${{ matrix.gcc_v }}
Expand All @@ -29,7 +57,7 @@ jobs:
- uses: actions/setup-python@v2

- name: Install cibuildwheel
run: python -m pip install cibuildwheel==1.10.0
run: python -m pip install cibuildwheel>=2.12.3

- name: Install GFortran Linux
if: contains(matrix.os, 'ubuntu')
Expand Down
2 changes: 1 addition & 1 deletion 2023-01/smartsim/smartredis/.github/workflows/docker.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#
# BSD 2-Clause License
#
# Copyright (c) 2021, Hewlett Packard Enterprise
# Copyright (c) 2021-2023, Hewlett Packard Enterprise
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
Expand Down
32 changes: 30 additions & 2 deletions 2023-01/smartsim/smartredis/.github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,31 @@
#
# BSD 2-Clause License
#
# Copyright (c) 2021-2023, Hewlett Packard Enterprise
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
#
# 1. Redistributions of source code must retain the above copyright notice, this
# list of conditions and the following disclaimer.
#
# 2. Redistributions in binary form must reproduce the above copyright notice,
# this list of conditions and the following disclaimer in the documentation
# and/or other materials provided with the distribution.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
# 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.
#

name: deploy-release

on:
Expand All @@ -20,7 +48,7 @@ jobs:
strategy:
fail-fast: false
matrix:
os: [ubuntu-20.04, macos-10.15]
os: [ubuntu-20.04, macos-12]
gcc_v: [8] # Version of GFortran we want to use.
env:
FC: gfortran-${{ matrix.gcc_v }}
Expand All @@ -31,7 +59,7 @@ jobs:
- uses: actions/setup-python@v2

- name: Install cibuildwheel
run: python -m pip install cibuildwheel==1.10.0
run: python -m pip install cibuildwheel>=2.12.3

- name: Install GFortran Linux
if: contains(matrix.os, 'ubuntu')
Expand Down
146 changes: 0 additions & 146 deletions 2023-01/smartsim/smartredis/.github/workflows/run_post_merge_tests.yml

This file was deleted.

Loading