-
Notifications
You must be signed in to change notification settings - Fork 1
Aligner #12
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
Aligner #12
Conversation
|
Hi @prasadtalasila I have updated the way we delete samples. If you could approve and merge this PR, I will then create PR for the sysID. |
prasadtalasila
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@8ohamed This review is incomplete. I am providing the partial review in order to help you proceed further.
|
The reference code subscribes to metadata topic too, it extracts the datatype and the number of samples in each message. It also publishes a metadata for the aligned data, this metadata includes "UTCAtFirstSample" and "Fs" |
prasadtalasila
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@8ohamed thanks for the updates to the PR. Please see the new comments.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please do not update these settings. It is best to refactor the code instead.
src/data/accel/hbk/aligner.py
Outdated
| msg, acc=acc: acc.process_message(msg)) | ||
|
|
||
|
|
||
| def find_continuous_key_groups(self): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please add type hints here and in other places
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The data_map is an internal property of Accelerometer and it should not be used outside. Please write continuous_key_groups(self) for the Accelerometer and reuse those here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@prasadtalasila
In order to avoid other classes accessing the data_map, I added new methods to Accelerometer
- get_sorted_keys, so each accelerometer returns a list of its keys so the aligner can use it
- get_samples_for_key so the aligner can use it to extract data, instead of directly using the data_map
- clear_used_data it deletes used data and everything that is older, aligner class calls it after extracting the data
I have pushed the changes, I will now look at the tests.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This test uses the actual mqtt server. Please create another test file (tests/unit/data/accel/hbk/test_aligner.py) by using the same code except that the mqtt server is mocked using pytest-mock. Such tests are called unit tests and are very useful.
The same technique can be used to create unit tests for Accelerometer class.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The existing tests in tests/data can be moved to test/integration/data.
|
@8ohamed I forgot to mention the following comments. Please look into them.
|
|
Hi @prasadtalasila Thanks for the review, I have now resolved the issues with accessing data_map. I have also made unit tests now we have 100% coverage for both mqtt.py and aligner.py and for accelerometer.py we have 96% |
|
@8ohamed The tests are failing. Please see the log below. |
|
@prasadtalasila I had forgotten to update the output of extract() in the test. It's fixed now. |
prasadtalasila
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@8ohamed Thanks for the quick updates. Please see the following comments.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This gives the following error.
Received message on topic cpsens/d8-3a-dd-37-d2-7e/3160-A-042_sn_999998/1/acc/raw/data
Channel: cpsens/d8-3a-dd-37-d2-7e/3160-A-042_sn_999998/1/acc/raw/data Key: 282170143, Samples: 16
Fatal Python error: _enter_buffered_busy: could not acquire lock for <_io.BufferedWriter name='<stdout>'> at interpreter shutdown, possibly due to daemon threads
Python runtime state: finalizing (tstate=0x00007ffb20bf3fe8)
Current thread 0x000071f8 (most recent call first):
<no Python frame>
Extension modules: numpy._core._multiarray_umath, _wmi, numpy.linalg._umath_linalg (total: 3)
|
The The |
|
@prasadtalasila I have wrote the interface, and fixed the test they are all passing now. |
New PR for Aligner, because the previous one was closed after renaming it.