Skip to content

Commit

Permalink
Merge pull request #11 from ukaea/release/2.7.2
Browse files Browse the repository at this point in the history
Release/2.7.2
  • Loading branch information
stephen-dixon authored Sep 4, 2023
2 parents 08c6054 + 832925e commit 7e4ec61
Show file tree
Hide file tree
Showing 61 changed files with 950 additions and 507 deletions.
4 changes: 3 additions & 1 deletion .github/workflows/cmake.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ jobs:
- name: Install macos dependencies
if: matrix.os == 'macos-latest'
run: >
brew update && brew install
brew update-reset && brew install
git
boost
openssl
Expand Down Expand Up @@ -96,6 +96,7 @@ jobs:
run: sudo cmake --install ${{github.workspace}}/build --config ${{ matrix.release }}

- name: Install pyuda
if: matrix.os == 'ubuntu-latest'
run: >
cp -r /usr/local/python_installer ${{github.workspace}}/python_installer &&
python3 -m venv ${{github.workspace}}/venv &&
Expand All @@ -104,6 +105,7 @@ jobs:
pip3 install ${{github.workspace}}/python_installer
- name: Test pyuda import
if: matrix.os == 'ubuntu-latest'
run: >
source ${{github.workspace}}/venv/bin/activate &&
python3 -c 'import pyuda; client=pyuda.Client()'
Expand Down
10 changes: 5 additions & 5 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ endmacro()
macro( CONVERT_LIN_PATH VarName )
if( MINGW AND NOT "${${VarName}}" STREQUAL "" )
execute_process( COMMAND cygpath.exe -m ${${VarName}} OUTPUT_VARIABLE ${VarName} )
string( STRIP ${${VarName}} ${VarName} )
string( REGEX REPLACE "[\r\n]+" ";" ${VarName} ${${VarName}} )
string( STRIP "${${VarName}}" ${VarName} )
string( REGEX REPLACE "[\r\n]+" ";" ${VarName} "${${VarName}}" )
endif()
endmacro()

Expand Down Expand Up @@ -107,12 +107,11 @@ else()
endif()
endif()

if( NOT WIN32 OR MINGW )
if( NOT WIN32 )
set( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fPIC -pthread -Wno-implicit-function-declaration" )
set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC -pthread" )

if( MINGW )
add_definitions( -D_WIN32 )
add_definitions( -DMINGW )
endif()

Expand Down Expand Up @@ -161,7 +160,7 @@ endif()
option( CLIENT_ONLY "Only build UDA client" OFF )
option( SERVER_ONLY "Only build UDA server" OFF )
option( BUILD_SHARED_LIBS "Build shared libraries" OFF )
option( NO_MEMCACHE "Do not attempt to build with libmemcached support" OFF )
option( NO_MEMCACHE "Do not attempt to build with libmemcached support" ON )
option( ENABLE_CAPNP "Enable Cap’n Proto serialisation" OFF )

# Wrapper configuration
Expand Down Expand Up @@ -224,6 +223,7 @@ if( WIN32 OR MINGW )
DESTINATION lib
FILES_MATCHING PATTERN "*xdr*"
)
return()
endif()

########################################################################################################################
Expand Down
67 changes: 67 additions & 0 deletions docker/client.centos.8
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
FROM centos:8

SHELL ["/bin/bash", "-c"]

RUN sed -i 's/$releasever/$releasever-stream/g' /etc/yum.repos.d/CentOS-*
RUN yum update -y --allowerasing && \
yum group install -y 'Development Tools' && \
yum install -y \
git \
wget \
boost-devel \
openssl-devel \
cmake \
libxml2-devel \
libtirpc-devel \
python39-devel \
python39-pip

# Building libfmt from source
RUN cd /tmp && \
wget https://github.com/fmtlib/fmt/archive/refs/tags/10.0.0.tar.gz && \
tar xzf 10.0.0.tar.gz && \
cd fmt-10.0.0 && \
cmake -Bbuild -H. -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/usr/local -DBUILD_SHARED_LIBS=ON && \
cmake --build build -j && \
cmake --install build

# Building spdlog from source
RUN cd /tmp && \
wget https://github.com/gabime/spdlog/archive/refs/tags/v1.11.0.tar.gz && \
tar xzf v1.11.0.tar.gz && \
cd spdlog-1.11.0 && \
cmake -Bbuild -H. -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/usr/local -DBUILD_SHARED_LIBS=ON && \
cmake --build build -j && \
cmake --install build

RUN cd /tmp && \
wget https://github.com/capnproto/capnproto/archive/refs/tags/v0.10.4.tar.gz && \
tar xzf v0.10.4.tar.gz && \
cd capnproto-0.10.4 && \
cmake -Bbuild -H. -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/usr/local -DBUILD_SHARED_LIBS=ON && \
cmake --build build -j && \
cmake --install build

COPY . /uda

RUN cd /uda && \
cmake -B build \
-DBUILD_SHARED_LIBS=ON \
-DCMAKE_BUILD_TYPE=Release \
-DSSLAUTHENTICATION=ON \
-DCLIENT_ONLY=ON \
-DENABLE_CAPNP=ON

# LD_LIBRARY_PATH needed by capnp scheam generator binary
RUN cd /uda && LD_LIBRARY_PATH=/usr/local/lib64 cmake --build build --config Release

RUN cd /uda && cmake --install build --config Release

RUN cp -r /usr/local/python_installer ./python_installer && \
export LD_LIBRARY_PATH=/usr/local/lib64 && \
python3 -m venv ./venv && \
source ./venv/bin/activate && \
pip3 install Cython numpy && \
pip3 install ./python_installer && \
python3 -c 'import pyuda; print(pyuda.__version__)'

43 changes: 43 additions & 0 deletions docker/client.ubuntu.22.10
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
FROM ubuntu:22.10

SHELL ["/bin/bash", "-c"]

RUN apt-get update && apt-get install -y \
git \
libboost-dev \
libboost-program-options-dev \
libssl-dev \
cmake \
build-essential \
pkg-config \
libxml2-dev \
libspdlog-dev \
ninja-build \
capnproto \
libcapnp-dev \
python3-dev \
python3-pip \
python3-venv

COPY .. /uda

RUN cd /uda && \
cmake -G Ninja -B build \
-DBUILD_SHARED_LIBS=ON \
-DCMAKE_BUILD_TYPE=Release \
-DSSLAUTHENTICATION=ON \
-DCLIENT_ONLY=ON \
-DENABLE_CAPNP=ON

RUN cd /uda && cmake --build build --config Release

RUN cd /uda && cmake --install build --config Release

RUN apt-get install -y python3-dev python3-pip python3-venv

RUN cp -r /usr/local/python_installer ./python_installer && \
python3 -m venv ./venv && \
source ./venv/bin/activate && \
pip3 install Cython numpy && \
pip3 install ./python_installer && \
python3 -c 'import pyuda; print(pyuda.__version__)'
124 changes: 123 additions & 1 deletion docs/creating_plugins.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,126 @@ layout: default
title: Creating a UDA plugin
---

TODO: Instructions for creating a new UDA plugin
## UDA plugin

A UDA plugin is shared library that is loaded dynamically by the
UDA server to enable extra functionality. The plugin makes available
a number of functions which can be called by the UDA client by specifying
the plugin name and function along with any number of arguments.

For example, if we have a plugin which is called `TEST` we might have
functions:
- `TEST::help()`
- `TEST::readData(filename=foo)`
- `TEST::process(signal=foo,operation=bar,flag)`

These functions read the arguments, do some processing, and return a
UDA `DataBlock` containing the data to be passed to the client.

## Structure of a plugin

The internals of a plugin is up to the plugin author. It can written in any
language that can be compiled to a shared library (.so on Linux, .dylib on MacOS,
.dll on Windows) but must provide a C style entry function which is
called by the UDA server.

The entry function must look like:

`int entryFunction(IDAM_PLUGIN_INTERFACE*)`

Then function can have any name — the name is specified in the plugin configuration
file, see below. The `IDAM_PLUGIN_INTERFACE` is a structure defined in `uda/plugins.h`
and provides a mechanism for the plugin to interact with the UDA server — reading the
function arguments, returning the resultant data, etc. The returned `int` value specifies
the return state of the plugin call — zero for success or non-zero for an error state
(the actual error is returned via the `IDAM_PLUGIN_INTERFACE`).

## Accessing function name and arguments

The function being called is provided in the `IDAM_PLUGIN_INTERFACE` structure passed into
entry function as a C-string (`const char*`) via:

`plugin_interface->request->function`

The arguments that where passed to the plugin function is passed a list of name-value pairs
via:

`plugin_interface->request->nameValueList`

You can the provided helper functions to find the argument in the list and return the value:

`bool find<TYPE>Value(NAMEVALUELIST* nvl, TYPE* value, const char* name)`

where `<TYPE>` is the name of type being expected, i.e. `Int` or `Double`, `name` is the name of the argument
being read and `value` is where the found value is stored. If the argument is not found the function will return
`false`, otherwise it will return `true` and populate `data` with the found value.

Help macros are also available when the name of the variable being read into is the same as the
name of the argument being read, i.e. to read a function argument called `arg1` we can used:

```c
int arg1;
bool found = FIND_INT_VALUE(nvl, arg1);
```

If the function argument is required you can use another helper macro which will set an error message
and return from the function with a non-zero value, if the argument is not found:

```c
int arg1;˚
FIND_REQUIRED_INT_VALUE(nvl, arg1);
```
## Returning data from a plugin
To return
## Plugin configuration file
The UDA server has a plugin configuration file that specifies how to load and use
the plugins available to the server. The plugin configuration file is a comman separated
text file with each line defined as:
`NAME, TYPE, ENTRY_FUNC, LIBRARY, *, 1, 1, 1, DESC`
Where:
- `NAME`: the name of the plugin — this is the name by which the client can call the call the plugin.
- `TYPE`: the type of the plugin — should be `function` for the plugins defined here.
- `ENTRY_FUNC`: the name of the plugin entry function.
- `LIBRARY`: the file name of the compile shared library, including extension.
- `DESC`: a short description of the plugin which is used by UDA when listing the plugins available.
Note:
The other elements (`*, 1, 1, 1`) are not applicable to the `function` type plugins are should always be set
to these values.
For example:
`HELP, function, helpPlugin, libhelp_plugin.dylib, *, 1, 1, 1, Service Discovery: list the details on all registered services, HELP::services()`
## Copying the template plugin
The easies way to create a new plugin is to copy the `templatePlugin` from the UDA repository.
Copy the template plugin directory `source/plugin/template` and rename as required. The directory contains
the following files:
- `CMakeLists.txt`: the CMake configuration file specifying how to build the plugin
- `templatePlugin.h`: the plugin header file
- `templatePlugin.cpp`: the plugin source file
Now update the plugin:
1. Rename the `templatePlugin.*` files to something that makes sense for your plugin and update
the `CMakeLists.txt` file as appropriate.
2. Change the entry function name in the source and header files from `templatePlugin(...)` to
something that corresponds to your plugin, and update `CMakeLists.txt` accordingly.
3. Implement the functionality required in the plugin.
The template plugin is written in C++ and uses a TemplatePlugin object to handle any of the function
requests. The plugin object is static as data can be cached between calls to avoid having to repeat work,
for example holding onto file handles to avoid re-opening files.
You can use the structure as provided or implement the functionality however you desire as long as each call
to the entry function handles the function requested and returns an error code accordingly.
6 changes: 3 additions & 3 deletions extlib/portablexdr-4.9.1/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@ cmake_policy( SET CMP0048 NEW )

project( xdr VERSION 4.9.1 )

if( NOT WIN32 OR MINGW )
if( NOT WIN32 )
set( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Werror -fno-strict-aliasing" )
endif()

include( TestBigEndian )

if( WIN32 OR MINGW )
if( WIN32 )
add_definitions( -DBIG_ENDIAN=1 -DLITTLE_ENDIAN=2 )
test_big_endian( BIG_ENDIAN )

Expand All @@ -30,5 +30,5 @@ configure_file(

include_directories( ${CMAKE_BINARY_DIR} ${CMAKE_SOURCE_DIR} )

add_library( ${PROJECT_NAME} ${SOURCES} )
add_library( ${PROJECT_NAME} SHARED ${SOURCES} )

4 changes: 1 addition & 3 deletions extlib/portablexdr-4.9.1/rpc/types.h
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,7 @@ typedef char * caddr_t;
//#include <sys/time.h>

#ifndef INADDR_LOOPBACK
# if defined(__GNUC__)
# define INADDR_LOOPBACK (u_long)0x7F000001
# endif
# define INADDR_LOOPBACK (u_long)0x7F000001
#endif
#ifndef MAXHOSTNAMELEN
# define MAXHOSTNAMELEN 64
Expand Down
24 changes: 24 additions & 0 deletions scripts/cmake-freia-idl84.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#!/bin/bash

module purge
module load idl/08.4
module load java/1.8
module load hdf5-C/1.8.13
module load gcc/7.3.0
module load cmake/3.21.0
module load capnproto/0.10.4
module load fmt/10.0.0
module load spdlog/1.11.0

export HDF5_USE_SHLIB=yes
export BOOST_ROOT=/usr/local/depot/boost-1-77-0-gcc7.3.0

CC=gcc CXX=g++ cmake -Bbuild_freia -H. \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_INSTALL_PREFIX=/projects/UDA/uda-install-develop \
-DBUILD_SHARED_LIBS=ON \
-DENABLE_CAPNP=ON \
-DUDA_CLI_BOOST_STATIC=ON \
-DUDA_HOST=uda2.mast.l \
-DUDA_PORT=56565 \
$*
3 changes: 3 additions & 0 deletions scripts/cmake-freia.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,7 @@ CC=gcc CXX=g++ cmake -Bbuild_freia -H. \
-DCMAKE_INSTALL_PREFIX=/projects/UDA/uda-install-develop \
-DBUILD_SHARED_LIBS=ON \
-DENABLE_CAPNP=ON \
-DUDA_CLI_BOOST_STATIC=ON \
-DUDA_HOST=uda2.mast.l \
-DUDA_PORT=56565 \
$*
Loading

0 comments on commit 7e4ec61

Please sign in to comment.