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

feat: nopayloadclient service #1428

Open
wants to merge 10 commits into
base: main
Choose a base branch
from
82 changes: 81 additions & 1 deletion .github/workflows/linux-eic-shell.yml
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ jobs:
release: nightly
- CC: clang
CMAKE_BUILD_TYPE: Release
release: 24.04.0-stable
release: 24.05.0-stable
steps:
- name: mmap rnd_bits workaround
# https://github.com/actions/runner/issues/3207#issuecomment-2000066889
Expand Down Expand Up @@ -647,6 +647,86 @@ jobs:
path: rec_${{ matrix.particle }}_1GeV_20GeV_${{ matrix.detector_config }}_${{ matrix.benchmark_plugins }}.hists.root
if-no-files-found: error

eicrecon-nopayloadclient:
runs-on: ubuntu-latest
needs:
- build
- npsim-gun
strategy:
matrix:
CC: [clang]
particle: [e]
detector_config: [craterlake]
services:
db:
image: postgres
env:
POSTGRES_DB: dbname
POSTGRES_USER: login
POSTGRES_PASSWORD: password
POSTGRES_HOST: localhost
POSTGRES_PORT: 5432
ports:
- 5432:5432
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
nopayloaddb-webapp:
image: ghcr.io/eic/nopayloaddb-webapp:latest
env:
POSTGRES_DB: dbname
POSTGRES_USER: login
POSTGRES_PASSWORD: password
POSTGRES_HOST: localhost
POSTGRES_PORT: 5432
Comment on lines +679 to +683
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we can move env up to job scope.

ports:
- 8000:8000
steps:
- name: Checkout .github
uses: actions/checkout@v4
with:
sparse-checkout: .github
- name: Download install directory
uses: actions/download-artifact@v4
with:
name: install-${{ matrix.CC }}-eic-shell-Release-${{ env.platform }}-${{ env.release }}
- name: Uncompress install directory
run: tar -xaf install.tar.zst
- uses: actions/download-artifact@v4
with:
name: sim_${{ matrix.particle }}_1GeV_20GeV_${{ matrix.detector_config }}.edm4hep.root
- uses: cvmfs-contrib/github-action-cvmfs@v4
- name: Run EICrecon
uses: eic/run-cvmfs-osg-eic-shell@main
with:
platform-release: "${{ env.platform }}:${{ env.release }}"
setup: "/opt/detector/epic-${{ env.detector-version }}/setup.sh"
run: |
export NOPAYLOADCLIENT_CONF=$PWD/default.json
cat <<- EOF > $NOPAYLOADCLIENT_CONF
{
"base_url": "localhost:8000",
"api_res": "/api/cdb_rest/",
"write_dir": "/tmp/remote_pl_store/",
"read_dir_list": ["/tmp/remote_pl_store/", "/cvmfs/place/holder/"],
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove place holder.

"n_retries": 5,
"retry_sleep_mean": 30,
"cache_life_time": 10,
"cache_max_mb": 1,
"print_time_stamps": false,
"use_fake_backend": false,
"logger": "terminal",
"log_level": "INFO"
}
EOF
cli_npc checkConnection
export DETECTOR_CONFIG=${DETECTOR}_${{ matrix.detector_config }}
export LD_LIBRARY_PATH=$PWD/install/lib:$LD_LIBRARY_PATH
export JANA_PLUGIN_PATH=$PWD/install/lib/EICrecon/plugins:/usr/local/plugins
$PWD/install/bin/eicrecon -Ppodio:output_file=rec_${{ matrix.particle }}_1GeV_20GeV_${{ matrix.detector_config }}.edm4eic.root sim_${{ matrix.particle }}_1GeV_20GeV_${{ matrix.detector_config }}.edm4hep.root -Pplugins=dump_flags,janadot,janatop -Pdump_flags:json=${{ matrix.particle }}_${{ matrix.detector_config }}_flags.json -Pjana:warmup_timeout=0 -Pjana:timeout=0

eicrecon-gun:
runs-on: ubuntu-latest
needs:
Expand Down
18 changes: 18 additions & 0 deletions cmake/jana_plugin.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -329,6 +329,24 @@ macro(plugin_add_irt _name)

endmacro()

# Adds nopayloadclient for a plugin
macro(plugin_add_nopayloadclient _name)

if(NOT CURL_FOUND)
find_package(CURL REQUIRED)
endif()

find_library(npc_lib REQUIRED NAMES nopayloadclient)
find_path(npc_include REQUIRED NAMES nopayloadclient)

# Add include directories
plugin_include_directories(${PLUGIN_NAME} PUBLIC ${npc_include})

# Add libraries
plugin_link_libraries(${PLUGIN_NAME} CURL::libcurl ${npc_lib})

endmacro()

# Adds podio, edm4hep, edm4eic for a plugin
macro(plugin_add_event_model _name)

Expand Down
1 change: 1 addition & 0 deletions src/services/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,6 @@ add_subdirectory(geometry/acts)
add_subdirectory(geometry/richgeo)
add_subdirectory(io/podio)
add_subdirectory(log)
add_subdirectory(payload)
add_subdirectory(rootfile)
add_subdirectory(pid_lut)
18 changes: 18 additions & 0 deletions src/services/payload/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
cmake_minimum_required(VERSION 3.16)

# Automatically set plugin name the same as the directory name Don't forget
# string(REPLACE " " "_" PLUGIN_NAME ${PLUGIN_NAME}) if this dir has spaces in
# its name
get_filename_component(PLUGIN_NAME ${CMAKE_CURRENT_LIST_DIR} NAME)

# Function creates ${PLUGIN_NAME}_plugin and ${PLUGIN_NAME}_library targets
# Setting default includes, libraries and installation paths
plugin_add(${PLUGIN_NAME} WITH_SHARED_LIBRARY)

# The macro grabs sources as *.cc *.cpp *.c and headers as *.h *.hh *.hpp Then
# correctly sets sources for ${_name}_plugin and ${_name}_library targets Adds
# headers to the correct installation directory
plugin_glob_all(${PLUGIN_NAME})

# Find dependencies
plugin_add_nopayloadclient(${PLUGIN_NAME})
13 changes: 13 additions & 0 deletions src/services/payload/Payload_service.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
// SPDX-License-Identifier: LGPL-3.0-or-later
// Copyright (C) 2024 Wouter Deconinck

#include "Payload_service.h"

#include <JANA/JException.h>
#include <nlohmann/json.hpp>
#include <nopayloadclient/nopayloadclient.hpp>

Payload_service::Payload_service(JApplication *app)
: m_client("EICrecon") {
m_application = app;
}
25 changes: 25 additions & 0 deletions src/services/payload/Payload_service.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
// SPDX-License-Identifier: LGPL-3.0-or-later
// Copyright (C) 2024 Wouter Deconinck

#pragma once

#include <JANA/JApplication.h>
#include <JANA/Services/JServiceLocator.h>
#include <nlohmann/json.hpp>
#include <nopayloadclient/nopayloadclient.hpp>
#include <string>

class Payload_service : public JService
{
public:
explicit Payload_service(JApplication *app);
~Payload_service() { };

private:

Payload_service() = default;

nopayloadclient::NoPayloadClient m_client;

JApplication* m_application;
};
16 changes: 16 additions & 0 deletions src/services/payload/payload.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// Copyright 2022, David Lawrence
// Subject to the terms in the LICENSE file found in the top-level directory.
//
//

#include <JANA/JApplication.h>
#include <memory>

#include "services/log/Log_service.h"

extern "C" {
void InitPlugin(JApplication* app) {
InitJANAPlugin(app);
app->ProvideService(std::make_shared<Log_service>(app));
}
}
Loading