-
Notifications
You must be signed in to change notification settings - Fork 25
feat: raise helpful error message for existing event properties #1046
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
base: main
Are you sure you want to change the base?
Conversation
for more information, see https://pre-commit.ci
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #1046 +/- ##
===========================================
- Coverage 100.00% 99.94% -0.06%
===========================================
Files 84 86 +2
Lines 3654 3722 +68
Branches 646 652 +6
===========================================
+ Hits 3654 3720 +66
- Misses 0 1 +1
- Partials 0 1 +1 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
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.
Great! Thank you so much for your initiative!
Some of the tests don't pass because event_properties
can also be a dict.
I posted a short proposal on how to change your code accordingly.
You will also need to add at least two test cases here:
pymovements/tests/unit/dataset/dataset_test.py
Lines 1603 to 1614 in 87487d0
@pytest.mark.parametrize( | |
('property_kwargs', 'exception', 'msg_substrings'), | |
[ | |
pytest.param( | |
{'event_properties': 'foo'}, | |
pm.exceptions.InvalidProperty, | |
('foo', 'invalid', 'valid', 'peak_velocity'), | |
id='invalid_property', | |
), | |
], | |
) | |
def test_event_dataframe_add_property_raises_exceptions( |
One for the ValueError
and one for the TypeError
.
…-lab#1041) - add type check for event_properties in dataset.py - add two test cases for ValueError and TypeError in dataset_test.py
for more information, see https://pre-commit.ci
…movements into feature/su-feature
for more information, see https://pre-commit.ci
…movements into feature/su-feature
for more information, see https://pre-commit.ci
…movements into feature/su-feature
for more information, see https://pre-commit.ci
…y getting event_properties_name
for more information, see https://pre-commit.ci
- remove tests in dataset_test.py
for more information, see https://pre-commit.ci
for more information, see https://pre-commit.ci
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.
Great, this looks quite good already, but please make sure that all tests pass.
There are a few syntax errors left in your code, that's why the tests fail. The error messages in the test runs point you to the error: https://github.com/aeye-lab/pymovements/actions/runs/14032843428?pr=1046
for more information, see https://pre-commit.ci
for more information, see https://pre-commit.ci
for more information, see https://pre-commit.ci
for more information, see https://pre-commit.ci
this PR gets screwed over by autopep8, see hhatto/autopep8#765 for the issue. maybe we should deactivate autopep8? |
for more information, see https://pre-commit.ci
for more information, see https://pre-commit.ci
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.
Great, finally linting and all tests pass! Was a bit complicated with all the type unions. There seemed to be a confusion between EventProcessor
and EventGazeProcessor
, so I helped out a bit to not burden you with these details.
The last thing what's missing now is covering all the new exceptions with tests.
event_property_names = [property[0] for property in processor.event_properties] | ||
existing_columns = set(self.events[0].columns) & set(event_property_names) | ||
if existing_columns: | ||
raise ValueError( |
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 is not covered by any tests anymore. Please add a test here:
pymovements/tests/unit/dataset/dataset_test.py
Lines 1603 to 1619 in 6245bbf
@pytest.mark.parametrize( | |
('property_kwargs', 'exception', 'msg_substrings'), | |
[ | |
pytest.param( | |
{'event_properties': 'foo'}, | |
pm.exceptions.InvalidProperty, | |
('foo', 'invalid', 'valid', 'peak_velocity'), | |
id='invalid_property', | |
), | |
], | |
) | |
def test_event_dataframe_add_property_raises_exceptions( | |
gaze_dataset_configuration, | |
property_kwargs, | |
exception, | |
msg_substrings, | |
): |
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.
Hi @xiaotiansu maybe you overlooked this, there's one final test needed to get full coverage.
After adding the test we'll be ready to merge. Thanks for all the work so far!
Hi, my first commit of code, hope I'm doing it correctly :)
Fixes #
Implemented changes
Insert a description of the changes implemented in the pull request.
Type of change
How Has This Been Tested?
Please describe the tests that you ran to verify your changes.
Provide instructions so we can reproduce.
Please also list any relevant details for your test configuration
dataset
:tox -e py39 -- tests/unit/events
Checklist: