rstudio / vetiver-python

Version, share, deploy, and monitor models.
https://rstudio.github.io/vetiver-python/stable/
MIT License
60 stars 17 forks source link

Error when reading python_version from model metadata #148

Closed dbkegley closed 1 year ago

dbkegley commented 1 year ago

Describe the bug

2023/01/30 20:46:55.616070366 Unexpected error while running Python API: 'NoneType' object is not iterable
2023/01/30 20:46:55.629334829 Traceback (most recent call last):
2023/01/30 20:46:55.629366867   File "/opt/rstudio-connect/python/connect_fastapi_runtime.py", line 471, in <module>
2023/01/30 20:46:55.629402780     main(sys.argv)
2023/01/30 20:46:55.629437213   File "/opt/rstudio-connect/python/connect_fastapi_runtime.py", line 410, in main
2023/01/30 20:46:55.629438248     user_app = import_app(entrypoint, app_mode)
2023/01/30 20:46:55.629450763   File "/opt/rstudio-connect/python/connect_common_runtime.py", line 132, in import_app
2023/01/30 20:46:55.629451330     module = import_module(module_name)
2023/01/30 20:46:55.629457614   File "/opt/python/3.9.2/lib/python3.9/importlib/__init__.py", line 127, in import_module
2023/01/30 20:46:55.629458124     return _bootstrap._gcd_import(name[level:], package, level)
2023/01/30 20:46:55.629471240   File "<frozen importlib._bootstrap>", line 1030, in _gcd_import
2023/01/30 20:46:55.629473049   File "<frozen importlib._bootstrap>", line 1007, in _find_and_load
2023/01/30 20:46:55.629494192   File "<frozen importlib._bootstrap>", line 986, in _find_and_load_unlocked
2023/01/30 20:46:55.629549681   File "<frozen importlib._bootstrap>", line 680, in _load_unlocked
2023/01/30 20:46:55.629560240   File "<frozen importlib._bootstrap_external>", line 790, in exec_module
2023/01/30 20:46:55.629560893   File "<frozen importlib._bootstrap>", line 228, in _call_with_frames_removed
2023/01/30 20:46:55.629569775   File "/opt/rstudio-connect/mnt/app/app.py", line 7, in <module>
2023/01/30 20:46:55.629570297     v = VetiverModel.from_pin(b, 'ap311532/cars_mpg', version = '100')
2023/01/30 20:46:55.629582672   File "/opt/rstudio-connect/mnt/app/python/env/lib/python3.9/site-packages/vetiver/vetiver_model.py", line 119, in from_pin
2023/01/30 20:46:55.629598822     return cls(
2023/01/30 20:46:55.629630152   File "/opt/rstudio-connect/mnt/app/python/env/lib/python3.9/site-packages/vetiver/vetiver_model.py", line 94, in __init__
2023/01/30 20:46:55.629634383     self.metadata = translator.create_meta(metadata)
2023/01/30 20:46:55.629657150   File "/opt/rstudio-connect/mnt/app/python/env/lib/python3.9/site-packages/vetiver/handlers/base.py", line 95, in create_meta
2023/01/30 20:46:55.629658320     return VetiverMeta.from_dict(metadata, pip_name)
2023/01/30 20:46:55.629671020   File "/opt/rstudio-connect/mnt/app/python/env/lib/python3.9/site-packages/vetiver/meta.py", line 30, in from_dict
2023/01/30 20:46:55.629671562     python_version = tuple(metadata.get("python_version", sys.version_info))
2023/01/30 20:46:55.629685708 TypeError: 'NoneType' object is not iterable

To Reproduce Steps to reproduce the behavior:

  1. Go to '...'
  2. Click on '....'
  3. Scroll down to '....'
  4. See error

Expected behavior

The model runs without errors

Screenshots If applicable, add screenshots to help explain your problem.

Desktop (please complete the following information):

Additional context

This came up during a customer support ticket from the Connect team. Still waiting to hear back from the customer on the exact Connect/vetiver versions

isabelizimm commented 1 year ago

Thank you for this report! It looks like there is a bug if None is supplied as Python version, since it is trying to coerce it into a tuple. I'm adding a fix in #149 to add proper handling around this.