HDF5NXmx: Improve error handling
Build Packages / build:rpm (ubuntu2204_nocuda) (push) Failing after 8m31s
Build Packages / build:rpm (rocky9_nocuda) (push) Failing after 10m5s
Build Packages / build:rpm (ubuntu2404_nocuda) (push) Failing after 10m4s
Build Packages / build:rpm (rocky8_nocuda) (push) Failing after 10m24s
Build Packages / build:rpm (rocky8_sls9) (push) Failing after 11m57s
Build Packages / build:rpm (rocky8) (push) Failing after 11m53s
Build Packages / build:rpm (rocky9) (push) Failing after 11m57s
Build Packages / build:rpm (rocky9_sls9) (push) Failing after 12m4s
Build Packages / Generate python client (push) Successful in 1m30s
Build Packages / Build documentation (push) Successful in 2m13s
Build Packages / Create release (push) Has been skipped
Build Packages / build:rpm (ubuntu2204) (push) Failing after 7m40s
Build Packages / build:rpm (ubuntu2404) (push) Failing after 7m31s
Build Packages / XDS test (durin plugin) (push) Successful in 9m31s
Build Packages / XDS test (neggia plugin) (push) Successful in 10m30s
Build Packages / XDS test (JFJoch plugin) (push) Failing after 10m42s
Build Packages / Unit tests (push) Failing after 9m46s
Build Packages / DIALS test (push) Successful in 13m42s

This commit is contained in:
2026-05-05 19:36:14 +02:00
parent e2e6fc909f
commit bc41e19a70
4 changed files with 64 additions and 50 deletions
+1
View File
@@ -325,6 +325,7 @@ jobs:
run: |
cd build/tests
LD_PRELOAD=enospc_shim.so ./jfjoch_hdf5_enospc_test HDF5File_enospc
LD_PRELOAD=enospc_shim.so ./jfjoch_hdf5_enospc_test FileWriter_enospc
- name: Run hdf5 test
shell: bash
run: |
+8 -1
View File
@@ -7,6 +7,7 @@
#include "../writer/HDF5Objects.h"
#include "../writer/FileWriter.h"
#include "../common/DiffractionExperiment.h"
#include <iostream>
TEST_CASE("HDF5File_enospc") {
auto file = std::make_unique<HDF5File>("enospc_test.h5");
@@ -25,7 +26,8 @@ TEST_CASE("FileWriter_enospc") {
RegisterHDF5Filter();
DiffractionExperiment x(DetJF4M());
x.FilePrefix("test02_1p10").ImagesPerTrigger(5).ImagesPerFile(2).Compression(CompressionAlgorithm::NO_COMPRESSION);
x.FilePrefix("fw_enospc").ImagesPerTrigger(5).ImagesPerFile(2).Compression(CompressionAlgorithm::NO_COMPRESSION)
.SetFileWriterFormat(FileWriterFormat::NXmxVDS);
StartMessage start_message;
x.FillMessage(start_message);
@@ -40,6 +42,11 @@ TEST_CASE("FileWriter_enospc") {
REQUIRE_THROWS(file_set.Write(message));
message.number = 2;
REQUIRE_THROWS(file_set.Write(message));
EndMessage end_message{
.max_image_number = 3
};
REQUIRE_THROWS(file_set.WriteHDF5(end_message));
}
// No leftover HDF5 objects
REQUIRE (H5Fget_obj_count(H5F_OBJ_ALL, H5F_OBJ_ALL) == 0);
-1
View File
@@ -15,7 +15,6 @@ FileWriter::FileWriter(const StartMessage &request)
if (start_message.file_format)
format = start_message.file_format.value();
// defailt
if (start_message.images_per_file <= 0)
start_message.images_per_file = default_images_per_file;
+55 -48
View File
@@ -699,56 +699,63 @@ void NXmx::ADUHistogram(const EndMessage &end) {
}
void NXmx::Finalize(const EndMessage &end) {
if (!hdf5_file)
throw JFJochException(JFJochExceptionCategory::FileWriteError, "HDF5 file already closed");
if (end.end_date) {
hdf5_file->Attr("file_time", end.end_date.value());
hdf5_file->SaveScalar("/entry/end_time", end.end_date.value());
hdf5_file->SaveScalar("/entry/end_time_estimated", end.end_date.value());
} else {
std::string time_now = time_UTC(std::chrono::system_clock::now());
hdf5_file->Attr("file_time", time_now);
hdf5_file->SaveScalar("/entry/end_time", time_now);
hdf5_file->SaveScalar("/entry/end_time_estimated", time_now);
try {
if (!hdf5_file)
throw JFJochException(JFJochExceptionCategory::FileWriteError, "HDF5 file already closed");
if (end.end_date) {
hdf5_file->Attr("file_time", end.end_date.value());
hdf5_file->SaveScalar("/entry/end_time", end.end_date.value());
hdf5_file->SaveScalar("/entry/end_time_estimated", end.end_date.value());
} else {
std::string time_now = time_UTC(std::chrono::system_clock::now());
hdf5_file->Attr("file_time", time_now);
hdf5_file->SaveScalar("/entry/end_time", time_now);
hdf5_file->SaveScalar("/entry/end_time_estimated", time_now);
}
Detector(start_message, end);
Sample(start_message, end);
AzimuthalIntegration(start_message, end);
ADUHistogram(end);
switch (start_message.file_format.value_or(FileWriterFormat::NXmxLegacy)) {
case FileWriterFormat::NXmxLegacy:
LinkToData(start_message, end);
break;
case FileWriterFormat::NXmxVDS:
LinkToData_VDS(start_message, end);
break;
case FileWriterFormat::NXmxIntegrated:
default:
break;
}
if (end.rotation_lattice)
SaveVector(*hdf5_file, "/entry/MX/rotationLatticeIndexed", end.rotation_lattice->GetVector())
->Units("Angstrom");
if (end.rotation_lattice_type)
SaveScalar(*hdf5_file, "/entry/MX/rotationLatticeNiggliClass", end.rotation_lattice_type->niggli_class);
if (end.indexing_rate) {
SaveScalar(*hdf5_file, "/entry/MX/imageIndexedMean", end.indexing_rate.value());
}
if (end.bkg_estimate) {
SaveScalar(*hdf5_file, "/entry/MX/bkgEstimateMean", end.bkg_estimate.value());
}
if (!end.scale_factor.empty())
SaveVector(*hdf5_file, "/entry/MX/imageScaleFactor", end.scale_factor);
hdf5_file->Close();
hdf5_file.reset();
} catch (const JFJochException &e) {
hdf5_file.reset();
std::error_code ec;
std::filesystem::remove(tmp_filename, ec);
throw;
}
Detector(start_message, end);
Sample(start_message, end);
AzimuthalIntegration(start_message, end);
ADUHistogram(end);
switch (start_message.file_format.value_or(FileWriterFormat::NXmxLegacy)) {
case FileWriterFormat::NXmxLegacy:
LinkToData(start_message, end);
break;
case FileWriterFormat::NXmxVDS:
LinkToData_VDS(start_message, end);
break;
case FileWriterFormat::NXmxIntegrated:
default:
break;
}
if (end.rotation_lattice)
SaveVector(*hdf5_file, "/entry/MX/rotationLatticeIndexed", end.rotation_lattice->GetVector())
->Units("Angstrom");
if (end.rotation_lattice_type)
SaveScalar(*hdf5_file, "/entry/MX/rotationLatticeNiggliClass", end.rotation_lattice_type->niggli_class);
if (end.indexing_rate) {
SaveScalar(*hdf5_file, "/entry/MX/imageIndexedMean", end.indexing_rate.value());
}
if (end.bkg_estimate) {
SaveScalar(*hdf5_file, "/entry/MX/bkgEstimateMean", end.bkg_estimate.value());
}
if (!end.scale_factor.empty())
SaveVector(*hdf5_file, "/entry/MX/imageScaleFactor", end.scale_factor);
hdf5_file->Close();
hdf5_file.reset();
if (std::filesystem::exists(filename) && !overwrite)
throw JFJochException(JFJochExceptionCategory::FileWriteError, "File already exists");