From c7927a7e62489d7b00ac4b82fe8be8fd1b6a4825 Mon Sep 17 00:00:00 2001 From: miro Date: Sat, 4 Jan 2025 17:03:36 +0000 Subject: [PATCH 1/2] chore: add warnings make IDEs signal deprecated code instead of relying on runtime logs only --- mycroft/__init__.py | 10 +- ovos_core/intent_services/__init__.py | 147 ++++++++++++++++-- ovos_core/intent_services/adapt_service.py | 8 + ovos_core/intent_services/commonqa_service.py | 8 + ovos_core/intent_services/ocp_service.py | 8 + .../intent_services/padacioso_service.py | 8 + .../intent_services/padatious_service.py | 8 + ovos_core/skill_manager.py | 23 ++- 8 files changed, 206 insertions(+), 14 deletions(-) diff --git a/mycroft/__init__.py b/mycroft/__init__.py index bcbc47550331..8f0b0c514255 100644 --- a/mycroft/__init__.py +++ b/mycroft/__init__.py @@ -35,4 +35,12 @@ LOG.warning("mycroft has been deprecated! please start importing from ovos_core and companion packages\n" - "mycroft module remains available for backwards compatibility and will be removed in version 0.2.0") \ No newline at end of file + "mycroft module remains available for backwards compatibility and will be removed in version 0.2.0") + +import warnings + +warnings.warn( + "'mycroft' has been deprecated! please start importing from 'ovos_core' and companion packages", + DeprecationWarning, + stacklevel=2, +) \ No newline at end of file diff --git a/ovos_core/intent_services/__init__.py b/ovos_core/intent_services/__init__.py index b7bf71425c41..298e907b3076 100644 --- a/ovos_core/intent_services/__init__.py +++ b/ovos_core/intent_services/__init__.py @@ -33,6 +33,7 @@ from ovos_utils.log import LOG, log_deprecation, deprecated from ovos_utils.metrics import Stopwatch from padacioso.opm import PadaciosoPipeline as PadaciosoService +import warnings class IntentService: @@ -524,143 +525,267 @@ def shutdown(self): def registered_intents(self): log_deprecation("direct access to self.adapt_service is deprecated, " "pipelines are in the progress of being replaced with plugins", "1.0.0") + warnings.warn( + "direct access to self.adapt_service is deprecated", + DeprecationWarning, + stacklevel=2, + ) lang = get_message_lang() return [parser.__dict__ for parser in self._adapt_service.engines[lang].intent_parsers] @property def adapt_service(self): + warnings.warn( + "direct access to self.adapt_service is deprecated", + DeprecationWarning, + stacklevel=2, + ) log_deprecation("direct access to self.adapt_service is deprecated, " "pipelines are in the progress of being replaced with plugins", "1.0.0") return self._adapt_service @property def padatious_service(self): + warnings.warn( + "direct access to self.padatious_service is deprecated", + DeprecationWarning, + stacklevel=2, + ) log_deprecation("direct access to self.padatious_service is deprecated, " "pipelines are in the progress of being replaced with plugins", "1.0.0") return self._padatious_service @property def padacioso_service(self): + warnings.warn( + "direct access to self.padatious_service is deprecated", + DeprecationWarning, + stacklevel=2, + ) log_deprecation("direct access to self.padacioso_service is deprecated, " "pipelines are in the progress of being replaced with plugins", "1.0.0") return self._padacioso_service @property def fallback(self): - + warnings.warn( + "direct access to self.fallback is deprecated", + DeprecationWarning, + stacklevel=2, + ) log_deprecation("direct access to self.fallback is deprecated, " "pipelines are in the progress of being replaced with plugins", "1.0.0") return self._fallback @property def converse(self): + warnings.warn( + "direct access to self.converse is deprecated", + DeprecationWarning, + stacklevel=2, + ) log_deprecation("direct access to self.converse is deprecated, " "pipelines are in the progress of being replaced with plugins", "1.0.0") return self._converse @property def common_qa(self): + warnings.warn( + "direct access to self.common_qa is deprecated", + DeprecationWarning, + stacklevel=2, + ) log_deprecation("direct access to self.common_qa is deprecated, " "pipelines are in the progress of being replaced with plugins", "1.0.0") return self._common_qa @property def stop(self): + warnings.warn( + "direct access to self.stop is deprecated", + DeprecationWarning, + stacklevel=2, + ) log_deprecation("direct access to self.stop is deprecated, " "pipelines are in the progress of being replaced with plugins", "1.0.0") return self._stop @property def ocp(self): + warnings.warn( + "direct access to self.ocp is deprecated", + DeprecationWarning, + stacklevel=2, + ) log_deprecation("direct access to self.ocp is deprecated, " "pipelines are in the progress of being replaced with plugins", "1.0.0") return self._ocp @adapt_service.setter def adapt_service(self, value): + warnings.warn( + "direct access to self.adapt_service is deprecated", + DeprecationWarning, + stacklevel=2, + ) log_deprecation("direct access to self.adapt_service is deprecated, " "pipelines are in the progress of being replaced with plugins", "1.0.0") self._adapt_service = value @padatious_service.setter def padatious_service(self, value): + warnings.warn( + "direct access to self.padatious_service is deprecated", + DeprecationWarning, + stacklevel=2, + ) log_deprecation("direct access to self.padatious_service is deprecated, " "pipelines are in the progress of being replaced with plugins", "1.0.0") self._padatious_service = value @padacioso_service.setter def padacioso_service(self, value): + warnings.warn( + "direct access to self.padacioso_service is deprecated", + DeprecationWarning, + stacklevel=2, + ) log_deprecation("direct access to self.padacioso_service is deprecated, " "pipelines are in the progress of being replaced with plugins", "1.0.0") self._padacioso_service = value @fallback.setter def fallback(self, value): + warnings.warn( + "direct access to self.fallback is deprecated", + DeprecationWarning, + stacklevel=2, + ) log_deprecation("direct access to self.fallback is deprecated, " "pipelines are in the progress of being replaced with plugins", "1.0.0") self._fallback = value @converse.setter def converse(self, value): + warnings.warn( + "direct access to self.converse is deprecated", + DeprecationWarning, + stacklevel=2, + ) log_deprecation("direct access to self.converse is deprecated, " "pipelines are in the progress of being replaced with plugins", "1.0.0") self._converse = value @common_qa.setter def common_qa(self, value): + warnings.warn( + "direct access to self.common_qa is deprecated", + DeprecationWarning, + stacklevel=2, + ) log_deprecation("direct access to self.common_qa is deprecated, " "pipelines are in the progress of being replaced with plugins", "1.0.0") self._common_qa = value @stop.setter def stop(self, value): + warnings.warn( + "direct access to self.stop is deprecated", + DeprecationWarning, + stacklevel=2, + ) log_deprecation("direct access to self.stop is deprecated, " "pipelines are in the progress of being replaced with plugins", "1.0.0") self._stop = value @ocp.setter def ocp(self, value): + warnings.warn( + "direct access to self.ocp is deprecated", + DeprecationWarning, + stacklevel=2, + ) log_deprecation("direct access to self.ocp is deprecated, " "pipelines are in the progress of being replaced with plugins", "1.0.0") self._ocp = value @deprecated("handle_get_adapt moved to adapt service, this method does nothing", "1.0.0") def handle_get_adapt(self, message: Message): - """DEPRECATED""" + warnings.warn( + "moved to adapt service, this method does nothing", + DeprecationWarning, + stacklevel=2, + ) @deprecated("handle_adapt_manifest moved to adapt service, this method does nothing", "1.0.0") def handle_adapt_manifest(self, message): - """DEPRECATED""" + warnings.warn( + "moved to adapt service, this method does nothing", + DeprecationWarning, + stacklevel=2, + ) @deprecated("handle_vocab_manifest moved to adapt service, this method does nothing", "1.0.0") def handle_vocab_manifest(self, message): - """DEPRECATED""" + warnings.warn( + "moved to adapt service, this method does nothing", + DeprecationWarning, + stacklevel=2, + ) @deprecated("handle_get_padatious moved to padatious service, this method does nothing", "1.0.0") def handle_get_padatious(self, message): - """DEPRECATED""" + warnings.warn( + "moved to padatious service, this method does nothing", + DeprecationWarning, + stacklevel=2, + ) @deprecated("handle_padatious_manifest moved to padatious service, this method does nothing", "1.0.0") def handle_padatious_manifest(self, message): - """DEPRECATED""" + warnings.warn( + "moved to padatious service, this method does nothing", + DeprecationWarning, + stacklevel=2, + ) @deprecated("handle_entity_manifest moved to padatious service, this method does nothing", "1.0.0") def handle_entity_manifest(self, message): - """DEPRECATED""" + warnings.warn( + "moved to padatious service, this method does nothing", + DeprecationWarning, + stacklevel=2, + ) @deprecated("handle_register_vocab moved to individual pipeline services, this method does nothing", "1.0.0") def handle_register_vocab(self, message): - """DEPRECATED""" + warnings.warn( + "moved to pipeline plugins, this method does nothing", + DeprecationWarning, + stacklevel=2, + ) @deprecated("handle_register_intent moved to individual pipeline services, this method does nothing", "1.0.0") def handle_register_intent(self, message): - """DEPRECATED""" + warnings.warn( + "moved to pipeline plugins, this method does nothing", + DeprecationWarning, + stacklevel=2, + ) @deprecated("handle_detach_intent moved to individual pipeline services, this method does nothing", "1.0.0") def handle_detach_intent(self, message): - """DEPRECATED""" + warnings.warn( + "moved to pipeline plugins, this method does nothing", + DeprecationWarning, + stacklevel=2, + ) @deprecated("handle_detach_skill moved to individual pipeline services, this method does nothing", "1.0.0") def handle_detach_skill(self, message): - """DEPRECATED""" + warnings.warn( + "moved to pipeline plugins, this method does nothing", + DeprecationWarning, + stacklevel=2, + ) diff --git a/ovos_core/intent_services/adapt_service.py b/ovos_core/intent_services/adapt_service.py index 53a5612852a1..982fe78831d8 100644 --- a/ovos_core/intent_services/adapt_service.py +++ b/ovos_core/intent_services/adapt_service.py @@ -2,3 +2,11 @@ from ovos_adapt.opm import AdaptPipeline as AdaptService from ovos_utils.log import log_deprecation log_deprecation("adapt service moved to 'ovos-adapt-pipeline-plugin'. this import is deprecated", "1.0.0") + +import warnings + +warnings.warn( + "adapt service moved to 'ovos-adapt-pipeline-plugin'", + DeprecationWarning, + stacklevel=2, +) \ No newline at end of file diff --git a/ovos_core/intent_services/commonqa_service.py b/ovos_core/intent_services/commonqa_service.py index 00cfd52ac4a7..d292ceacd6f2 100644 --- a/ovos_core/intent_services/commonqa_service.py +++ b/ovos_core/intent_services/commonqa_service.py @@ -1,3 +1,11 @@ from ovos_commonqa.opm import Query, CommonQAService from ovos_utils.log import log_deprecation log_deprecation("adapt service moved to 'ovos-common-query-pipeline-plugin'. this import is deprecated", "1.0.0") + +import warnings + +warnings.warn( + "adapt service moved to 'ovos-common-query-pipeline-plugin'", + DeprecationWarning, + stacklevel=2, +) \ No newline at end of file diff --git a/ovos_core/intent_services/ocp_service.py b/ovos_core/intent_services/ocp_service.py index 0a77f8c255fc..790e79f5d609 100644 --- a/ovos_core/intent_services/ocp_service.py +++ b/ovos_core/intent_services/ocp_service.py @@ -2,3 +2,11 @@ from ocp_pipeline.opm import OCPPipelineMatcher, OCPFeaturizer, OCPPlayerProxy from ovos_utils.log import log_deprecation log_deprecation("adapt service moved to 'ovos-ocp-pipeline-plugin'. this import is deprecated", "1.0.0") + +import warnings + +warnings.warn( + "adapt service moved to 'ovos-ocp-pipeline-plugin'", + DeprecationWarning, + stacklevel=2, +) \ No newline at end of file diff --git a/ovos_core/intent_services/padacioso_service.py b/ovos_core/intent_services/padacioso_service.py index 9f6afcda9fa0..7bd3fd645d10 100644 --- a/ovos_core/intent_services/padacioso_service.py +++ b/ovos_core/intent_services/padacioso_service.py @@ -3,3 +3,11 @@ from padacioso import IntentContainer as FallbackIntentContainer from ovos_utils.log import log_deprecation log_deprecation("adapt service moved to 'padacioso.opm'. this import is deprecated", "1.0.0") + +import warnings + +warnings.warn( + "adapt service moved to 'padacioso'", + DeprecationWarning, + stacklevel=2, +) \ No newline at end of file diff --git a/ovos_core/intent_services/padatious_service.py b/ovos_core/intent_services/padatious_service.py index 242d101325c2..b0f421b732c5 100644 --- a/ovos_core/intent_services/padatious_service.py +++ b/ovos_core/intent_services/padatious_service.py @@ -2,3 +2,11 @@ from ovos_padatious.opm import PadatiousMatcher, PadatiousPipeline as PadatiousService from ovos_utils.log import log_deprecation log_deprecation("adapt service moved to 'ovos-padatious-pipeline-plugin'. this import is deprecated", "1.0.0") + +import warnings + +warnings.warn( + "adapt service moved to 'ovos-padatious-pipeline-plugin'", + DeprecationWarning, + stacklevel=2, +) \ No newline at end of file diff --git a/ovos_core/skill_manager.py b/ovos_core/skill_manager.py index b2d2cb89884d..059da67b84ed 100644 --- a/ovos_core/skill_manager.py +++ b/ovos_core/skill_manager.py @@ -32,6 +32,7 @@ from ovos_utils.process_utils import ProcessStatus, StatusCallbackMap, ProcessState from ovos_workshop.skill_launcher import SKILL_MAIN_MODULE from ovos_workshop.skill_launcher import SkillLoader, PluginSkillLoader +import warnings def _shutdown_skill(instance): @@ -738,7 +739,11 @@ def stop(self): # Deprecated stuff @deprecated("priority skills have been deprecated for a long time", "1.0.0") def load_priority(self): - pass + warnings.warn( + "priority skills have been deprecated", + DeprecationWarning, + stacklevel=2, + ) @deprecated("mycroft.ready event has moved to finished booting skill", "1.0.0") def is_device_ready(self): @@ -749,11 +754,20 @@ def is_device_ready(self): Raises: TimeoutError: If the device is not ready within a specified timeout. """ + warnings.warn( + "mycroft.ready event has moved to finished booting skill", + DeprecationWarning, + stacklevel=2, + ) return True @deprecated("mycroft.ready event has moved to finished booting skill", "1.0.0") def handle_check_device_readiness(self, message): - pass + warnings.warn( + "mycroft.ready event has moved to finished booting skill", + DeprecationWarning, + stacklevel=2, + ) @deprecated("mycroft.ready event has moved to finished booting skill", "1.0.0") def check_services_ready(self, services): @@ -764,4 +778,9 @@ def check_services_ready(self, services): Returns: bool: True if all specified services are ready, False otherwise. """ + warnings.warn( + "mycroft.ready event has moved to finished booting skill", + DeprecationWarning, + stacklevel=2, + ) return True From 224e47fb8d8f97982837bda29a099752e32c1d3b Mon Sep 17 00:00:00 2001 From: miro Date: Sat, 4 Jan 2025 17:10:53 +0000 Subject: [PATCH 2/2] update python version --- .github/workflows/license_tests.yml | 2 +- .github/workflows/publish_stable.yml | 2 +- .github/workflows/release_workflow.yml | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/license_tests.yml b/.github/workflows/license_tests.yml index 9c43092e303f..94e0dec3674a 100644 --- a/.github/workflows/license_tests.yml +++ b/.github/workflows/license_tests.yml @@ -16,7 +16,7 @@ jobs: - name: Setup Python uses: actions/setup-python@v1 with: - python-version: 3.8 + python-version: '3.11' - name: Install Build Tools run: | python -m pip install build wheel uv diff --git a/.github/workflows/publish_stable.yml b/.github/workflows/publish_stable.yml index 9d9921178e37..60b5cfb20d3d 100644 --- a/.github/workflows/publish_stable.yml +++ b/.github/workflows/publish_stable.yml @@ -26,7 +26,7 @@ jobs: - name: Setup Python uses: actions/setup-python@v1 with: - python-version: 3.8 + python-version: '3.11' - name: Install Build Tools run: | python -m pip install build wheel diff --git a/.github/workflows/release_workflow.yml b/.github/workflows/release_workflow.yml index 101fb42a7e5c..93923cbbe1b0 100644 --- a/.github/workflows/release_workflow.yml +++ b/.github/workflows/release_workflow.yml @@ -47,7 +47,7 @@ jobs: - name: Setup Python uses: actions/setup-python@v1 with: - python-version: 3.8 + python-version: '3.11' - name: Install Build Tools run: | python -m pip install build wheel