-
-
Notifications
You must be signed in to change notification settings - Fork 30.8k
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
Numpy should be a dependency from core #114318
Comments
Hey there @hunterjm, @uvjustin, @allenporter, mind taking a look at this issue as it has been labeled with an integration ( Code owner commandsCode owners of
(message by CodeOwnersMention) stream documentation |
Not sure I agree. This is attempting to load stream as camera depends on stream. |
What part don't you agree with? You are correct it tries to load stream via camera, but because the stream integration is in |
I don't think there is well defined behavior when default config is disabled. You are loading a camera so you need to load stream. I suggest just enabling stream. |
1 similar comment
I don't think there is well defined behavior when default config is disabled. You are loading a camera so you need to load stream. I suggest just enabling stream. |
Ah alright, might be. I was under the impression that now that some core components have been moved into bootstrap (#105560), |
I think stream may be in the "has impact" category given the heavy dependencies on things like pyav and ffmpeg. |
Which is exactly why I don't want it in my configuration if I don't have a need for it 😉 |
so |
2 similar comments
so |
so |
Correct! Maybe I should have mentioned that more clearly. This is just with an empty configuration out of the box. So nothing else besides the core components inside bootstrap. That's why I initially didn't tag the stream integration, as I didn't think it was the cause. I tried to figure out why it was loading camera, but this was far beyond my understanding of the home assistant architecture. |
Coincidentally, I just got the same error doing the following steps:
$ pre-commit
[INFO] Initializing environment for https://github.com/astral-sh/ruff-pre-commit.
[INFO] Initializing environment for https://github.com/codespell-project/codespell.
[INFO] Initializing environment for https://github.com/pre-commit/pre-commit-hooks.
[INFO] Initializing environment for https://github.com/adrienverge/yamllint.git.
[INFO] Initializing environment for https://github.com/pre-commit/mirrors-prettier.
[INFO] Initializing environment for https://github.com/pre-commit/mirrors-prettier:prettier@3.0.3.
[INFO] Initializing environment for https://github.com/cdce8p/python-typing-update.
[INFO] Installing environment for https://github.com/astral-sh/ruff-pre-commit.
[INFO] Once installed this environment will be reused.
[INFO] This may take a few minutes...
[INFO] Installing environment for https://github.com/codespell-project/codespell.
[INFO] Once installed this environment will be reused.
[INFO] This may take a few minutes...
[INFO] Installing environment for https://github.com/pre-commit/pre-commit-hooks.
[INFO] Once installed this environment will be reused.
[INFO] This may take a few minutes...
[INFO] Installing environment for https://github.com/adrienverge/yamllint.git.
[INFO] Once installed this environment will be reused.
[INFO] This may take a few minutes...
[INFO] Installing environment for https://github.com/pre-commit/mirrors-prettier.
[INFO] Once installed this environment will be reused.
[INFO] This may take a few minutes...
ruff.................................................(no files to check)Skipped
ruff-format..........................................(no files to check)Skipped
codespell............................................(no files to check)Skipped
check json...............................................................Passed
don't commit to branch...................................................Passed
yamllint.............................................(no files to check)Skipped
prettier.................................................................Passed
mypy.................................................(no files to check)Skipped
pylint...............................................(no files to check)Skipped
gen_requirements_all.....................................................Failed
- hook id: gen_requirements_all
- files were modified by this hook
Warning: homeassistant/components/facebox/__init__.py and manifest.json missing, skipping directory. If this is your development environment, you can safely delete this folder.
hassfest.................................................................Failed
- hook id: hassfest
- exit code: 1
Warning: homeassistant/components/facebox/__init__.py and manifest.json missing, skipping directory. If this is your development environment, you can safely delete this folder.
Validating application_credentials... done in 0.03s
Validating bluetooth... done in 0.01s
Validating codeowners... done in 0.03s
Validating config_schema... done in 3.47s
Validating dependencies... done in 11.08s
Validating dhcp... done in 0.01s
Validating icons... done in 0.67s
Validating json... done in 0.00s
Validating manifest... done in 0.06s
Validating mqtt... done in 0.01s
Validating requirements... done in 0.01s
Validating services...Traceback (most recent call last):
File "<frozen runpy>", line 198, in _run_module_as_main
File "<frozen runpy>", line 88, in _run_code
File "/workspaces/home-assistant-core/script/hassfest/__main__.py", line 250, in <module>
sys.exit(main())
^^^^^^
File "/workspaces/home-assistant-core/script/hassfest/__main__.py", line 172, in main
plugin.validate(integrations, config)
File "/workspaces/home-assistant-core/script/hassfest/services.py", line 238, in validate
validate_services(config, integration)
File "/workspaces/home-assistant-core/script/hassfest/services.py", line 133, in validate_services
services = CORE_INTEGRATION_SERVICES_SCHEMA(data)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/voluptuous/schema_builder.py", line 272, in __call__
return self._compiled([], data)
^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/voluptuous/schema_builder.py", line 595, in validate_dict
return base_validate(path, iteritems(data), out)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/voluptuous/schema_builder.py", line 387, in validate_mapping
cval = cvalue(key_path, value)
^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/voluptuous/validators.py", line 229, in _run
return self._exec(self._compiled, value, path)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/voluptuous/validators.py", line 274, in _exec
return func(path, v)
^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/voluptuous/schema_builder.py", line 818, in validate_callable
return schema(data)
^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/voluptuous/schema_builder.py", line 272, in __call__
return self._compiled([], data)
^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/voluptuous/schema_builder.py", line 595, in validate_dict
return base_validate(path, iteritems(data), out)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/voluptuous/schema_builder.py", line 387, in validate_mapping
cval = cvalue(key_path, value)
^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/voluptuous/validators.py", line 229, in _run
return self._exec(self._compiled, value, path)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/voluptuous/validators.py", line 274, in _exec
return func(path, v)
^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/voluptuous/schema_builder.py", line 818, in validate_callable
return schema(data)
^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/voluptuous/schema_builder.py", line 272, in __call__
return self._compiled([], data)
^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/voluptuous/schema_builder.py", line 595, in validate_dict
return base_validate(path, iteritems(data), out)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/voluptuous/schema_builder.py", line 387, in validate_mapping
cval = cvalue(key_path, value)
^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/voluptuous/validators.py", line 229, in _run
return self._exec(self._compiled, value, path)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/voluptuous/validators.py", line 353, in _exec
v = func(path, v)
^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/voluptuous/schema_builder.py", line 636, in validate_sequence
cval = validate(index_path, value)
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/voluptuous/schema_builder.py", line 818, in validate_callable
return schema(data)
^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/voluptuous/schema_builder.py", line 272, in __call__
return self._compiled([], data)
^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/voluptuous/schema_builder.py", line 595, in validate_dict
return base_validate(path, iteritems(data), out)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/voluptuous/schema_builder.py", line 387, in validate_mapping
cval = cvalue(key_path, value)
^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/voluptuous/schema_builder.py", line 636, in validate_sequence
cval = validate(index_path, value)
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/voluptuous/validators.py", line 229, in _run
return self._exec(self._compiled, value, path)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/voluptuous/validators.py", line 353, in _exec
v = func(path, v)
^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/voluptuous/schema_builder.py", line 818, in validate_callable
return schema(data)
^^^^^^^^^^^^
File "/workspaces/home-assistant-core/homeassistant/helpers/selector.py", line 161, in _validate_supported_features
feature_mask |= _validate_supported_feature(supported_feature)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/workspaces/home-assistant-core/homeassistant/helpers/selector.py", line 136, in _validate_supported_feature
known_entity_features = _entity_features()
^^^^^^^^^^^^^^^^^^
File "/workspaces/home-assistant-core/homeassistant/helpers/selector.py", line 92, in _entity_features
from homeassistant.components.camera import CameraEntityFeature
File "/workspaces/home-assistant-core/homeassistant/components/camera/__init__.py", line 31, in <module>
from homeassistant.components.stream import (
File "/workspaces/home-assistant-core/homeassistant/components/stream/__init__.py", line 64, in <module>
from .core import (
File "/workspaces/home-assistant-core/homeassistant/components/stream/core.py", line 15, in <module>
import numpy as np
ModuleNotFoundError: No module named 'numpy'
hassfest-metadata....................................(no files to check)Skipped
hassfest-mypy-config.................................(no files to check)Skipped |
There were some attempts to add this to the general dependencies, but they all got declined but i never saw the reason why they got declined |
History: Generally, i don't think we try super hard to support non-default config, but it seems like given some things were moved to bootstrap and some where not that it still seems like something we're trying to keep working. I think its fine to say It seems less clear what the solution is for non-dev environment given the selectors imports the camera entity which imports stream. We definitely don't want to add hacks for this, so it may need to stay as the status quo |
I certainly get this in my dev config. And I'm actually trying to sort a different issue in dev and got the same error with a new build of HA |
I get same traceback when building dev container. |
When building yourself in dev I recommend creating a config with default_config: |
I think it happens when I add the mqtt integration. But yes I should include default_config, but I try to minimise what I load to reduce rebuild time. |
I guess modularity is a goal and then the solution should be to restore modularity by disconnecting things and making dependencies optional, not adding more. :) Maybe one of these two alternatives?
|
The selector logic is validating features and is pre-loading a map. Maybe that map does not need to exist and the feature enums can be imported only as needed. |
I modified those functions and made them "forgiving" by wrapping them in try / except statements: I've been running it for two weeks and it works. Instead of failing, it just logs an exception and moves on without it. I've planned to make a proper PR but haven't gotten around to it yet. The reason behind all this is that the node I'm running HA on is a relatively low-powered arm device. Compiling numpy, OpenCV etc takes a significant amount of time and HA is our main interface to manage our light-automation (24 shellys), heating+hot-water+ventilation (nibe), air conditioning (toshiba) and soon monitoring / managing solar + car-charger. Anything automatic which might break the functionality is unacceptable because there's no guarantee that I'm around or have time to spare to fix things when it breaks (and it has broken from time to time, not a great experience). Maybe it would be best if the logic for these functions was 'flipped around'? |
The problem
When using HASS Core without the
default_config
integration inconfiguration.yaml
, there is still a dependency on Camera which depends on Stream which depends onnumpy
. However because the Stream integration isn't loaded, thenumpy
module is not automatically installed. This results in an error and you cannot use Home Assistant withoutnumpy
.I am not sure if this happens in the Container versions as well, but probably only on Core in a virtual environment
I am aware that this is a particular niche situation, but it would be nice that even users with a minimal configuration automatically have the correct version of
numpy
installed (which complies with the package constraints too). I am not sure how and where this should be fixed though. Shouldnumpy
be a dependency when installing homeassistant with pip? Or a dependency of another module as well?What version of Home Assistant Core has the issue?
core-2024.4.0.dev0
What was the last working version of Home Assistant Core?
No response
What type of installation are you running?
Home Assistant Core
Integration causing the issue
No response
Link to integration documentation on our website
No response
Diagnostics information
No response
Example YAML snippet
No response
Anything in the logs that might be useful for us?
Additional information
No response
The text was updated successfully, but these errors were encountered: