-
Notifications
You must be signed in to change notification settings - Fork 0
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
DSEGOG-267 HDF ingestion validity checks #93
Conversation
added checks from word document missing some channel checks
added more file tests added some pytests combined pytests into better groups
made sure all of the file checks work and don't cause any errors where it should have passed
changed some of the models so that they don't cause the channel to be rejected instead the channel is rejected inside the ingestion validator giving a nicer error
expected failed responses for channel_dtype pytests work code has been linted also (some of the linting does fail but that will be fixed in a later commit)
need to create a mock for some of these as impossible with normal pytest tests for image_path, path, waveform_id, id_ will be created in a later commit
may need to add more to them to ensure they work on all cases
may need to add further checks at a later point
while making the tests I fixed some hidden bugs in the validator code such as if the channel name was wrong the code would fail as it made use of the channel name in the manifest may need to add further tests in another commit to test different variations
by adding the check into the hdf_handler.py file the unrecognised_attribute_checks, has become Obsolete apart from a small art at the end This may need to be adressed in a later commit
added tests for the function that runs all of the channel checks more comprehensive pytests of this function will be added in a later commit
- need to finalise code for channel checks as some isn't used any more - need to lint the code and make parts less complicated - need to implement the checks into the actual code
increased the number of lines pytests covered for ingestion_validator.py simplified functions and removed unused code
simplified complex functions removed unused parts of code started planning where the checks go on ingest started writing integration tests updated: test/endpoints/test_get_records.py::TestGetRecords::test_valid_get_records[Query using a single projection] pytest with new metadata variables also updated names of channels for new simulated data
changed some variable names fixed an issue with timestamp in the partial ingest checks that caused two of the same timestamps to be considered different altered channel remover code in ingest_data to be slightly less complicated
simplified a function by spliting it into two changed some formatting with black
linted the program had to do matplotlib.use("Agg") to prevent an error in waveform.py added a way to delete from the s3 echo
There are a few of these in the hdf_handler code that I'm not sure are able to be ran because of other constraints but still effects the code coverage. I'm not sure if removing them could cause problems though. except ValidationError as exc: |
I couldn't increase the coverage too much because some of the code I don't think can get run more information on the hdf validator PR
@Will-Cross1 thanks for taking a look at increasing the code coverage on |
increased code coverage for echo_interface to 100% removed an unused import from test_hdf_handler should be the last commit for this branch
fixed merge conflicts added docstrings to functions
separated each test function into valid and invalid checks
…62-echo-hdf-tests
DSEGOG-262 echo hdf tests
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #93 +/- ##
==========================================
+ Coverage 91.33% 94.99% +3.66%
==========================================
Files 47 50 +3
Lines 2446 2837 +391
Branches 197 297 +100
==========================================
+ Hits 2234 2695 +461
+ Misses 186 105 -81
- Partials 26 37 +11 ☔ View full report in Codecov by Sentry. |
- Split test classes into separate files and make some minor improvements
803300e
to
1145384
Compare
…ies for manifest - A database query would be executed for every single channel, now it's just twice in the entire ingestion process
Description:
Implamented checks to the HDF file in accrodance to the word document provided by Stephen Dann.
When an HDF file is ingested it is then checked by the code in this pull request in accordance to the word document
it then returns a message to the user in this format:
this will give a message depending on wether an existing record has been updated or created
it gives a response with a list of accepted channels as well as rejected channels
rejected channels are in a dictionary form with the key being the rejected channel which links to a list of reason why the channel failed
any warnings raised in the file checker are also returned to the user in this dictionary inside the "warnings" list
HTTP codes:
On creation: 201
On update: 200
On fail: 400
Key functionalities:
Testing:
there are many comprehensive pytests as well as integration tests with this PR
list of test commands ran in shell:
(ran in the top folder (operationsgateway-api))
(Works on Mac not sure about windows)
poetry run pytest
poetry run pytest -s "test/records/test_HDF_file.py" -v -vv
poetry run pytest -s "test/records/test_HDF_file.py::TestFile" -v -vv
poetry run pytest -s "test/records/test_HDF_file.py::TestRecord" -v -vv
poetry run pytest -s "test/records/test_HDF_file.py::TestChannel" -v -vv
poetry run pytest -s "test/records/test_HDF_file.py::TestPartialImport" -v -vv
poetry run pytest -s "test/records/test_HDF_file.py::TestIntegrationIngestData" -v -vv
Additional notes:
matplotlib.use("Agg")
to the waveform.py file to fix an error to do with matplotlib that arose