Skip to content
This repository has been archived by the owner on Apr 15, 2024. It is now read-only.

Basic unit tests, logging, exception refactoring #25

Merged
merged 26 commits into from
Jul 19, 2020

Conversation

cfculhane
Copy link
Contributor

This PR combines a bunch of commits to address the following issues:

#8 - Implemented via shared_logging.py and its associated config file, at the moment the level is set to DEBUG which is quite verbose, but once the codebase becomes more stable this can be rolled back if desired

#22 - Using pytest and tox, I have written a basic integration test that runs two short videos and checks they are outputted correctly and that the output contains the expected number of frames. Later on further test can be written to test individual modules but at least now we can easily check if we break things as we change the code.

I have included calls to plugins to make coverage and test reports, see below:

image

image

#23 - partial fix to this, but the whole stack of .arm(), .release() etc might need to be looked at in more detail to figure out how untangle it and ensure things exit cleanly. For now I've removed the sys.exit() calls and made the exit clean by calling .release() when running out of frames. This might not be the intended behaviours, so will need feedback.

Please have a look through and see how I went, the blink_detection is a bit of an issue I think, I've added an assert that the blink_threshold > 0, as there is a check for abs(delta) > threshold if the threshold is less than 0, check_blink() will always detect a blink. #24 raises the issue of not hardcoding this, which might need to be addressed in a PR soon after this one.

cfculhane added 18 commits July 19, 2020 11:41
…ments file. Also updated setup.py to find namespace packages
…port folder so that all data from one session is in the same place
… custom args to be passed more easily in unit tests
…all, add basic logging, remove now-uncessary sys.exit()
…emoved the timestamp as the directory now has a timestamp.
…eturn True if blink detected, False otherwise, and to check threshold > 0
@cfculhane
Copy link
Contributor Author

tox doesn't want to start on travis for some reason! :(

Copy link
Contributor

@kinow kinow left a comment

Choose a reason for hiding this comment

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

After changing the first_namespace_packages by find_packages it executed tox, then failed with the same message as Travis.

------------------------------------------------------------------------------- live log call --------------------------------------------------------------------------------
2020-07-19 20:53:22 INFO Initiating tracking via Importer: cv
ERROR: InvocationError for command /home/kinow/Development/python/workspace/eyeloop/.tox/py38/bin/pytest --cov=eyeloop --cov-report html:tests/reports/coverage --html=tests/reports/pytest_results.html (exited with code 1)
___________________________________________________________________________________ summary ___________________________________________________________________________________
ERROR:   py38: commands failed

Let me see if there's any easy flag to increase verbosity...

setup.py Outdated Show resolved Hide resolved
@kinow
Copy link
Contributor

kinow commented Jul 19, 2020

@cfculhane I think it needs an X Server to run the tests? I ran tox and it failed. Then copied the command, it opened lots of windows, but the tests started working (I think; at least it went a bit ahead until I stopped it as it was really opening a lot of windows 😄 )

@cfculhane
Copy link
Contributor Author

@cfculhane I think it needs an X Server to run the tests? I ran tox and it failed. Then copied the command, it opened lots of windows, but the tests started working (I think; at least it went a bit ahead until I stopped it as it was really opening a lot of windows 😄 )

I've found, https://github.com/tox-dev/tox-travis , ill add that to the travis script to see what happens

@cfculhane
Copy link
Contributor Author

Still not working, I'll try this approach - jazzband/pip-tools#858

@cfculhane
Copy link
Contributor Author

Still no dice, open to ideas. Maybe it does need an X server and we could just run travis without a GUI - but given it was running eyeloop previously this doesn't seem to be the cause

@kinow
Copy link
Contributor

kinow commented Jul 19, 2020

I'm not in front of the computer with my development environment, but I found this link from pytest-qt when searching for xfvb and tox. Check out the first error described, looks pretty similar to what we have here.

https://pytest-qt.readthedocs.io/en/latest/troubleshooting.html

Perhaps their solution could be ported to eyeloop? Or at least serve as starting point I think.

@cfculhane
Copy link
Contributor Author

I'm not in front of the computer with my development environment, but I found this link from pytest-qt when searching for xfvb and tox. Check out the first error described, looks pretty similar to what we have here.

pytest-qt.readthedocs.io/en/latest/troubleshooting.html

Perhaps their solution could be ported to eyeloop? Or at least serve as starting point I think.

Thanks for this, I'll look into it later in the week, I've unfortunately run out of time today

@cfculhane
Copy link
Contributor Author

Hallelujah, just using pytest works! Tox is still nice for easy of use by dev and end users I think, but running pytest seems to be the go for travis for now.

Copy link
Contributor

@kinow kinow left a comment

Choose a reason for hiding this comment

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

That's looking good to me. A great improvement! And users (and devs) should be able to change the logging configuration and see more - or less - of the eyeloop logging information. 👏

tox.ini Show resolved Hide resolved
setup.py Show resolved Hide resolved
eyeloop/utilities/shared_logging.py Outdated Show resolved Hide resolved
@simonarvin
Copy link
Owner

Great work, guys! I will look into blink detection. Closing Importer via .release() is more elegant - I fully agree. Merging this into our main branch

@simonarvin simonarvin closed this Jul 19, 2020
@simonarvin simonarvin reopened this Jul 19, 2020
@simonarvin simonarvin merged commit 24a30eb into simonarvin:master Jul 19, 2020
@cfculhane cfculhane deleted the basic-unit-tests branch July 20, 2020 22:38
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants