Cannot run the QuickStart
Huangmao1208 opened this issue · 11 comments
from nl2ltl import translate
from nl2ltl.engines.rasa.core import RasaEngine
from nl2ltl.engines.gpt.core import openai
from nl2ltl.filters.simple_filters import BasicFilter
from nl2ltl.engines.utils import pretty
engine = RasaEngine()
#engine = openai.Engine()
filter = BasicFilter()
utterance = "Eventually send me a Slack after receiving a Gmail"
ltlf_formulas = translate(utterance, engine, filter)
pretty(ltlf_formulas)
ImportError Traceback (most recent call last)
File ~/.local/lib/python3.9/site-packages/rasa/engine/graph.py:112, in GraphSchema.from_dict(cls, serialized_graph_schema)
109 try:
110 serialized_node[
111 "uses"
--> 112 ] = rasa.shared.utils.common.class_from_module_path(
113 serialized_node["uses"]
114 )
116 resource = serialized_node["resource"]
File ~/.local/lib/python3.9/site-packages/rasa/shared/utils/common.py:36, in class_from_module_path(module_path, lookup_path)
35 module_name, _, class_name = module_path.rpartition(".")
---> 36 m = importlib.import_module(module_name)
37 klass = getattr(m, class_name, None)
File /usr/lib/python3.9/importlib/init.py:127, in import_module(name, package)
126 level += 1
--> 127 return _bootstrap._gcd_import(name[level:], package, level)
File :1030, in _gcd_import(name, package, level)
File :1007, in find_and_load(name, import)
File :986, in find_and_load_unlocked(name, import)
File :680, in _load_unlocked(spec)
File :850, in exec_module(self, module)
File :228, in _call_with_frames_removed(f, *args, **kwds)
File ~/.local/lib/python3.9/site-packages/rasa/graph_components/validators/default_recipe_validator.py:12
11 from rasa.nlu.extractors.regex_entity_extractor import RegexEntityExtractor
---> 12 from rasa.nlu.extractors.crf_entity_extractor import (
13 CRFEntityExtractor,
14 CRFEntityExtractorOptions,
15 )
16 from rasa.nlu.extractors.entity_synonyms import EntitySynonymMapper
File ~/.local/lib/python3.9/site-packages/rasa/nlu/extractors/crf_entity_extractor.py:18
17 from rasa.engine.storage.storage import ModelStorage
---> 18 from rasa.nlu.test import determine_token_labels
19 from rasa.nlu.tokenizers.spacy_tokenizer import POS_TAG_KEY
File ~/.local/lib/python3.9/site-packages/rasa/nlu/test.py:34
33 import rasa.shared.utils.io
---> 34 import rasa.utils.plotting as plot_utils
35 import rasa.utils.io as io_utils
File ~/.local/lib/python3.9/site-packages/rasa/utils/plotting.py:8
7 from typing import Any, Callable, List, Optional, Text, TypeVar, Union, Tuple
----> 8 import matplotlib
9 from matplotlib.ticker import FormatStrFormatter
File ~/.local/lib/python3.9/site-packages/matplotlib/init.py:109
107 # cbook must import matplotlib only within function
108 # definitions, so it is safe to import from it here.
--> 109 from . import _api, _version, cbook, docstring, rcsetup
110 from matplotlib.cbook import MatplotlibDeprecationWarning, sanitize_sequence
File ~/.local/lib/python3.9/site-packages/matplotlib/rcsetup.py:27
26 from matplotlib.cbook import ls_mapper
---> 27 from matplotlib.colors import Colormap, is_color_like
28 from matplotlib.fontconfig_pattern import parse_fontconfig_pattern
File ~/.local/lib/python3.9/site-packages/matplotlib/colors.py:51
50 import re
---> 51 from PIL import Image
52 from PIL.PngImagePlugin import PngInfo
File /usr/lib/python3/dist-packages/PIL/Image.py:89
83 try:
84 # If the _imaging C module is not present, Pillow will not load.
85 # Note that other modules should not refer to _imaging directly;
86 # import Image and use the Image.core variable instead.
87 # Also note that Image.core is not a publicly documented interface,
88 # and should be considered private and subject to change.
---> 89 from . import _imaging as core
91 if version != getattr(core, "PILLOW_VERSION", None):
ImportError: cannot import name '_imaging' from 'PIL' (/usr/lib/python3/dist-packages/PIL/init.py)
The above exception was the direct cause of the following exception:
GraphSchemaException Traceback (most recent call last)
Cell In[3], line 7
4 from nl2ltl.filters.simple_filters import BasicFilter
5 from nl2ltl.engines.utils import pretty
----> 7 engine = RasaEngine()
8 #engine = openai.Engine()
9 filter = BasicFilter()
File ~/Documents/nl2ltl/nl2ltl/engines/rasa/core.py:42, in RasaEngine.init(self, model)
37 def init(
38 self,
39 model: Path = None,
40 ):
41 """Rasa NLU Engine initialization."""
---> 42 self._load_model(model)
44 self._check_consistency()
File ~/Documents/nl2ltl/nl2ltl/engines/rasa/core.py:50, in RasaEngine._load_model(self, model)
48 self.agent = Agent.load(model)
49 else:
---> 50 self.agent = Agent.load(_get_latest_model(path=MODEL_OUTPUT_PATH))
File ~/.local/lib/python3.9/site-packages/rasa/core/agent.py:345, in Agent.load(cls, model_path, domain, generator, tracker_store, lock_store, action_endpoint, fingerprint, model_server, remote_storage, http_interpreter)
333 """Constructs a new agent and loads the processer and model."""
334 agent = Agent(
335 domain=domain,
336 generator=generator,
(...)
343 http_interpreter=http_interpreter,
344 )
--> 345 agent.load_model(model_path=model_path, fingerprint=fingerprint)
346 return agent
File ~/.local/lib/python3.9/site-packages/rasa/core/agent.py:352, in Agent.load_model(self, model_path, fingerprint)
348 def load_model(
349 self, model_path: Union[Text, Path], fingerprint: Optional[Text] = None
350 ) -> None:
351 """Loads the agent's model and processor given a new model path."""
--> 352 self.processor = MessageProcessor(
353 model_path=model_path,
354 tracker_store=self.tracker_store,
355 lock_store=self.lock_store,
356 action_endpoint=self.action_endpoint,
357 generator=self.nlg,
358 http_interpreter=self.http_interpreter,
359 )
360 self.domain = self.processor.domain
362 self._set_fingerprint(fingerprint)
File ~/.local/lib/python3.9/site-packages/rasa/core/processor.py:105, in MessageProcessor.init(self, model_path, tracker_store, lock_store, generator, action_endpoint, max_number_of_predictions, on_circuit_break, http_interpreter)
103 self.on_circuit_break = on_circuit_break
104 self.action_endpoint = action_endpoint
--> 105 self.model_filename, self.model_metadata, self.graph_runner = self._load_model(
106 model_path
107 )
109 if self.model_metadata.assistant_id is None:
110 rasa.shared.utils.io.raise_warning(
111 f"The model metadata does not contain a value for the "
112 f"'{ASSISTANT_ID_KEY}' attribute. Check that 'config.yml' "
(...)
116 UserWarning,
117 )
File ~/.local/lib/python3.9/site-packages/rasa/core/processor.py:142, in MessageProcessor._load_model(model_path)
140 with TempDirectoryPath(get_temp_dir_name()) as temporary_directory:
141 try:
--> 142 metadata, runner = loader.load_predict_graph_runner(
143 Path(temporary_directory),
144 Path(model_tar),
145 LocalModelStorage,
146 DaskGraphRunner,
147 )
148 return os.path.basename(model_tar), metadata, runner
149 except tarfile.ReadError:
File ~/.local/lib/python3.9/site-packages/rasa/engine/loader.py:26, in load_predict_graph_runner(storage_path, model_archive_path, model_storage_class, graph_runner_class)
9 def load_predict_graph_runner(
10 storage_path: Path,
11 model_archive_path: Path,
12 model_storage_class: Type[ModelStorage],
13 graph_runner_class: Type[GraphRunner],
14 ) -> Tuple[ModelMetadata, GraphRunner]:
15 """Loads a model from an archive and creates the prediction graph runner.
16
17 Args:
(...)
24 A tuple containing the model metadata and the prediction graph runner.
25 """
---> 26 model_storage, model_metadata = model_storage_class.from_model_archive(
27 storage_path=storage_path, model_archive_path=model_archive_path
28 )
29 runner = graph_runner_class.create(
30 graph_schema=model_metadata.predict_schema,
31 model_storage=model_storage,
(...)
34 ),
35 )
36 return model_metadata, runner
File ~/.local/lib/python3.9/site-packages/rasa/engine/storage/local_model_storage.py:95, in LocalModelStorage.from_model_archive(cls, storage_path, model_archive_path)
89 logger.debug(f"Extracted model to '{temporary_directory_path}'.")
91 cls._initialize_model_storage_from_model_archive(
92 temporary_directory_path, storage_path
93 )
---> 95 metadata = cls._load_metadata(temporary_directory_path)
97 return (cls(storage_path), metadata)
File ~/.local/lib/python3.9/site-packages/rasa/engine/storage/local_model_storage.py:154, in LocalModelStorage._load_metadata(directory)
148 @staticmethod
149 def _load_metadata(directory: Path) -> ModelMetadata:
150 serialized_metadata = rasa.shared.utils.io.read_json_file(
151 directory / MODEL_ARCHIVE_METADATA_FILE
152 )
--> 154 return ModelMetadata.from_dict(serialized_metadata)
File ~/.local/lib/python3.9/site-packages/rasa/engine/storage/storage.py:194, in ModelMetadata.from_dict(cls, serialized)
178 """Loads ModelMetadata
which has been serialized using metadata.as_dict()
.
179
180 Args:
(...)
184 Instantiated ModelMetadata
.
185 """
186 from rasa.engine.graph import GraphSchema
188 return ModelMetadata(
189 trained_at=datetime.fromisoformat(serialized["trained_at"]),
190 rasa_open_source_version=serialized["rasa_open_source_version"],
191 model_id=serialized["model_id"],
192 assistant_id=serialized.get("assistant_id"),
193 domain=Domain.from_dict(serialized["domain"]),
--> 194 train_schema=GraphSchema.from_dict(serialized["train_schema"]),
195 predict_schema=GraphSchema.from_dict(serialized["predict_schema"]),
196 training_type=TrainingType(serialized["training_type"]),
197 project_fingerprint=serialized["project_fingerprint"],
198 core_target=serialized["core_target"],
199 nlu_target=serialized["nlu_target"],
200 language=serialized["language"],
201 # optional, since introduced later
202 spaces=serialized.get("spaces"),
203 )
File ~/.local/lib/python3.9/site-packages/rasa/engine/graph.py:121, in GraphSchema.from_dict(cls, serialized_graph_schema)
118 serialized_node["resource"] = Resource(**resource)
120 except ImportError as e:
--> 121 raise GraphSchemaException(
122 "Error deserializing graph schema. Can't "
123 "find class for graph component type "
124 f"'{serialized_node['uses']}'."
125 ) from e
127 nodes[node_name] = SchemaNode(**serialized_node)
129 return GraphSchema(nodes)
GraphSchemaException: Error deserializing graph schema. Can't find class for graph component type 'rasa.graph_components.validators.default_recipe_validator.DefaultV1RecipeValidator'.
Hi @Huangmao1208,
thanks for reaching out! I think the problem is that you're using python 3.9
, which is not supported by rasa==3.5.11
. As written in the README, the support is only for python 3.8
.
However, I'm currently working on an update of the package, which will update rasa
to the latest version and it will support from python 3.8
to python 3.10
.
Stay tuned as there will be a new release pretty soon (few hours)...
Hi @Huangmao1208,
thanks for reaching out! I think the problem is that you're using
python 3.9
, which is not supported byrasa==3.5.11
. As written in the README, the support is only forpython 3.8
.However, I'm currently working on an update of the package, which will update
rasa
to the latest version and it will support frompython 3.8
topython 3.10
.Stay tuned as there will be a new release pretty soon (few hours)...
Great! Thanks for the help!!!
i have tried to use python3.8, it gives me an error as
ModuleNotFoundError: No module named 'zoneinfo'
And I have searched online, it says I have to use from backports.zoneinfo import ZoneInfo
, but I cannot overwritten File [/usr/lib/python3/dist-packages/pytz/__init__.py:16]
Did you ever face this problem before?
@Huangmao1208, this error is a weird one. I've never encountered it. It seems related to one of your packages installed in the environment. Are you using a virtual environment with dependencies only?
this error is a weird one. I've never encountered it. It seems related to one of your packages installed in the environment. Are you using a virtual environment with dependencies only?
Hey @francescofuggitti
Yes, I use the virtual environment with python3.8
It's hard to tell what is going wrong in your environment. Could you post here the exact list of commands you run, so we can try to reproduce it?
I am not sure if I misunderstand things, what I did is run the quickstart code below in jupyter notebook.
from nl2ltl import translate
from nl2ltl.engines.rasa.core import RasaEngine
from nl2ltl.filters.simple_filters import BasicFilter
from nl2ltl.engines.utils import pretty
engine = RasaEngine()
filter = BasicFilter()
utterance = "Eventually send me a Slack after receiving a Gmail"
ltlf_formulas = translate(utterance, engine, filter)
pretty(ltlf_formulas)
Ok, what are the steps you used to install the package?
In a fresh environment, can you try to install it from source with git clone ...
, then cd nl2ltl
and then run pip install -e .
?
Ok, what are the steps you used to install the package?
In a fresh environment, can you try to install it from source with
git clone ...
, thencd nl2ltl
and then runpip install -e .
?
Yes, I have done this. These steps didn't have any error
Mmmh, then I really don't know how I can help you. All tests and workflows are working and they are isolated builds...
FYI, I've made a new release v0.0.5
, where rasa
is made optional (as rasa
has several conflicts with other packages). You can try to install nl2ltl
with pip install -e .
(pay attention to the -e
flag) and then use the GPTEngine as follows:
from nl2ltl import translate
from nl2ltl.engines.gpt.core import GPTEngine
from nl2ltl.filters.simple_filters import BasicFilter
from nl2ltl.engines.utils import pretty
engine = GPTEngine()
filter = BasicFilter()
utterance = "Eventually send me a Slack after receiving a Gmail"
ltlf_formulas = translate(utterance, engine, filter)
pretty(ltlf_formulas)
Let me know if that works.
I'll close this issue as the new version 0.0.5 has been release and all tests are passing