Skip to content

Commit

Permalink
chore: add warnings (#641)
Browse files Browse the repository at this point in the history
* chore: add warnings

make IDEs signal deprecated code instead of relying on runtime logs only

* update python version
  • Loading branch information
JarbasAl authored Jan 4, 2025
1 parent 94aee92 commit d755ee5
Show file tree
Hide file tree
Showing 11 changed files with 209 additions and 17 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/license_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/publish_stable.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release_workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 9 additions & 1 deletion mycroft/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
"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,
)
147 changes: 136 additions & 11 deletions ovos_core/intent_services/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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,
)
8 changes: 8 additions & 0 deletions ovos_core/intent_services/adapt_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
)
8 changes: 8 additions & 0 deletions ovos_core/intent_services/commonqa_service.py
Original file line number Diff line number Diff line change
@@ -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,
)
8 changes: 8 additions & 0 deletions ovos_core/intent_services/ocp_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
)
8 changes: 8 additions & 0 deletions ovos_core/intent_services/padacioso_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
)
8 changes: 8 additions & 0 deletions ovos_core/intent_services/padatious_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
)
Loading

0 comments on commit d755ee5

Please sign in to comment.