Skip to content

Commit 2d6802e

Browse files
edenhausabmantis
andauthored
Deprecate tensorflow (home-assistant#145806)
Co-authored-by: Abílio Costa <abmantis@users.noreply.github.com>
1 parent 9687a34 commit 2d6802e

File tree

5 files changed

+76
-3
lines changed

5 files changed

+76
-3
lines changed
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,4 @@
11
"""The tensorflow component."""
2+
3+
DOMAIN = "tensorflow"
4+
CONF_GRAPH = "graph"

homeassistant/components/tensorflow/image_processing.py

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,15 +26,21 @@
2626
CONF_SOURCE,
2727
EVENT_HOMEASSISTANT_START,
2828
)
29-
from homeassistant.core import HomeAssistant, split_entity_id
29+
from homeassistant.core import (
30+
DOMAIN as HOMEASSISTANT_DOMAIN,
31+
HomeAssistant,
32+
split_entity_id,
33+
)
3034
from homeassistant.helpers import config_validation as cv, template
3135
from homeassistant.helpers.entity_platform import AddEntitiesCallback
36+
from homeassistant.helpers.issue_registry import IssueSeverity, create_issue
3237
from homeassistant.helpers.typing import ConfigType, DiscoveryInfoType
3338
from homeassistant.util.pil import draw_box
3439

40+
from . import CONF_GRAPH, DOMAIN
41+
3542
os.environ["TF_CPP_MIN_LOG_LEVEL"] = "2"
3643

37-
DOMAIN = "tensorflow"
3844
_LOGGER = logging.getLogger(__name__)
3945

4046
ATTR_MATCHES = "matches"
@@ -47,7 +53,6 @@
4753
CONF_CATEGORIES = "categories"
4854
CONF_CATEGORY = "category"
4955
CONF_FILE_OUT = "file_out"
50-
CONF_GRAPH = "graph"
5156
CONF_LABELS = "labels"
5257
CONF_LABEL_OFFSET = "label_offset"
5358
CONF_LEFT = "left"
@@ -110,6 +115,21 @@ def setup_platform(
110115
discovery_info: DiscoveryInfoType | None = None,
111116
) -> None:
112117
"""Set up the TensorFlow image processing platform."""
118+
create_issue(
119+
hass,
120+
HOMEASSISTANT_DOMAIN,
121+
f"deprecated_system_packages_yaml_integration_{DOMAIN}",
122+
breaks_in_ha_version="2025.12.0",
123+
is_fixable=False,
124+
issue_domain=DOMAIN,
125+
severity=IssueSeverity.WARNING,
126+
translation_key="deprecated_system_packages_yaml_integration",
127+
translation_placeholders={
128+
"domain": DOMAIN,
129+
"integration_title": "Tensorflow",
130+
},
131+
)
132+
113133
model_config = config[CONF_MODEL]
114134
model_dir = model_config.get(CONF_MODEL_DIR) or hass.config.path("tensorflow")
115135
labels = model_config.get(CONF_LABELS) or hass.config.path(

requirements_test_all.txt

Lines changed: 9 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
"""TensorFlow component tests."""
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
"""Tensorflow test."""
2+
3+
from unittest.mock import Mock, patch
4+
5+
from homeassistant.components.image_processing import DOMAIN as IMAGE_PROCESSING_DOMAINN
6+
from homeassistant.components.tensorflow import CONF_GRAPH, DOMAIN as TENSORFLOW_DOMAIN
7+
from homeassistant.const import CONF_ENTITY_ID, CONF_MODEL, CONF_PLATFORM, CONF_SOURCE
8+
from homeassistant.core import DOMAIN as HOMEASSISTANT_DOMAIN, HomeAssistant
9+
from homeassistant.helpers import issue_registry as ir
10+
from homeassistant.setup import async_setup_component
11+
12+
13+
@patch.dict("sys.modules", tensorflow=Mock())
14+
async def test_repair_issue_is_created(
15+
hass: HomeAssistant,
16+
issue_registry: ir.IssueRegistry,
17+
) -> None:
18+
"""Test repair issue is created."""
19+
assert await async_setup_component(
20+
hass,
21+
IMAGE_PROCESSING_DOMAINN,
22+
{
23+
IMAGE_PROCESSING_DOMAINN: [
24+
{
25+
CONF_PLATFORM: TENSORFLOW_DOMAIN,
26+
CONF_SOURCE: [
27+
{CONF_ENTITY_ID: "camera.test_camera"},
28+
],
29+
CONF_MODEL: {
30+
CONF_GRAPH: ".",
31+
},
32+
}
33+
],
34+
},
35+
)
36+
await hass.async_block_till_done()
37+
assert (
38+
HOMEASSISTANT_DOMAIN,
39+
f"deprecated_system_packages_yaml_integration_{TENSORFLOW_DOMAIN}",
40+
) in issue_registry.issues

0 commit comments

Comments
 (0)