Skip to content

Commit

Permalink
Merge branch 'master' into 6051_jupyter_chat_action_endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
rgstephens authored Jul 27, 2020
2 parents 78f4d5e + fb8049d commit 5ec4061
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 11 deletions.
6 changes: 4 additions & 2 deletions rasa/core/brokers/broker.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,14 +69,16 @@ def _create_from_endpoint_config(

broker = KafkaEventBroker.from_endpoint_config(endpoint_config)
else:
broker = _load_from_module_string(endpoint_config)
broker = _load_from_module_name_in_endpoint_config(endpoint_config)

if broker:
logger.debug(f"Instantiated event broker to '{broker.__class__.__name__}'.")
return broker


def _load_from_module_string(broker_config: EndpointConfig,) -> Optional["EventBroker"]:
def _load_from_module_name_in_endpoint_config(
broker_config: EndpointConfig,
) -> Optional["EventBroker"]:
"""Instantiate an event broker based on its class name."""
try:
event_broker_class = common.class_from_module_path(broker_config.type)
Expand Down
4 changes: 2 additions & 2 deletions rasa/core/interpreter.py
Original file line number Diff line number Diff line change
Expand Up @@ -293,10 +293,10 @@ def _create_from_endpoint_config(
elif endpoint_config.type is None or endpoint_config.type.lower() == "http":
return RasaNLUHttpInterpreter(endpoint_config=endpoint_config)
else:
return _load_from_module_string(endpoint_config)
return _load_from_module_name_in_endpoint_config(endpoint_config)


def _load_from_module_string(
def _load_from_module_name_in_endpoint_config(
endpoint_config: EndpointConfig,
) -> "NaturalLanguageInterpreter":
"""Instantiate an event channel based on its class name."""
Expand Down
8 changes: 5 additions & 3 deletions rasa/core/lock_store.py
Original file line number Diff line number Diff line change
Expand Up @@ -247,15 +247,17 @@ def _create_from_endpoint_config(
elif endpoint_config.type == "redis":
lock_store = RedisLockStore(host=endpoint_config.url, **endpoint_config.kwargs)
else:
lock_store = _load_from_module_string(endpoint_config)
lock_store = _load_from_module_name_in_endpoint_config(endpoint_config)

logger.debug(f"Connected to lock store '{lock_store.__class__.__name__}'.")

return lock_store


def _load_from_module_string(endpoint_config: EndpointConfig) -> "LockStore":
"""Given the name of a `LockStore` module tries to retrieve it."""
def _load_from_module_name_in_endpoint_config(
endpoint_config: EndpointConfig,
) -> "LockStore":
"""Retrieve a `LockStore` based on its class name."""

try:
lock_store_class = common.class_from_module_path(endpoint_config.type)
Expand Down
4 changes: 2 additions & 2 deletions rasa/core/nlg/generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,13 +67,13 @@ def _create_from_endpoint_config(

nlg = TemplatedNaturalLanguageGenerator(domain.templates)
else:
nlg = _load_from_module_string(endpoint_config, domain)
nlg = _load_from_module_name_in_endpoint_config(endpoint_config, domain)

logger.debug(f"Instantiated NLG to '{nlg.__class__.__name__}'.")
return nlg


def _load_from_module_string(
def _load_from_module_name_in_endpoint_config(
endpoint_config: EndpointConfig, domain: Domain
) -> "NaturalLanguageGenerator":
"""Initializes a custom natural language generator.
Expand Down
6 changes: 4 additions & 2 deletions rasa/core/tracker_store.py
Original file line number Diff line number Diff line change
Expand Up @@ -1057,14 +1057,16 @@ def _create_from_endpoint_config(
domain=domain, event_broker=event_broker, **endpoint_config.kwargs
)
else:
tracker_store = _load_from_module_string(domain, endpoint_config, event_broker)
tracker_store = _load_from_module_name_in_endpoint_config(
domain, endpoint_config, event_broker
)

logger.debug(f"Connected to {tracker_store.__class__.__name__}.")

return tracker_store


def _load_from_module_string(
def _load_from_module_name_in_endpoint_config(
domain: Domain, store: EndpointConfig, event_broker: Optional[EventBroker] = None
) -> "TrackerStore":
"""Initializes a custom tracker.
Expand Down

0 comments on commit 5ec4061

Please sign in to comment.