Skip to content

Commit

Permalink
Merge branch 'development' into recoil_detector
Browse files Browse the repository at this point in the history
  • Loading branch information
raffaelladevita authored Feb 3, 2025
2 parents 926b240 + b43d779 commit 6982871
Show file tree
Hide file tree
Showing 173 changed files with 3,959 additions and 4,734 deletions.
25 changes: 25 additions & 0 deletions .containers/coatjava.Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#syntax=docker/dockerfile:1

FROM ubuntu:noble

LABEL name="coatjava"
LABEL maintainer="Whitney Armstrong <[email protected]>"
LABEL architecture="amd64"

USER root


RUN apt update && apt upgrade -y
RUN apt install cmake vim maven groovy git ca-certificates wget curl python-is-python3 \
openjdk-17-jdk openjdk-17-jre openjdk-17-jdk-headless openjdk-17-jre-headless \
python3-sqlalchemy -y && update-ca-certificates

# CA certificates
ADD https://pki.jlab.org/JLabCA.crt /etc/ssl/certs/JLabCA.crt
#RUN trust anchor --store /image/JLabCA.crt

ARG REF_NAME=development
# build coatjava
RUN java --version && cd /opt && \
git clone https://code.jlab.org/hallb/alert/coatjava.git && cd coatjava && \
git fetch origin && git checkout ${REF_NAME} && ./build-coatjava.sh
12 changes: 12 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,21 @@
version: 2

registries:
clas12maven:
type: maven-repository
url: https://clasweb.jlab.org/clas12maven
jhep:
type: maven-repository
url: https://clasweb.jlab.org/jhep/maven

updates:
- package-ecosystem: "maven"
directory: "/"
schedule:
interval: "weekly"
registries:
- clas12maven
- jhep
ignore:
- dependency-name: "org.jlab:groot" # since version numbers are not in order
- package-ecosystem: "github-actions"
Expand Down
19 changes: 18 additions & 1 deletion .github/workflows/maven.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ defaults:
env:
java_version: 17
java_distribution: zulu
groovy_version: 4.0.3
groovy_version: 4.x

jobs:

Expand Down Expand Up @@ -133,11 +133,28 @@ jobs:
- name: test run-groovy
run: coatjava/bin/run-groovy validation/advanced-tests/test-run-groovy.groovy

release:
needs: [ build ]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/download-artifact@v4
with:
name: build_ubuntu-latest
- name: Release
uses: softprops/action-gh-release@v2
if: startsWith(github.ref, 'refs/tags/')
with:
files: coatjava.tar.gz
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

final:
needs:
- build
- test_coatjava
- test_run-groovy
- release
runs-on: ubuntu-latest
steps:
- name: pass
Expand Down
14 changes: 14 additions & 0 deletions .github/workflows/validation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,17 @@ on:
jobs:
validation:
uses: JeffersonLab/clas12-validation/.github/workflows/ci.yml@main
with:
matrix_evgen: >-
[
"e_p",
"e_n",
"e_g",
"e_pC",
"eFT_K",
"e_gFT"
]
matrix_config: >-
[
"rgb_fall2019"
]
40 changes: 40 additions & 0 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
workflow:
rules:
- if: '$CI_PIPELINE_SOURCE == "merge_request_event"'
- if: '$CI_PIPELINE_SOURCE == "web"'
- if: '$CI_PIPELINE_SOURCE == "webide"'
- if: '$CI_COMMIT_BRANCH == "master"'
- if: '$CI_COMMIT_BRANCH == "development"'
- if: '$CI_COMMIT_TAG'

default:
image: ubuntu:noble
retry: 2

coatjava_build:
image: gcr.io/kaniko-project/executor:debug
script:
- echo "${CI_COMMIT_REF_NAME}"
- >-
/kaniko/executor
--context $CI_PROJECT_DIR/docker
--dockerfile $CI_PROJECT_DIR/.containers/coatjava.Dockerfile
--destination $CI_REGISTRY_IMAGE/coatjava:${CI_COMMIT_REF_NAME}
--build-arg REF_NAME=${CI_COMMIT_REF_NAME}
alert_testing:
needs: ["coatjava_build"]
variables:
REF_NAME: "$CI_COMMIT_REF_NAME"
trigger:
project: hallb/alert/c12
strategy: depend

shared_for_alert_tests:
needs: ["coatjava_build"]
variables:
REF_NAME: "$CI_COMMIT_REF_NAME"
trigger:
project: hallb/alert/atof/shared_for_alert
strategy: depend

107 changes: 107 additions & 0 deletions bin/hipo-multi-merge
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
#!/usr/bin/env ruby

require 'optparse'
require 'ostruct'
require 'fileutils'

def print_log(name, val)
puts name.rjust(30) + " = #{val}"
end

# user options
@args = OpenStruct.new
@args.inputs = nil
@args.output_dir = nil
@args.prefix = nil
@args.num_merge = nil
@args.use_batch = false
@args.dry_run = false
OptionParser.new do |o|
o.banner = '''
This tool merges a set of input HIPO files to a set of output HIPO files,
where you may control the number of input files per output file; for example,
use this tool if you have 1000 small HIPO files but would rather have 10
large HIPO files.
'''
o.separator "USAGE: #{$0} [OPTIONS]..."
o.separator ''
o.separator 'REQUIRED OPTIONS:'
o.on('-i', '--input INPUTS', 'input directory or file glob;', 'surround file glob in quotes') { |a| @args.inputs = a }
o.on('-o', '--output OUTPUT_DIR', 'output directory') { |a| @args.output_dir = a }
o.on('-p', '--prefix OUTPUT_PREFIX', 'output filename prefix; names will be:', ' [OUTPUT_DIR]/[OUTPUT_PREFIX]_#####.hipo') { |a| @args.prefix = a }
o.on('-n', '--num NUM_FILES', 'number of files per output merged file') { |a| @args.num_merge = a.to_i }
o.separator ''
o.separator 'OPTIONAL OPTIONS:'
o.on('-b', '--batch', 'submit jobs to Slurm', '(default is sequential jobs)') { |a| @args.use_batch = true }
o.on('-d', '--dry-run', 'just print what would be done') { |a| @args.dry_run = true }
o.on_tail('-h', '--help', 'show this message') do
puts o
exit
end
end.parse! ARGV.empty? ? ['--help'] : ARGV

# check required options
if [@args.inputs, @args.output_dir, @args.prefix, @args.num_merge].include? nil
raise 'missing required option(s;) re-run with "--help" for guidance.'
end
raise 'option "--num" must be greater than zero' unless @args.num_merge > 0

# glob inputs
input_glob = File.expand_path @args.inputs
input_glob = File.join input_glob, "*.hipo" if File.directory? input_glob
print_log 'input glob', input_glob
print_log 'output dir', @args.output_dir
print_log 'output prefix', @args.prefix
print_log 'num files per output', @args.num_merge

# chunks
input_files = Dir.glob input_glob
raise "no input files found with glob '#{input_glob}'" if input_files.empty?
input_chunks = input_files.each_slice(@args.num_merge).to_a
print_log 'num input files', input_files.size
print_log 'num output files', input_chunks.size
raise 'option "--num" >= num input files, therefore there is nothing to do' if input_chunks.size == 1

# build commands
puts "="*82
merge_cmds = input_chunks.each_with_index.map do |input_chunk, chunk_num|
out_name = File.join @args.output_dir, "#{@args.prefix}_#{chunk_num.to_s.rjust(5, '0')}.hipo"
raise "output file #{out_name} already exists; cannot overwrite! delete it or choose another path/name" if File.exist? out_name
[ 'hipo-utils', '-merge', '-o', out_name, *input_chunk ].join ' '
end

# sbatch commands
if @args.use_batch
sbatch_args = {
'job-name' => "hipo_multi_merge___#{@args.prefix}",
'account' => 'clas12',
'partition' => 'production',
'mem-per-cpu' => 500,
'time' => '1:00:00',
'ntasks' => 1,
'cpus-per-task' => 1,
}.map{ |opt, val| "--#{opt}=#{val.to_s}" }
exe_cmds = merge_cmds.each_with_index.map do |merge_cmd, job_num|
log_name = "/farm_out/%u/%x_#{job_num.to_s.rjust(5, '0')}"
[
'sbatch',
*sbatch_args,
"--output=#{log_name}.out",
"--error=#{log_name}.err",
"--wrap='#{merge_cmd}'",
].join ' '
end
else
exe_cmds = merge_cmds
end

# execute
if @args.dry_run
puts 'THIS IS JUST A DRY RUN. Here are the commands which would be executed:'
puts "="*82
puts "mkdir -p #{@args.output_dir}"
exe_cmds.each do |cmd| puts cmd end
else
FileUtils.mkdir_p @args.output_dir
exe_cmds.each do |cmd| system cmd end
end
Loading

0 comments on commit 6982871

Please sign in to comment.