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

Made numpy requirement optional. Fixes #4 #5

Open
wants to merge 6 commits into
base: master
Choose a base branch
from

Conversation

wolph
Copy link

@wolph wolph commented Jan 12, 2020

No description provided.

@Efrony
Copy link

Efrony commented Jan 19, 2020

Hi! I'm using your new integration in Home assistant. But I can't find how to open the SETTING button in the file endpoints.py. Sorry that write here. I don't know where else to write =)

@bendavid
Copy link
Owner

I'm happy with this (but it needs to be rebased)

@wolph
Copy link
Author

wolph commented Jan 30, 2020

I’ve reapplied the patch :)

@bendavid
Copy link
Owner

The assert for missing numpy should be consistently added to all the relevant functions. Also please fix the style checks (suggest to use pre-commit hooks as described in the documentation)

@wolph
Copy link
Author

wolph commented Jan 31, 2020

I don't think the pre-commit stuff is working but I might be doing something wrong. The usage isn't really clear to me

# python3 .git/hooks/pre-commit
Trim Trailing Whitespace.............................(no files to check)Skipped
Fix End of Files.....................................(no files to check)Skipped
Check docstring is first.............................(no files to check)Skipped
Check Yaml...........................................(no files to check)Skipped
Debug Statements (Python)............................(no files to check)Skipped
Tests should end in _test.py.........................(no files to check)Skipped
flake8...............................................(no files to check)Skipped
black................................................(no files to check)Skipped
pyupgrade............................................(no files to check)Skipped
isort................................................(no files to check)Skipped
# pre-commit run
Trim Trailing Whitespace.............................(no files to check)Skipped
Fix End of Files.....................................(no files to check)Skipped
Check docstring is first.............................(no files to check)Skipped
Check Yaml...........................................(no files to check)Skipped
Debug Statements (Python)............................(no files to check)Skipped
Tests should end in _test.py.........................(no files to check)Skipped
flake8...............................................(no files to check)Skipped
black................................................(no files to check)Skipped
pyupgrade............................................(no files to check)Skipped
isort................................................(no files to check)Skipped

I've also tried to look at the Azure pipelines output but it's not telling me anything useful either: https://dev.azure.com/joshbendavid/aiopylgtv/_build/results?buildId=9&view=logs&jobId=00b6a206-eb91-585b-3d14-cf1a4d7b1970&j=00b6a206-eb91-585b-3d14-cf1a4d7b1970&t=9a9400f1-b707-5d54-e2fd-4fe1d8bc6dda

Feel free to add extra numpy checks to the other methods though. For the time being I've simply added a mock numpy which works fine for my case.

@ghost
Copy link

ghost commented Nov 26, 2020

bumping this as I've just got a new LG TV and would like to use this library but not install numpy.

@cdce8p
Copy link

cdce8p commented Dec 20, 2020

I'm also looking forward to this feature. How can I help to get over this finish line?

@wolph I could provide a patch to your feature branch if it would help.
@bendavid if this PR is stale I could also open a new one with these changes and the remaining fixes.

@wolph
Copy link
Author

wolph commented Dec 20, 2020

I've (re-) applied the patch 3 times, I'm just running the fork for now

@cdce8p
Copy link

cdce8p commented Dec 20, 2020

@wolph Take a look at wolph#1 That should resolve the remaining issues.
To fix pre-commit, it did:

source venv/bin/activate  # activate virtual env
pip install pre-commit
pre-commit install
pre-commit run --all-files

If you merge the PR into your branch, this PR should be good to go.

@wolph
Copy link
Author

wolph commented Dec 21, 2020

Thanks for the help @cdce8p :)
I've merged your pull request, let's see if that helps

@bendavid
Copy link
Owner

I'll come back to this soon, but there are a few other items which are higher priority (and ideally I would like to add some unit tests to systematically make sure this isn't breaking the calibration functionality).

Are there platforms where this is really breaking/preventing to use the library?

@wolph
Copy link
Author

wolph commented Dec 22, 2020

With any OS/Python version combination that doesn't have a binary wheel you're in for a very long build time. In my case it is a FreeBSD machine that doesn't come bundled with numpy for the Python version I want. But most pyenv environments will give similar issues.

@cdce8p
Copy link

cdce8p commented Jan 15, 2021

How do we what do move forward with this PR?

I'm using this lib together with Home Assistant on a Raspberry Pi, like a few others I would imagine. Since there is no binary wheel any install or update of numpy takes a really long time during which the whole system is unresponsive.

@bendavid You mentioned that you would like some unit tests to make sure calibration still works as expected. I could contribute those, however since I'm not familiar which this feature I would only assert that numpy is being imported correctly. This however can also be seen just by looking at the changes itself. Let me explain. Below is the output of assert

Python 3.9.1
Type "help", "copyright", "credits" or "license" for more information.
>>> assert np
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
NameError: name 'np' is not defined
>>> import numpy as np
>>> assert np
>>> 

As you can see, if numpy is imported as expected it just does nothing. Therefore the risk is not if the calibration will continue to work, but if all other features continue to (assuming you don't have numpy installed). Since we've added the asserts only to functions which use or call a function that uses numpy, this shouldn't be an issue.

Please let me / us know how you want to continue.

@wolph I just realized that the assert statements are too verbose. It will never print the error message and thus just do more comparisons. I will open a PR on your fork to change those into comments.

@cdce8p
Copy link

cdce8p commented Jan 15, 2021

@wolph The PR: wolph#2

@wolph
Copy link
Author

wolph commented Jan 16, 2021

And it's merged :)

Let's hope we can continue now

@cdce8p
Copy link

cdce8p commented Jan 23, 2021

@bendavid Any update?

@stamak
Copy link

stamak commented Aug 18, 2021

also looking forward for this functionality?

@chros73
Copy link

chros73 commented Nov 23, 2021

I just looked into this, I think using assert is not enough, it's bypassed when optimized code is compiled (-O option). Instead:

  • either raise exception
  • or (I think better to) just completely disable calibration functionality, e.g. like this

But I like the idea as well :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants