Skip to content

Commit 1ccf3fc

Browse files
authored
Refactor to use pip installation function from neon-utils (#761)
# Description Deprecates logic duplicated in `neon-utils` for managing pip installation with constraints Includes update to Docker default configuration to prevent logged errors in default container load # Issues - Needs NeonGeckoCom/neon-utils#556 # Other Notes - Deployed as `ghcr.io/neongeckocom/neon_skills-default_skills:alpha` Docker image for testing (9/3) - This change means that an invalid `default_skills` configuration value will cause no skills to be installed, rather than just the one skill to not be installed - Previously, URLs that weren't git repositories were treated as invalid, but this removes that check which allows for specifying a wheel URL
1 parent 35b7abb commit 1ccf3fc

5 files changed

Lines changed: 16 additions & 18 deletions

File tree

docker_overlay/etc/neon/neon.yaml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
language:
22
supported_langs:
33
- en
4-
- uk
4+
# secondary_langs defines what languages are loaded in ovos-core intent services
5+
secondary_langs: [en-us]
6+
57
skills:
68
wait_for_internet: false
79
extra_directories:
@@ -45,4 +47,4 @@ ready_settings:
4547
- skills
4648
signal:
4749
use_signal_files: false
48-
patch_imports: false
50+
patch_imports: false

neon_core/configuration/neon.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -338,4 +338,4 @@ location:
338338
code: America/Los_Angeles
339339
name: Pacific Standard Time
340340
dstOffset: 3600000
341-
offset: -28800000
341+
offset: -28800000

neon_core/util/skill_utils.py

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,12 @@
3333
from os.path import expanduser, join, isdir, dirname, islink
3434
from typing import List
3535

36-
from ovos_utils.xdg_utils import xdg_data_home
37-
from ovos_utils.log import LOG
36+
from ovos_utils.log import LOG, deprecated
3837

3938
from ovos_config.config import Configuration
4039

4140

41+
@deprecated("Internal function is deprecated", "25.09.01")
4242
def _write_pip_constraints_to_file(output_file: str):
4343
"""
4444
Writes out a constraints file for OSM to use to prevent broken dependencies
@@ -67,6 +67,7 @@ def _write_pip_constraints_to_file(output_file: str):
6767
LOG.info(f"Wrote core constraints to file: {output_file}")
6868

6969

70+
@deprecated("Internal function is deprecated", "25.09.01")
7071
def _install_skill_pip(skill_package: str, constraints_file: str) -> bool:
7172
"""
7273
Pip install the specified package
@@ -92,16 +93,12 @@ def install_skills_from_list(skills_to_install: list, config: dict = None):
9293
:param skills_to_install: list of skills to install
9394
:param config: optional dict configuration
9495
"""
95-
constraints_file = join(xdg_data_home(), "neon", "constraints.txt")
96-
_write_pip_constraints_to_file(constraints_file)
97-
98-
for spec in skills_to_install:
99-
if "://" in spec and "git+" not in spec:
100-
LOG.error(f"Got an invalid package spec to install: {spec}")
101-
elif not _install_skill_pip(spec, constraints_file):
102-
LOG.error(f"Pip installation failed for: {spec}")
103-
104-
LOG.info(f"Installed {len(skills_to_install)} skills")
96+
from neon_utils.packaging_utils import install_packages_from_pip
97+
ret_code = install_packages_from_pip("neon-core", skills_to_install, True)
98+
if ret_code == 0:
99+
LOG.info(f"Installed {len(skills_to_install)} skills")
100+
else:
101+
LOG.error(f"Error installing skills: {ret_code}")
105102

106103

107104
def install_skills_default(config: dict = None):

requirements/requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
ovos-core[lgpl]~=0.1
33

44

5-
neon-utils[network]~=1.13,>=1.13.1a1
5+
neon-utils[network]~=1.13,>=1.13.1a4
66
ovos-utils~=0.0,>=0.0.38
77
ovos-bus-client~=0.0,>=0.0.10
88
neon-transformers~=1.0

test/test_skill_utils.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@
3232
import unittest
3333
from os.path import dirname, join, exists, isdir
3434
from unittest.mock import patch
35-
from unittest import skip
3635

3736
sys.path.append(os.path.dirname(os.path.dirname(__file__)))
3837

@@ -43,7 +42,7 @@
4342
]
4443

4544
TEST_SKILLS_WITH_PIP = [
46-
"https://github.com/NeonGeckoCom/skill-date_time/tree/dev",
45+
# "https://github.com/NeonGeckoCom/skill-date_time/tree/dev",
4746
"git+https://github.com/NeonGeckoCom/malls-parser-skill",
4847
"neon-skill-support_helper"
4948
]

0 commit comments

Comments
 (0)