Skip to content

Commit

Permalink
Remove unused params in neon_core.__init__
Browse files Browse the repository at this point in the history
Mark init methods as deprecated
Update skill installation to skip install methods when nothing to install
Update dependencies
  • Loading branch information
NeonDaniel committed Oct 25, 2023
1 parent febf6d7 commit 672b7e5
Show file tree
Hide file tree
Showing 6 changed files with 41 additions and 26 deletions.
11 changes: 6 additions & 5 deletions neon_core/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,17 +26,18 @@
# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

import sys
# import sys

from neon_core.config import setup_resolve_resource_file, get_core_version
# from neon_core.config import setup_resolve_resource_file, get_core_version
from os.path import dirname


# TODO: Deprecate below
NEON_ROOT_PATH = dirname(__file__)
sys.path.append(NEON_ROOT_PATH)
# sys.path.append(NEON_ROOT_PATH)

CORE_VERSION_STR = get_core_version()
setup_resolve_resource_file()
CORE_VERSION_STR = "" # get_core_version()
# setup_resolve_resource_file()

__all__ = ['NEON_ROOT_PATH',
'CORE_VERSION_STR']
36 changes: 23 additions & 13 deletions neon_core/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,19 @@ def get_core_version() -> str:
Get the core version string.
NOTE: `init_config` should be called before this method
"""
# from neon_core.configuration import Configuration
# Configuration.load_all_configs({"disable_remote_config": True})

# TODO: Remove by 2024
from ovos_utils.log import log_deprecation
log_deprecation("This method is deprecated; use Python built-in utilities "
"to find package versions", "23.12.1")
# patch version string to allow downstream to know where it is running
import mycroft.version
core_version_str = '.'.join(map(str,
mycroft.version.CORE_VERSION_TUPLE)) + \
"(NeonGecko)"
mycroft.version.CORE_VERSION_STR = core_version_str
try:
import mycroft.version
core_version_str = '.'.join(map(str,
mycroft.version.CORE_VERSION_TUPLE)) + \
"(NeonGecko)"
mycroft.version.CORE_VERSION_STR = core_version_str
except (ImportError, AttributeError):
return ""
return core_version_str


Expand All @@ -49,14 +53,20 @@ def setup_resolve_resource_file():
Override default resolve_resource_file to include resources in neon-core.
Priority: neon-utils, neon-core, ~/.local/share/neon, ~/.neon, mycroft-core
"""
from ovos_utils.log import log_deprecation
from neon_utils.file_utils import resolve_neon_resource_file
from mycroft.util.file_utils import resolve_resource_file
log_deprecation("This method is deprecated; resource resolution is handled "
"automatically.", "23.12.1")

def patched_resolve_resource_file(res_name):
from mycroft.util.file_utils import resolve_resource_file
resource = resolve_neon_resource_file(res_name) or \
resolve_resource_file(res_name)
resolve_resource_file(res_name)
return resource

import mycroft.util
mycroft.util.file_utils.resolve_resource_file = \
patched_resolve_resource_file
try:
import mycroft.util
mycroft.util.file_utils.resolve_resource_file = \
patched_resolve_resource_file
except (ImportError, AttributeError):
pass
8 changes: 5 additions & 3 deletions neon_core/util/skill_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ def install_skills_from_list(skills_to_install: list, config: dict = None):
try:
_write_pip_constraints_to_file(constraints_file)
except PermissionError:
LOG.error(f"Unable to write pip constraints file {constraints_file}")
LOG.warning(f"Unable to write pip constraints file {constraints_file}")
from ovos_skills_manager.utils import set_osm_constraints_file
constraints_file = join(xdg_data_home(), "neon", "constraints.txt")
_write_pip_constraints_to_file(constraints_file)
Expand All @@ -205,7 +205,7 @@ def install_skills_from_list(skills_to_install: list, config: dict = None):
if token_set:
from ovos_skills_manager.session import clear_github_token
clear_github_token()
LOG.info(f"Installed skills to: {skill_dir}")
LOG.info(f"Installed {len(skills_to_install)} skills to: {skill_dir}")


def install_skills_default(config: dict = None):
Expand All @@ -217,7 +217,9 @@ def install_skills_default(config: dict = None):
if isinstance(skills_list, str):
skills_list = _get_skills_from_remote_list(skills_list)
assert isinstance(skills_list, list)
install_skills_from_list(skills_list, config)
if skills_list:
LOG.info(f"Installing configured skills: {skills_list}")
install_skills_from_list(skills_list, config)


def _get_skills_from_remote_list(url: str) -> List[str]:
Expand Down
7 changes: 4 additions & 3 deletions requirements/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,13 @@ ovos-core~=0.0.7
ovos-plugin-common-play~=0.0.5

# utils
neon-utils[audio,network]~=1.6,>=1.6.3a3
neon-utils[audio,network]~=1.6,>=1.6.3a4
# TODO: Audio extra patching dependency resolution
ovos-utils~=0.0.35
ovos-bus-client~=0.0.5
ovos-bus-client~=0.0.5,>=0.0.6a18
# TODO: Above alpha just for testing compat.
neon-transformers~=0.2
ovos-config~=0.0.11a15
ovos-config~=0.0.11
ovos-plugin-manager~=0.0.21
ovos-backend-client~=0.0.6
psutil~=5.6
Expand Down
2 changes: 1 addition & 1 deletion requirements/skills_default.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
skill-ddg~=0.0
skill-ddg~=0.0,>=0.0.2a2
neon-skill-alerts~=2.0
neon-skill-caffeinewiz~=1.0
neon-skill-data_controls~=2.0
Expand Down
3 changes: 2 additions & 1 deletion requirements/skills_extended.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,5 @@ neon-skill-translation~=1.0
neon-skill-camera~=1.0
ovos-skill-somafm~=0.0.1
neon-homeassistant-skill~=0.0.13
ovos-skill-icanhazdadjokes @ git+https://github.com/openvoiceos/skill-ovos-icanhazdadjokes
ovos-skill-icanhazdadjokes @ git+https://github.com/openvoiceos/skill-ovos-icanhazdadjokes
# TODO: Pin "stable" commit

0 comments on commit 672b7e5

Please sign in to comment.