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

Update nwbinspector validation workflow #122

Merged
merged 4 commits into from
Jan 8, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
6 changes: 5 additions & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -141,4 +141,8 @@ jobs:
run: |
python -m pip install --upgrade pip
python -m pip install nwbinspector
nwbinspector nwb_files --threshold BEST_PRACTICE_VIOLATION
nwbinspector nwb_files --threshold BEST_PRACTICE_VIOLATION --json-file-path out.json
if ! grep -q '"messages": \[\]' out.json; then
echo "NWBInspector found issues in the NWB files"
Copy link
Contributor

Choose a reason for hiding this comment

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

It would be nice to also print the contents of the out.txt file to the command-line to make it easy to see the issues found in the GitHub Action directly. I would also rename out.txt to out.json

Copy link
Collaborator Author

@stephprince stephprince Jan 8, 2025

Choose a reason for hiding this comment

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

It would be nice to also print the contents of the out.txt file to the command-line to make it easy to see the issues found in the GitHub Action directly.

The report summary should be printed out and formatted automatically by running nwbinspector (see the Install pynwb and run validation step here), in this action there are 0 issues found but otherwise it will print the issues in the GitHub Action.

I would also rename out.txt to out.json

Will do!

exit 1
fi
4 changes: 2 additions & 2 deletions tests/testNWBFile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ TEST_CASE("createElectricalSeries", "[nwb]")

// write timeseries data
std::vector<float> mockData = {1.0f, 2.0f, 3.0f, 4.0f, 5.0f};
std::vector<double> mockTimestamps = {0.1, 0.2, 0.3, 0.4, 0.5};
std::vector<double> mockTimestamps = {0.1, 0.3, 0.4, 0.5, 0.8};
std::vector<SizeType> positionOffset = {0, 0};
std::vector<SizeType> dataShape = {mockData.size(), 0};

Expand Down Expand Up @@ -105,7 +105,7 @@ TEST_CASE("createMultipleEcephysDatasets", "[nwb]")

// write electrical series data
std::vector<float> mockData = {1.0f, 2.0f, 3.0f, 4.0f, 5.0f};
std::vector<double> mockTimestamps = {0.1, 0.2, 0.3, 0.4, 0.5};
std::vector<double> mockTimestamps = {0.1, 0.3, 0.4, 0.5, 0.8};
std::vector<SizeType> positionOffset = {0, 0};
std::vector<SizeType> dataShape = {mockData.size(), 0};

Expand Down
14 changes: 11 additions & 3 deletions tests/testUtils.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -100,14 +100,22 @@ inline std::vector<std::vector<float>> getMockData2D(SizeType numSamples = 1000,
}

inline std::vector<double> getMockTimestamps(SizeType numSamples = 1000,
SizeType samplingRate = 30000)
SizeType samplingRate = 30000,
double maxOffset = 0.00001)
{
std::vector<double> mockTimestamps(numSamples);
double samplingPeriod = 1.0 / samplingRate;

std::random_device rd;
std::mt19937 rng(rd()); // random number generator
std::uniform_real_distribution<> dis(-maxOffset,
maxOffset); // range of floats

for (SizeType i = 0; i < numSamples; ++i) {
mockTimestamps[i] = i * samplingPeriod; // Each timestamp is the sample
// number times the sampling period
// Each timestamp is the sample number times the sampling period with an
// offset
double offset = dis(rng);
mockTimestamps[i] = i * samplingPeriod + offset;
}

return mockTimestamps;
Expand Down
Loading