Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Models throw error after starting python shell editor #2367

Open
wpotrzebowski opened this issue Nov 3, 2022 · 0 comments
Open

Models throw error after starting python shell editor #2367

wpotrzebowski opened this issue Nov 3, 2022 · 0 comments

Comments

@wpotrzebowski
Copy link
Contributor

Describe the bug
As pointed out in #2263 models throw error after running python shell editor

To Reproduce
Steps to reproduce the behavior:

  1. Select model and compute
  2. Open python shell editor
  3. Select another model
  4. See error
5:34:41 - ERROR: Traceback (most recent call last):
  File "sas/sascalc/data_util/calcthread.py", line 272, in _run
  File "sas/qtgui/Perspectives/Fitting/ModelThread.py", line 179, in compute
  File "sasmodels/sasview_model.py", line 713, in calculate_Iq
    return self._calculate_Iq(qx, qy)
  File "sasmodels/sasview_model.py", line 721, in _calculate_Iq
    self.__class__._model = core.build_model(self._model_info)
  File "sasmodels/core.py", line 335, in build_model
    source = generate.make_source(model_info)
  File "sasmodels/generate.py", line 1025, in make_source
    lineno = getframeinfo(currentframe()).lineno + 2
  File "inspect.py", line 1473, in getframeinfo
  File "PyInstaller/hooks/rthooks/pyi_rth_inspect.py", line 25, in _pyi_getsourcefile
AttributeError: module '__main__' has no attribute '__file__'
15:34:41 - ERROR: Traceback (most recent call last):
  File "sas/sascalc/data_util/calcthread.py", line 272, in _run
  File "sas/qtgui/Perspectives/Fitting/ModelThread.py", line 179, in compute
  File "sasmodels/sasview_model.py", line 713, in calculate_Iq
    return self._calculate_Iq(qx, qy)
  File "sasmodels/sasview_model.py", line 721, in _calculate_Iq
    self.__class__._model = core.build_model(self._model_info)
  File "sasmodels/core.py", line 335, in build_model
    source = generate.make_source(model_info)
  File "sasmodels/generate.py", line 1025, in make_source
    lineno = getframeinfo(currentframe()).lineno + 2
  File "inspect.py", line 1473, in getframeinfo
  File "PyInstaller/hooks/rthooks/pyi_rth_inspect.py", line 25, in _pyi_getsourcefile
AttributeError: module '__main__' has no attribute '__file__'

SasView version (please complete the following information):

  • 5.0.5 after 2263 being merged

Operating system (please complete the following information):

  • All

Additional context
As mentioned by @pkienzle:
`I suspect the error is a result of the python app builder putting modules in a zip file. IIRC the import hook which loads the module from the zip does not define file. That doesn't explain why the problem is showing up now.

The code which is failing is not critical. It is telling the model compiler that the code is coming from the current line in generate.py so that it'll be easier to interpret compiler errors. As a short term fix we can wrap this in an exception handler and use a hard-coded line number as the default. It doesn't matter if the offset drifts a little as the code is modified; just knowing that the code is coming from generate.py should be enough to debug any problems.`

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant