Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
ae2dbf5
Add indexing to service
jbeilstenedmands Oct 10, 2025
67b6e52
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Oct 10, 2025
b2017c8
Merge branch 'main' into add_live_indexing_to_service
jbeilstenedmands Oct 23, 2025
42e103c
Add unit cell validator to convert input from ispyb
jbeilstenedmands Oct 23, 2025
b2640ae
Updates to detector metadata handling
jbeilstenedmands Oct 23, 2025
62f366c
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Oct 23, 2025
8aa4aba
Calculate mu based on detector
jbeilstenedmands Oct 24, 2025
40b16b8
Tidy pydantic models
jbeilstenedmands Oct 24, 2025
1f5d726
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Oct 24, 2025
003d302
Fetch and build ffbidx with cmake
jbeilstenedmands Oct 30, 2025
a13c367
Merge branch 'main' into add_live_indexing_to_service
jbeilstenedmands Nov 6, 2025
80206d0
Merge branch 'main' into add_live_indexing_to_service
jbeilstenedmands Jan 29, 2026
1cd2892
Add numpy to env to make available in docker image
jbeilstenedmands Feb 2, 2026
d0ff4eb
Update for ffbidx inclusion
jbeilstenedmands Feb 2, 2026
0b8c3d5
No ifs
jbeilstenedmands Feb 2, 2026
003eb62
Merge branch 'main' into add_live_indexing_to_service
jbeilstenedmands Feb 3, 2026
7964253
change tag for testing
jbeilstenedmands Feb 3, 2026
31880ff
add numpy to runtime env
jbeilstenedmands Feb 4, 2026
a2d43ee
Revert "add numpy to runtime env"
jbeilstenedmands Feb 4, 2026
61f3830
Make sure python install paths set
jbeilstenedmands Feb 4, 2026
1460e95
Install properly
jbeilstenedmands Feb 4, 2026
cc348e8
Fix installation of indexing module, add ffbidx
ndevenish Feb 4, 2026
8dfcaac
Build/install everything, and install ssx_index as a script
ndevenish Feb 4, 2026
18d1d12
Add JBE to authors
jbeilstenedmands Feb 5, 2026
acc63ae
revert image tag to latest
jbeilstenedmands Feb 6, 2026
e60d7ea
Merge branch 'main' into add_live_indexing_to_service
jbeilstenedmands Feb 6, 2026
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
2 changes: 2 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ Makefile
*.tar
.*_cache
ENV/
*.so
# This is better, but doesn't work with podman. sigh.
# *
# !**/CMakeLists.txt
Expand All @@ -24,3 +25,4 @@ ENV/
# !**/*.cc
# !**/*.cpp
# !**/*.h

22 changes: 17 additions & 5 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,9 @@ include(AlwaysColourCompilation)

include_directories(include)

# Find Python
find_package(Python3 COMPONENTS Interpreter Development REQUIRED)
include_directories(${Python3_INCLUDE_DIRS})
find_package(Python COMPONENTS Interpreter Development.Module NumPy REQUIRED)

# Dependency fetching
# Find packages that are in conda environment
find_package(fmt REQUIRED)
find_package(spdlog REQUIRED)
Expand All @@ -72,6 +71,21 @@ FetchContent_Declare(
)
FetchContent_MakeAvailable(argparse)

# Required for Python module build of ffbidx
set(BUILD_FAST_INDEXER ON CACHE BOOL "" FORCE)
set(PYTHON_MODULE ON CACHE BOOL "" FORCE)
set(PYTHON_MODULE_RPATH ON CACHE BOOL "" FORCE)

# ffbidx uses this to find site-packages
set(PYTHON_MODULE_PATH ${Python_SITEARCH} CACHE PATH "ffbidx python site-packages path" FORCE)

FetchContent_Declare(
ffbidx
GIT_REPOSITORY https://github.com/paulscherrerinstitute/fast-feedback-indexer.git
GIT_TAG main
)
FetchContent_MakeAvailable(ffbidx)

# GTest - try find_package first, fallback to FetchContent
find_package(GTest QUIET)
if(NOT GTest_FOUND AND NOT TARGET GTest::gtest_main)
Expand Down Expand Up @@ -191,5 +205,3 @@ add_subdirectory(h5read)
add_subdirectory(baseline)
add_subdirectory(spotfinder)
add_subdirectory(integrator)

configure_file(${CMAKE_SOURCE_DIR}/scripts/ssx_index ${CMAKE_BINARY_DIR}/bin/ssx_index COPYONLY)
19 changes: 10 additions & 9 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -24,29 +24,30 @@ RUN micromamba create -y -f /opt/runtime-environment.yml -p /opt/ffs

# Copy source
COPY . /opt/ffs_src
ENV CMAKE_GENERATOR Ninja

# Build the C++/CUDA backend
WORKDIR /opt/build
RUN cmake /opt/ffs_src -G Ninja -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/opt/ffs -DHDF5_ROOT=/opt/ffs -DCUDA_ARCH=80
RUN cmake --build . --target spotfinder --target spotfinder32
RUN cmake /opt/ffs_src \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_INSTALL_PREFIX=/opt/ffs \
-DHDF5_ROOT=/opt/ffs \
-DPython3_ROOT_DIR=/opt/ffs \
-DCUDA_ARCH=80

RUN cmake --install . --component Runtime
RUN cmake --build .

# Build and install dx2 submodule
WORKDIR /opt/build_dx2
RUN cmake /opt/ffs_src/dx2 -G Ninja -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/opt/ffs
RUN cmake --build . && cmake --install .
RUN cmake --install .

# Install Python package
WORKDIR /opt/build
RUN SETUPTOOLS_SCM_PRETEND_VERSION_FOR_FFS=1.0 /opt/ffs/bin/pip3 install /opt/ffs_src

# Now copy this into an isolated runtime container
FROM nvcr.io/nvidia/cuda:${CUDA_VERSION}-runtime-ubuntu24.04

LABEL org.opencontainers.image.title="fast-feedback-service" \
org.opencontainers.image.description="GPU-accelerated fast-feedback X-ray diffraction analysis service" \
org.opencontainers.image.authors="Nicholas Devenish <nicholas.devenish@diamond.ac.uk>, Dimitrios Vlachos <dimitrios.vlachos@diamond.ac.uk>" \
org.opencontainers.image.authors="Nicholas Devenish <nicholas.devenish@diamond.ac.uk>, Dimitrios Vlachos <dimitrios.vlachos@diamond.ac.uk>, James Beilsten-Edmands <james.beilsten-edmands@diamond.ac.uk>" \
org.opencontainers.image.source="https://github.com/DiamondLightSource/fast-feedback-service" \
org.opencontainers.image.licenses="BSD-3-Clause"

Expand Down
10 changes: 6 additions & 4 deletions baseline/indexer/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,11 @@ target_link_libraries(baseline_indexer
# Create Python module
nanobind_add_module(index index_module.cpp)
target_include_directories(index PRIVATE ${CMAKE_SOURCE_DIR}/baseline/predictor)
target_link_libraries(index PRIVATE Eigen3::Eigen dx2 ${Python3_LIBRARIES})
target_link_libraries(index PRIVATE Eigen3::Eigen dx2 Python::Module)

set(PYTHON_MODULE_DIR ${CMAKE_SOURCE_DIR}/src/ffs)
add_custom_command(TARGET index POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy $<TARGET_FILE:index> ${PYTHON_MODULE_DIR}

# Install into the runtime Python sitearch
install(TARGETS index
LIBRARY DESTINATION ${Python_SITEARCH}/ffs
COMPONENT Runtime
)
5 changes: 5 additions & 0 deletions baseline/indexer/index_module.cpp
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
#include <nanobind/eigen/dense.h>
#include <nanobind/nanobind.h>
#include <nanobind/stl/array.h>
#include <nanobind/stl/string.h>
#include <nanobind/stl/tuple.h>
#include <nanobind/stl/vector.h>

#include <dx2/crystal.hpp>
#include <dx2/detector.hpp>
#include <dx2/detector_attenuations.hpp>
#include <dx2/reflection.hpp>
#include <experimental/mdspan>
#include <tuple>
Expand Down Expand Up @@ -220,6 +222,9 @@ NB_MODULE(index, m) {
.def_prop_ro("delpsi", [](const IndexingResult &r) { return r.delpsi; })
.def_prop_ro("rmsds", [](const IndexingResult &r) { return r.rmsds; });
m.def("make_panel", &make_panel, "Create a configured Panel object");
m.def("calculate_mu_for_material_at_wavelength",
&calculate_mu_for_material_at_wavelength,
"Calculate the absorption coefficient from material and wavelength");
m.def("ssx_xyz_to_rlp",
&ssx_xyz_to_rlp,
nb::arg("xyzobs_px"),
Expand Down
11 changes: 11 additions & 0 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,17 @@ build_directory() {
make -j"$JOBS"
fi
)

# Install
print_status "Installing $description..."
(
cd "$build_dir"
if [[ "$BUILD_CMD" == "ninja" ]]; then
ninja "install"
else
make "install" -j"$JOBS"
fi
)

print_success "Successfully built $description"
}
Expand Down
2 changes: 1 addition & 1 deletion chart/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,4 @@ podSecurityContext:
# Container-level security context
containerSecurityContext:
# k8s-i24-beamline user
runAsUser: 36145
runAsUser: 36145
1 change: 1 addition & 0 deletions environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ dependencies:
- hdf5=1.14.6
- hdf5-external-filter-plugins=0.1.0
- nlohmann_json=3.12.0
- numpy=2.3.4
- pre-commit=4.3.0
- pydantic=2.12.3
- pytest=8.4.2
Expand Down
4 changes: 4 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ readme = "README.md"
authors = [
{ name = "Nicholas Devenish", email = "ndevenish@gmail.com" },
{ name = "Dimitri Vlachos", email = "dimitrios.vlachos@diamond.ac.uk" },
{ name = "James Beilsten-Edmands", email = "james.beilsten-edmands@diamond.ac.uk"},
]

requires-python = ">=3.12"
Expand All @@ -22,6 +23,9 @@ dependencies = [
"zocalo>=1.2.0",
]

[project.scripts]
ssx_index = "ffs.ssx_index:run"

[dependency-groups]
dev = [
"pytest",
Expand Down
2 changes: 2 additions & 0 deletions runtime-environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,12 @@ dependencies:
- gemmi=0.7.3
- hdf5=1.14.6
- hdf5-external-filter-plugins=0.1.0
- h5py
- python=3.13.7
- pip
- zocalo
- workflows
- pydantic
- rich
- spdlog=1.15.3
- numpy=2.3.4
Loading