Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove outdated backwards compat code #9187

Merged
merged 10 commits into from Jul 28, 2021
3 changes: 3 additions & 0 deletions changelog/6487.removal.md
@@ -0,0 +1,3 @@
Remove backwards compatibility code with Rasa Open Source 1.x, Rasa Enterprise 0.35, and other outdated
backwards compatibility code in `rasa.cli.x`, `rasa.core.utils`, `rasa.model_testing`, `rasa.model_training`
and `rasa.shared.core.events`.
30 changes: 8 additions & 22 deletions rasa/cli/x.py
Expand Up @@ -493,28 +493,14 @@ def run_locally(args: argparse.Namespace) -> None:

# noinspection PyBroadException
try:
try:
local.main(
args,
project_path,
args.data,
token=rasa_x_token,
config_path=config_path,
domain_path=domain_path,
)
except TypeError as e:
if "domain_path" in str(e):
# backwards compatibility with Rasa X versions < 0.35.0
# fixes regression https://github.com/RasaHQ/rasa/issues/7592
local.main(
args,
project_path,
args.data,
token=rasa_x_token,
config_path=config_path,
)
else:
raise
local.main(
args,
project_path,
args.data,
token=rasa_x_token,
config_path=config_path,
domain_path=domain_path,
)
wochinge marked this conversation as resolved.
Show resolved Hide resolved
except RasaXTermsError:
# User didn't accept the Rasa X terms.
pass
Expand Down
2 changes: 0 additions & 2 deletions rasa/core/utils.py
Expand Up @@ -19,8 +19,6 @@
from rasa.constants import DEFAULT_SANIC_WORKERS, ENV_SANIC_WORKERS
from rasa.shared.constants import DEFAULT_ENDPOINTS_PATH

# backwards compatibility 1.0.x
# noinspection PyUnresolvedReferences
wochinge marked this conversation as resolved.
Show resolved Hide resolved
from rasa.core.lock_store import LockStore, RedisLockStore, InMemoryLockStore
from rasa.utils.endpoints import EndpointConfig, read_endpoint_config
from sanic import Sanic
Expand Down
4 changes: 0 additions & 4 deletions rasa/model_testing.py
Expand Up @@ -127,10 +127,6 @@ def test_core_models(
)


# backwards compatibility
test = rasa.test
wochinge marked this conversation as resolved.
Show resolved Hide resolved


def test_core(
model: Optional[Text] = None,
stories: Optional[Text] = None,
Expand Down
4 changes: 0 additions & 4 deletions rasa/model_training.py
Expand Up @@ -51,10 +51,6 @@ class TrainingResult(NamedTuple):
code: int = 0


# backwards compatibility
train = rasa.train
wochinge marked this conversation as resolved.
Show resolved Hide resolved


async def train_async(
domain: Union[Domain, Text],
config: Text,
Expand Down
14 changes: 1 addition & 13 deletions rasa/shared/core/events.py
Expand Up @@ -247,19 +247,7 @@ def __init__(
metadata: Optional[Dict[Text, Any]] = None,
) -> None:
self.timestamp = timestamp or time.time()
self._metadata = metadata or {}

@property
def metadata(self) -> Dict[Text, Any]:
# Needed for compatibility with Rasa versions <1.4.0. Previous versions
# of Rasa serialized trackers using the pickle module. For the moment,
# Rasa still supports loading these serialized trackers with pickle,
# but will use JSON in any subsequent save operations. Versions of
# trackers serialized with pickle won't include the `_metadata`
# attribute in their events, so it is necessary to define this getter
# in case the attribute does not exist. For more information see
# CHANGELOG.rst.
return getattr(self, "_metadata", {})
self.metadata = metadata or {}
wochinge marked this conversation as resolved.
Show resolved Hide resolved

def __ne__(self, other: Any) -> bool:
# Not strictly necessary, but to avoid having both x==y and x!=y
Expand Down
3 changes: 2 additions & 1 deletion tests/test_model_training.py
Expand Up @@ -23,7 +23,8 @@
from rasa.core.interpreter import RasaNLUInterpreter
from rasa.nlu.model import Interpreter

from rasa.model_training import train_core, train_nlu, train, dry_run_result
from rasa import train
from rasa.model_training import train_core, train_nlu, dry_run_result
m-vdb marked this conversation as resolved.
Show resolved Hide resolved
from rasa.utils.tensorflow.constants import EPOCHS
from tests.conftest import AsyncMock
from tests.test_model import _fingerprint
Expand Down