uber/neuropod

AttributeError: module 'sys' has no attribute 'argv'

irasit opened this issue · 1 comments

Got this error when loading a model that contains sys.argv

LoadNeuropod modelPath = user_model/neuropod.zip failed: AttributeError: module 'sys' has no attribute 'argv'
At:
  /[redacted]/env/lib/python3.6/site-packages/ludwig/contrib.py(35): contrib_import
  /[redacted]/env/lib/python3.6/site-packages/ludwig/api.py(38): <module>
  <frozen importlib._bootstrap>(219): _call_with_frames_removed
  <frozen importlib._bootstrap_external>(678): exec_module
  <frozen importlib._bootstrap>(665): _load_unlocked
  <frozen importlib._bootstrap>(955): _find_and_load_unlocked
  <frozen importlib._bootstrap>(971): _find_and_load
  /tmp/tmp17kynda9.neuropod_python_symlinks/aa723e1c_34fd_4df9_b1de_df9076e88879/ludwig/neuropod_export.py(10): <module>
  <frozen importlib._bootstrap>(219): _call_with_frames_removed
  <frozen importlib._bootstrap_external>(678): exec_module
  <frozen importlib._bootstrap>(665): _load_unlocked
  <frozen importlib._bootstrap>(955): _find_and_load_unlocked
  <frozen importlib._bootstrap>(971): _find_and_load
  <frozen importlib._bootstrap>(994): _gcd_import
  /[redacted]/env/lib/python3.6/importlib/__init__.py(126): import_module
  /[redacted]/env/lib/python3.6/site-packages/neuropod-0.1.0-py3.6.egg/neuropod/backends/python/executor.py(120): __init__
  /[redacted]/env/lib/python3.6/site-packages/neuropod-0.1.0-py3.6.egg/neuropod/loader.py(29): load_neuropod

This issue related to this python issue , it only happen in embedded python system, and fixed in py3.8.

But to make it backward compatible, we can add this work around

import sys
if not hasattr(sys, 'argv'):
    sys.argv  = [''] 

After adding the fix in load_model, this problem still happened in another place.

LoadNeuropod modelPath = /mnt/mesos/sandbox/sandbox/tmp/DLInferenceTransformer_cb7c9b0bcdca_PID_dl_neuropod_integration_tests_ol_MID_tm20200618-034902-UHKBUHNJ-OKLFBD--1131379289 failed: AttributeError: module 'sys' has no attribute 'argv'

At:
  /home/udocker/michelangelo-deeplearning-inference/env/lib/python3.6/site-packages/ludwig/contrib.py(35): contrib_import
  /home/udocker/michelangelo-deeplearning-inference/env/lib/python3.6/site-packages/ludwig/api.py(38): <module>
  <frozen importlib._bootstrap>(219): _call_with_frames_removed
  <frozen importlib._bootstrap_external>(678): exec_module
  <frozen importlib._bootstrap>(665): _load_unlocked
  <frozen importlib._bootstrap>(955): _find_and_load_unlocked
  <frozen importlib._bootstrap>(971): _find_and_load
  /tmp/tmpygg1wlvu.neuropod_python_symlinks/49400b87_a06b_4297_ab3d_bb161a4e44dd/ludwig/neuropod_export.py(10): <module>
  <frozen importlib._bootstrap>(219): _call_with_frames_removed
  <frozen importlib._bootstrap_external>(678): exec_module
  <frozen importlib._bootstrap>(665): _load_unlocked
  <frozen importlib._bootstrap>(955): _find_and_load_unlocked
  <frozen importlib._bootstrap>(971): _find_and_load
  <frozen importlib._bootstrap>(994): _gcd_import
  /home/udocker/michelangelo-deeplearning-inference/env/lib/python3.6/importlib/__init__.py(126): import_module
  /home/udocker/michelangelo-deeplearning-inference/env/lib/python3.6/site-packages/neuropod-0.2.0-py3.6-linux-x86_64.egg/neuropod/backends/python/executor.py(130): __init__

Seems the best place to put it is in neuropod/backends/python/executor.py