[Bug] Dialogy fails to generate response on staging environment (working fine on production)
ltbringer opened this issue · 0 comments
ltbringer commented
Dialogy version 0.8.6
Error in response of kent slu service deployed on staging:
{"cause":"Traceback (most recent call last):\n File \"./slu/src/api/endpoints.py\", line 76, in slu\n response = PREDICT_API(\n File \"./slu/src/controller/prediction.py\", line 133, in predict\n build_test_case(\n File \"./slu/utils/make_test_cases.py\", line 24, in build_test_case\n with open(\nFileNotFoundError: [Errno 2] No such file or directory: 'tests/test_controller/test_cases.yaml'\n\nDuring handling of the above exception, another exception occurred:\n\nTraceback (most recent call last):\n File \"./slu/src/api/endpoints.py\", line 86, in slu\n return error_response.missing_models(os_error)\n File \"./slu/utils/error_response.py\", line 93, in missing_models\n jsonify(\n File \"/root/.pyenv/versions/3.8.2/lib/python3.8/site-packages/flask/json/__init__.py\", line 370, in jsonify\n dumps(data, indent=indent, separators=separators) + \"\\n\",\n File \"/root/.pyenv/versions/3.8.2/lib/python3.8/site-packages/flask/json/__init__.py\", line 211, in dumps\n rv = _json.dumps(obj, **kwargs)\n File \"/root/.pyenv/versions/3.8.2/lib/python3.8/json/__init__.py\", line 234, in dumps\n return cls(\n File \"/root/.pyenv/versions/3.8.2/lib/python3.8/json/encoder.py\", line 199, in encode\n chunks = self.iterencode(o, _one_shot=True)\n File \"/root/.pyenv/versions/3.8.2/lib/python3.8/json/encoder.py\", line 257, in iterencode\n return _iterencode(o, 0)\n File \"/root/.pyenv/versions/3.8.2/lib/python3.8/site-packages/flask/json/__init__.py\", line 100, in default\n return _json.JSONEncoder.default(self, o)\n File \"/root/.pyenv/versions/3.8.2/lib/python3.8/json/encoder.py\", line 179, in default\n raise TypeError(f'Object of type {o.__class__.__name__} '\nTypeError: Object of type FileNotFoundError is not JSON serializable\n","message":"Object of type FileNotFoundError is not JSON serializable"}
This error is coming from line 21 of slu/utils/make_test_cases.py where we are just checking production env and not staging therefore we move onto the next lines which requires the files mentioned in the error above (such as
tests/test_controller/test_cases.yaml which are not present in docker image).
if os.environ.get("ENVIRONMENT") == const.PRODUCTION:
return
with open(
os.path.join("tests", "test_controller", "test_cases.yaml"), "r"
) as handle:
test_cases = yaml.load(handle, Loader=yaml.SafeLoader)