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

temporary commandlinesplit alex's branch. For github diff and better reading for team #648

Draft
wants to merge 59 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
59 commits
Select commit Hold shift + click to select a range
4ec920e
feat: test runners: build and test runners for local use
pflanze May 8, 2024
e0c04fb
feat: test runners: add DEBUGGER environment variable
pflanze Apr 25, 2024
5667cb1
feat: test runners: add bin/gco-make-test
pflanze May 2, 2024
7950e5f
feat: test runners: add a timeout to runtests-e2e
pflanze Jun 12, 2024
4b30116
feat: test runners: bin/preprocessing-in: fix path to build dir
pflanze Jul 1, 2024
234ff15
feat: test runners: add `clean` target
pflanze Aug 27, 2024
0be1dfd
TMP remove failing tests
pflanze Sep 22, 2024
3afde55
docs: add documentation to AbstractConfigSource
pflanze May 31, 2024
c1256d3
fix: runtime_config: read port as uint16
pflanze May 28, 2024
9ce133e
style: api.cpp: use more descriptive variable/function names
pflanze May 28, 2024
57e61ae
feat!: add `api` prefix to config
pflanze May 31, 2024
a7eaad2
feat!: change casing of command line arguments to kebab-case
pflanze May 31, 2024
ba81184
refactor: add AbstractConfigSource::getUInt64
pflanze May 31, 2024
7c6c3d9
feat: add materializationCutoff option
pflanze May 31, 2024
bb62104
feat!: provide separate 'siloServer' and 'siloPreprocessor' programs
pflanze Sep 23, 2024
337c608
fix: --database-config config option as unix option string
pflanze Sep 23, 2024
a4e0555
refactor: test runners: update for separate 'siloServer' and 'siloPre…
pflanze Jun 17, 2024
1f657d7
fix: exit program if --help option was provided
pflanze Sep 23, 2024
9b6354b
-doc the options where?
pflanze Sep 23, 2024
72f960a
docs: document `AbstractConfigSource`
pflanze Sep 23, 2024
3f5d5e4
fix: api: print startup message after finishing option parsing
pflanze Sep 23, 2024
50a5285
style: consistent variable naming
pflanze Sep 23, 2024
d760240
- PREPROCESSING_CONFIG_OPTION + RUNTIME_CONFIG_OPTION become kebab ca…
pflanze Sep 23, 2024
624e441
refactor: rename silo_api/{api,main}.cpp
pflanze Sep 23, 2024
52d079d
refactor!: main: remove default preprocessing_config config files
pflanze Sep 23, 2024
1596bb6
refactor: main: factor out `getConfig`
pflanze Sep 23, 2024
9fa0c14
- refactor: preprocessing_config: generate from macros, add `database…
pflanze Sep 23, 2024
e6f7a44
-fixup! sq back dewarn
pflanze Oct 1, 2024
7fed070
-fixup! -the last removal of addDatabaseConfigOption call
pflanze Sep 30, 2024
49a5675
-fixup! -remove addDatabaseConfigOption finish --database-config REMO…
pflanze Sep 30, 2024
bc6d729
-fixup! - generate accessors, too (still for preprocessing_config only)
pflanze Sep 30, 2024
0dc3655
-fixup! -add getDatabaseConfigFilename (correct base folder? and logi…
pflanze Sep 30, 2024
6325a37
- runtime_config.h fmt::formatter implementation (Alex' hint)
pflanze Oct 1, 2024
fddbbcb
- runtime_config.cpp generated fmt::formatter
pflanze Oct 1, 2024
12db14d
- preprocessing_config.cpp : macro-based fmt::format (?, no see fn name)
pflanze Oct 1, 2024
e4ecffe
- preprocessing_config.{h,cpp} rename-identifier HAS_DEFAULT DEFAULT_…
pflanze Oct 1, 2024
1549c35
- preprocessing_config.cpp rename-identifier YES HAS_DEFAULT rename-i…
pflanze Oct 1, 2024
8e96c6c
- preprocessing_config.cpp "okay what is wrong?"
pflanze Oct 1, 2024
6061c6f
- preprocessing_config.cpp formatters
pflanze Oct 1, 2024
27ff970
- add fmt_formatters.h + fmt_formatters.cpp (Alex)
pflanze Oct 1, 2024
d9aab3f
-docs: todo: wrong docs
pflanze Oct 8, 2024
9654b8b
- config reading here, too (untested)
pflanze Oct 8, 2024
e7d1368
- HACK: show program arguments
pflanze Oct 8, 2024
3fb0bd7
chore: .gitignore: ignore generated files
pflanze Oct 20, 2024
36be39b
- new command line parser, translated from Rust
pflanze Nov 2, 2024
a32d01e
- multi-call mode handling
pflanze Nov 4, 2024
e9ddc05
wip
Taepper Nov 18, 2024
d6d8c8b
rebase follow-up
Taepper Nov 20, 2024
fa305df
tmp
pflanze Nov 7, 2024
125ee91
rebase follow-up finished
Taepper Nov 20, 2024
e730798
fixes
Taepper Nov 20, 2024
78b4013
fixes
Taepper Nov 20, 2024
2db56e4
fixes
Taepper Nov 20, 2024
ce0c287
wip
Taepper Nov 20, 2024
2de5a23
wip
Taepper Nov 21, 2024
d9291e4
wip
Taepper Nov 21, 2024
5e55e81
wip
Taepper Nov 21, 2024
fa6e956
refactoring mostly complete, some TODO items remain. And a final chec…
Taepper Nov 21, 2024
ad79d7a
fix the default value logic
Taepper Nov 21, 2024
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
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -69,3 +69,6 @@ conanprofile
**/temp/

**/node_modules/


/test*
10 changes: 0 additions & 10 deletions .run/silo --api.run.xml

This file was deleted.

10 changes: 0 additions & 10 deletions .run/silo --preprocessing.run.xml

This file was deleted.

10 changes: 10 additions & 0 deletions .run/silo api.run.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="silo api" type="CMakeRunConfiguration" factoryName="Application" PROGRAM_PARAMS="api --data-directory output/ --api-estimated-startup-time-in-minutes 2" REDIRECT_INPUT="false" ELEVATE="false" USE_EXTERNAL_CONSOLE="false" EMULATE_TERMINAL="false" WORKING_DIR="file://.." PASS_PARENT_ENVS_2="true" PROJECT_NAME="SILO" TARGET_NAME="silo" CONFIG_NAME="Debug" RUN_TARGET_PROJECT_NAME="SILO" RUN_TARGET_NAME="silo">
<envs>
<env name="SPDLOG_LEVEL" value="debug" />
</envs>
<method v="2">
<option name="com.jetbrains.cidr.execution.CidrBuildBeforeRunTaskProvider$BuildBeforeRunTask" enabled="true" />
</method>
</configuration>
</component>
10 changes: 10 additions & 0 deletions .run/silo preprocessing.run.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="silo preprocessing" type="CMakeRunConfiguration" factoryName="Application" PROGRAM_PARAMS="preprocessing --preprocessing-config testBaseData/test_preprocessing_config.yaml --database-config database_config.yaml --preprocessing-config testBaseData/exampleDataset/preprocessing_config.yaml" REDIRECT_INPUT="false" ELEVATE="false" USE_EXTERNAL_CONSOLE="false" EMULATE_TERMINAL="false" WORKING_DIR="file://../" PASS_PARENT_ENVS_2="true" PROJECT_NAME="SILO" TARGET_NAME="silo" CONFIG_NAME="Debug" RUN_TARGET_PROJECT_NAME="SILO" RUN_TARGET_NAME="silo">
<envs>
<env name="SPDLOG_LEVEL" value="debug" />
</envs>
<method v="2">
<option name="com.jetbrains.cidr.execution.CidrBuildBeforeRunTaskProvider$BuildBeforeRunTask" enabled="true" />
</method>
</configuration>
</component>
6 changes: 3 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ file(GLOB_RECURSE SRC_SILO "src/*.cpp")
list(REMOVE_ITEM SRC_SILO ${SRC_TEST})

set(SRC_SILO_WITHOUT_MAIN ${SRC_SILO})
list(REMOVE_ITEM SRC_SILO_WITHOUT_MAIN "${CMAKE_SOURCE_DIR}/src/silo_api/api.cpp")
list(REMOVE_ITEM SRC_SILO_WITHOUT_MAIN "${CMAKE_SOURCE_DIR}/src/main.cpp")

# ---------------------------------------------------------------------------
# Linter
Expand Down Expand Up @@ -105,9 +105,9 @@ target_link_libraries(
re2::re2
)

add_executable(siloApi "${CMAKE_SOURCE_DIR}/src/silo_api/api.cpp" $<TARGET_OBJECTS:silolib>)
add_executable(silo "${CMAKE_SOURCE_DIR}/src/main.cpp" $<TARGET_OBJECTS:silolib>)
target_link_libraries(
siloApi
silo
PUBLIC
silolib
)
Expand Down
6 changes: 3 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@ COPY . ./
RUN \
python3 ./build_with_conan.py --release --parallel 4\
&& cp build/Release/silo_test . \
&& cp build/Release/siloApi .
&& cp --no-dereference build/Release/{silo,siloServer,siloPreprocessor} .


FROM ubuntu:22.04 AS server

WORKDIR /app
COPY docker_default_preprocessing_config.yaml ./default_preprocessing_config.yaml
COPY docker_runtime_config.yaml ./runtime_config.yaml
COPY --from=builder /src/siloApi ./
COPY --from=builder /src/{silo,siloServer,siloPreprocessor} ./

RUN apt update && apt dist-upgrade -y \
&& apt install -y libtbb12 curl jq
Expand All @@ -25,7 +25,7 @@ HEALTHCHECK --start-period=20s CMD curl --fail --silent localhost:8081/info | jq

EXPOSE 8081

ENTRYPOINT ["./siloApi"]
ENTRYPOINT ["./silo"]

LABEL org.opencontainers.image.source="https://github.com/GenSpectrum/LAPIS-SILO"
LABEL org.opencontainers.image.description="Sequence Indexing engine for Large Order of genomic data"
61 changes: 61 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
# Note: you can set the COLOR environment variable to 1 to get the log
# files produced with color codes.

export PATH := bin:$(PATH)

all: build/siloServer build/siloPreprocessor build/silo_test

clean:
find build -name "*.o" -print0 | xargs -0 rm -f
rm -f build/siloApi build/silo_test

# Have separate targets for the binaries, but share a single build
# (faster to build them both?); use `run-cached` to only actually run one
# build, though.

build/siloServer: build/silo

build/siloPreprocessor: build/silo

build/silo: $(shell bin/cplusplus-source-files)
run-cached build/.exit-code build $@

build/silo_test: $(shell bin/cplusplus-source-files)
run-cached build/.exit-code build $@


# Tests produce log files if successful (if not successful, the log
# file can be found with .tmp appended, but is also printed to stdout).

build/unit-tests.log: build/silo_test
run-with-log $@ build/silo_test

build/preprocessing-tsv.log: \
build/siloPreprocessor \
$(shell bin/preprocessing-input-files-in testBaseData/exampleDataset)
run-with-log $@ preprocessing-in testBaseData/exampleDataset

build/preprocessing-ndjson.log: \
build/siloPreprocessor \
$(shell bin/preprocessing-input-files-in testBaseData/exampleDatasetAsNdjson)
run-with-log $@ preprocessing-in testBaseData/exampleDatasetAsNdjson

build/tsv-tests.log: build/siloServer build/preprocessing-tsv.log $(shell bin/test-query-files)
run-with-log $@ runtests-e2e testBaseData/exampleDataset 7001

build/ndjson-tests.log: build/siloServer build/preprocessing-ndjson.log $(shell bin/test-query-files)
run-with-log $@ runtests-e2e testBaseData/exampleDatasetAsNdjson 7002

test: build/unit-tests.log build/tsv-tests.log build/ndjson-tests.log


# Manually run the api so that it can be queried interactively.

runapi-tsv: build/siloServer build/preprocessing-tsv.log
runapi-in testBaseData/exampleDataset 8081

runapi-ndjson: build/siloServer build/preprocessing-tsv.log
runapi-in testBaseData/exampleDatasetAsNdjson 8081


.PHONY: all clean test runapi-tsv runapi-ndjson
52 changes: 52 additions & 0 deletions bin/build
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
#!/bin/bash
set -meuo pipefail
IFS=

usage() {
echo "usage: $0 [...]"
echo " Auto-detect the mold linker and ninja builder and"
echo " call cmake accordingly. Requires up to date configuration"
echo " via conan first. Currently only fully runs on Linux and"
echo " Mac OS, detection for core count on Windows is missing."
echo " Arguments are passed on to make/ninja."
exit 1
}

if [[ $# -gt 0 ]] && { [[ "$1" = "-h" ]] || [[ "$1" = "--help" ]] ; }; then
usage
fi

args=(../)

if _mold_path=$(which mold); then
args=("${args[@]}" -D CMAKE_EXE_LINKER_FLAGS=-fuse-ld=mold)
fi

if _ninja_path=$(which ninja); then
args=("${args[@]}" -G Ninja)
make=(ninja)
else
# Linux: /proc/cpuinfo
# Mac OS: sysctl -n hw.ncpu
corecount=$(grep -c ^processor /proc/cpuinfo || sysctl -n hw.ncpu)
make=(make "-j$corecount")
fi

_do() {
echo "+" "$@"
"$@"
}

_do cd build
_do cmake "${args[@]}"
# Make all binaries..
_do "${make[@]}"

# ..but touch the desired ones afterwards for the top-level Makefile's
# sake (XX sigh, alternatives?)
#if [ $# -gt 0 ]; then
# cd ..
# touch "$@"
#fi
# --- nah, just let it re-run build, sadly, still better than re-running tests unnecessarily.

6 changes: 6 additions & 0 deletions bin/cplusplus-source-files
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/bin/bash
set -meuo pipefail
IFS=

find src/ include/ -name "*.h" -o -name "*.cpp" | grep -v '#'

11 changes: 11 additions & 0 deletions bin/gco-make-test
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/bin/bash
set -emuo pipefail
IFS=

set -x

while read -r commit; do
git checkout "$commit"
make -j16 test
done

33 changes: 33 additions & 0 deletions bin/preprocessing-in
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#!/bin/bash
set -meuo pipefail
IFS=

usage() {
echo "$0 test-input-dir" >&2
false
}

if [[ $# != 1 ]]; then
usage
fi
if [[ "$1" == "-h" ]] || [[ "$1" == "--help" ]]; then
usage
fi
testdir="$1"
mypath=$(readlink -f "$0")
mydir=$(dirname "$mypath")
builddir=$(dirname "$mydir")/build

IFS=' '

set +x

rm -rf temp

cd "$testdir"

rm -rf {output,temp,test?*}


#SPDLOG_LEVEL=debug
${DEBUGGER-} "$builddir"/siloPreprocessor
7 changes: 7 additions & 0 deletions bin/preprocessing-input-files-in
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/bin/bash
set -meuo pipefail
IFS=

# preprocessing inputs
bin/verified-find "$1" -maxdepth 1 -a \( -name "*.fasta" -o -name "*.yaml" -o -name "*.xz" \
-o -name "*.zst" -o -name "*.json" -o -name "*.tsv" -o -name "*.ndjson" \)
80 changes: 80 additions & 0 deletions bin/run-cached
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
#!/bin/bash
set -meuo pipefail
IFS=

usage() {
echo "usage: $0 [-v|--verbose] file-for-exitcode cmd [args...]"
echo " Takes a lock on file-for-exitcode, if it gets the lock,"
echo " runs cmd with args and stores the exit code in file-for-exitcode."
echo " If the file is already locked, waits until unlocked then reads"
echo " the file contents as the exit code."
echo " Exits with the exitcode in either case."
echo " If -v/--verbose is given, prints to stderr when it's waiting for"
echo " another instance."
exit 1
}

if [[ $# -lt 1 ]]; then
usage
fi

if [[ "$1" = -v ]] || [[ "$1" = --verbose ]]; then
verbose=1
shift
else
verbose=0
fi

if [[ $# -lt 2 ]]; then
usage
fi

cachepath="$1"
shift

info() {
if [[ "$verbose" = 1 ]]; then
echo "$@" >&2
fi
}


# Open the cache file read/write to an unused file descriptor.
exec {fd}<>"$cachepath"

if flock -E77 --nonblock "$fd"; then
# We have an exclusive lock, so we are supposed to run the cmd;
# don't fail if it doesn't exit successfully.

# Remove previously stored code. (Have to reopen, `>&"$fd"` does
# not truncate.)
true > "$cachepath"

if "$@"; then
code=$?
else
code=$?
fi
echo "$code" >&"$fd"
exit "$code"
else
e=$?
if [[ "$e" == 77 ]]; then
# Another instance is running the command already; wait it out
# then read out the exit code.
info -n "$0 $cachepath: waiting for concurrent run to finish..."
flock "$fd"
# `read` will fail if the file is empty (possible if the other
# $0-instance was killed)
if read -r code <&"$fd"; then
info "exited with code $code"
exit "$code"
else
info "other $0 instance was killed"
exit 130
fi
else
echo "$0: got exit code $e, is the 'flock' command not available?" >&2
false
fi
fi
Loading
Loading