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

RecursionError in examples #187

Open
atollk opened this issue Dec 3, 2022 · 1 comment
Open

RecursionError in examples #187

atollk opened this issue Dec 3, 2022 · 1 comment

Comments

@atollk
Copy link

atollk commented Dec 3, 2022

I attempted to execute mystic/examples4/PP_surrogate_diam.py with mystic 0.4.0.

This caused a RecursionError to be thrown:

Traceback (most recent call last):
  File "test_project/mystic_test.py", line 179, in <module>
    diameter = UQ(RVstart, RVend, lower_bounds, upper_bounds)
  File "test_project/mystic_test.py", line 115, in UQ
    subdiameter, func_evals = optimize(cost, lb, ub)  # XXX: no initial conditions
  File "test_project/mystic_test.py", line 90, in optimize
    solver.Solve(cost, termination=CRT(tol, tol), strategy=Best1Exp, \
  File "test_project/venv/lib/python3.10/site-packages/mystic/differential_evolution.py", line 644, in Solve
    super(DifferentialEvolutionSolver2, self).Solve(cost, termination,\
  File "test_project/venv/lib/python3.10/site-packages/mystic/abstract_solver.py", line 1126, in Solve
    self._Solve(cost, ExtraArgs, **settings)
  File "test_project/venv/lib/python3.10/site-packages/mystic/abstract_solver.py", line 1069, in _Solve
    stop = self.Step(**settings) #XXX: remove need to pass settings?
  File "test_project/venv/lib/python3.10/site-packages/mystic/abstract_solver.py", line 1042, in Step
    self._Step(**kwds) #FIXME: not all kwds are given in __doc__
  File "test_project/venv/lib/python3.10/site-packages/mystic/differential_evolution.py", line 543, in _Step
    trialEnergy = self._map(cost, self.trialSolution, **self._mapconfig)
  File "test_project/venv/lib/python3.10/site-packages/pathos/parallel.py", line 226, in map
    return list(self.imap(f, *args))
  File "test_project/venv/lib/python3.10/site-packages/pathos/parallel.py", line 239, in imap
    return (subproc() for subproc in list(builtins.map(submit, *args)))
  File "test_project/venv/lib/python3.10/site-packages/pathos/parallel.py", line 235, in submit
    return _pool.submit(f, argz, globals=globals())
  File "test_project/venv/lib/python3.10/site-packages/ppft/_pp.py", line 474, in submit
    sfunc = self.__dumpsfunc((func, ) + depfuncs, modules)
  File "test_project/venv/lib/python3.10/site-packages/ppft/_pp.py", line 658, in __dumpsfunc
    sources = [self.__get_source(func) for func in funcs]
  File "test_project/venv/lib/python3.10/site-packages/ppft/_pp.py", line 658, in <listcomp>
    sources = [self.__get_source(func) for func in funcs]
  File "test_project/venv/lib/python3.10/site-packages/ppft/_pp.py", line 725, in __get_source
    self.__sourcesHM[hashf] = importable(func)
  File "test_project/venv/lib/python3.10/site-packages/dill/source.py", line 962, in importable
    src = _closuredsource(obj, alias=alias)
  File "test_project/venv/lib/python3.10/site-packages/dill/source.py", line 905, in _closuredsource
    src = importable(fobj,alias=name)#        wrong ref 'name'
  File "test_project/venv/lib/python3.10/site-packages/dill/source.py", line 962, in importable
    src = _closuredsource(obj, alias=alias)
  File "test_project/venv/lib/python3.10/site-packages/dill/source.py", line 905, in _closuredsource
    src = importable(fobj,alias=name)#        wrong ref 'name'
  File "test_project/venv/lib/python3.10/site-packages/dill/source.py", line 962, in importable
    src = _closuredsource(obj, alias=alias)
  File "test_project/venv/lib/python3.10/site-packages/dill/source.py", line 905, in _closuredsource
    src = importable(fobj,alias=name)#        wrong ref 'name'
  File "test_project/venv/lib/python3.10/site-packages/dill/source.py", line 962, in importable
    src = _closuredsource(obj, alias=alias)
  File "test_project/venv/lib/python3.10/site-packages/dill/source.py", line 905, in _closuredsource
    src = importable(fobj,alias=name)#        wrong ref 'name'
  File "test_project/venv/lib/python3.10/site-packages/dill/source.py", line 962, in importable
    src = _closuredsource(obj, alias=alias)
  File "test_project/venv/lib/python3.10/site-packages/dill/source.py", line 905, in _closuredsource
    src = importable(fobj,alias=name)#        wrong ref 'name'
  File "test_project/venv/lib/python3.10/site-packages/dill/source.py", line 962, in importable
    src = _closuredsource(obj, alias=alias)
  File "test_project/venv/lib/python3.10/site-packages/dill/source.py", line 905, in _closuredsource
    src = importable(fobj,alias=name)#        wrong ref 'name'
  File "test_project/venv/lib/python3.10/site-packages/dill/source.py", line 962, in importable
    src = _closuredsource(obj, alias=alias)
  File "test_project/venv/lib/python3.10/site-packages/dill/source.py", line 905, in _closuredsource
    src = importable(fobj,alias=name)#        wrong ref 'name'
  File "test_project/venv/lib/python3.10/site-packages/dill/source.py", line 962, in importable
    src = _closuredsource(obj, alias=alias)
  File "test_project/venv/lib/python3.10/site-packages/dill/source.py", line 905, in _closuredsource
    src = importable(fobj,alias=name)#        wrong ref 'name'
  File "test_project/venv/lib/python3.10/site-packages/dill/source.py", line 962, in importable
    src = _closuredsource(obj, alias=alias)
  File "test_project/venv/lib/python3.10/site-packages/dill/source.py", line 905, in _closuredsource
    src = importable(fobj,alias=name)#        wrong ref 'name'
  File "test_project/venv/lib/python3.10/site-packages/dill/source.py", line 962, in importable
    src = _closuredsource(obj, alias=alias)
  File "test_project/venv/lib/python3.10/site-packages/dill/source.py", line 905, in _closuredsource
    src = importable(fobj,alias=name)#        wrong ref 'name'
  File "test_project/venv/lib/python3.10/site-packages/dill/source.py", line 962, in importable
    src = _closuredsource(obj, alias=alias)
[...]
    src = importable(fobj,alias=name)#        wrong ref 'name'
  File "test_project/venv/lib/python3.10/site-packages/dill/source.py", line 962, in importable
    src = _closuredsource(obj, alias=alias)
  File "test_project/venv/lib/python3.10/site-packages/dill/source.py", line 905, in _closuredsource
    src = importable(fobj,alias=name)#        wrong ref 'name'
  File "test_project/venv/lib/python3.10/site-packages/dill/source.py", line 962, in importable
    src = _closuredsource(obj, alias=alias)
  File "test_project/venv/lib/python3.10/site-packages/dill/source.py", line 905, in _closuredsource
    src = importable(fobj,alias=name)#        wrong ref 'name'
  File "test_project/venv/lib/python3.10/site-packages/dill/source.py", line 962, in importable
    src = _closuredsource(obj, alias=alias)
  File "test_project/venv/lib/python3.10/site-packages/dill/source.py", line 905, in _closuredsource
    src = importable(fobj,alias=name)#        wrong ref 'name'
  File "test_project/venv/lib/python3.10/site-packages/dill/source.py", line 962, in importable
    src = _closuredsource(obj, alias=alias)
  File "test_project/venv/lib/python3.10/site-packages/dill/source.py", line 905, in _closuredsource
    src = importable(fobj,alias=name)#        wrong ref 'name'
  File "test_project/venv/lib/python3.10/site-packages/dill/source.py", line 962, in importable
    src = _closuredsource(obj, alias=alias)
  File "test_project/venv/lib/python3.10/site-packages/dill/source.py", line 905, in _closuredsource
    src = importable(fobj,alias=name)#        wrong ref 'name'
  File "test_project/venv/lib/python3.10/site-packages/dill/source.py", line 962, in importable
    src = _closuredsource(obj, alias=alias)
  File "test_project/venv/lib/python3.10/site-packages/dill/source.py", line 905, in _closuredsource
    src = importable(fobj,alias=name)#        wrong ref 'name'
  File "test_project/venv/lib/python3.10/site-packages/dill/source.py", line 962, in importable
    src = _closuredsource(obj, alias=alias)
  File "test_project/venv/lib/python3.10/site-packages/dill/source.py", line 905, in _closuredsource
    src = importable(fobj,alias=name)#        wrong ref 'name'
  File "test_project/venv/lib/python3.10/site-packages/dill/source.py", line 962, in importable
    src = _closuredsource(obj, alias=alias)
  File "test_project/venv/lib/python3.10/site-packages/dill/source.py", line 905, in _closuredsource
    src = importable(fobj,alias=name)#        wrong ref 'name'
  File "test_project/venv/lib/python3.10/site-packages/dill/source.py", line 962, in importable
    src = _closuredsource(obj, alias=alias)
  File "test_project/venv/lib/python3.10/site-packages/dill/source.py", line 905, in _closuredsource
    src = importable(fobj,alias=name)#        wrong ref 'name'
  File "test_project/venv/lib/python3.10/site-packages/dill/source.py", line 962, in importable
    src = _closuredsource(obj, alias=alias)
  File "test_project/venv/lib/python3.10/site-packages/dill/source.py", line 905, in _closuredsource
    src = importable(fobj,alias=name)#        wrong ref 'name'
  File "test_project/venv/lib/python3.10/site-packages/dill/source.py", line 962, in importable
    src = _closuredsource(obj, alias=alias)
  File "test_project/venv/lib/python3.10/site-packages/dill/source.py", line 905, in _closuredsource
    src = importable(fobj,alias=name)#        wrong ref 'name'
  File "test_project/venv/lib/python3.10/site-packages/dill/source.py", line 962, in importable
    src = _closuredsource(obj, alias=alias)
  File "test_project/venv/lib/python3.10/site-packages/dill/source.py", line 905, in _closuredsource
    src = importable(fobj,alias=name)#        wrong ref 'name'
  File "test_project/venv/lib/python3.10/site-packages/dill/source.py", line 962, in importable
    src = _closuredsource(obj, alias=alias)
  File "test_project/venv/lib/python3.10/site-packages/dill/source.py", line 905, in _closuredsource
    src = importable(fobj,alias=name)#        wrong ref 'name'
  File "test_project/venv/lib/python3.10/site-packages/dill/source.py", line 962, in importable
    src = _closuredsource(obj, alias=alias)
  File "test_project/venv/lib/python3.10/site-packages/dill/source.py", line 905, in _closuredsource
    src = importable(fobj,alias=name)#        wrong ref 'name'
  File "test_project/venv/lib/python3.10/site-packages/dill/source.py", line 962, in importable
    src = _closuredsource(obj, alias=alias)
  File "test_project/venv/lib/python3.10/site-packages/dill/source.py", line 902, in _closuredsource
    src = getsource(fobj, alias) # DO NOT include dependencies
  File "test_project/venv/lib/python3.10/site-packages/dill/source.py", line 374, in getsource
    lines, lnum = getsourcelines(object, enclosing=enclosing)
  File "test_project/venv/lib/python3.10/site-packages/dill/source.py", line 345, in getsourcelines
    code, n = getblocks(object, lstrip=lstrip, enclosing=enclosing, locate=True)
  File "test_project/venv/lib/python3.10/site-packages/dill/source.py", line 271, in getblocks
    lines, lnum = findsource(object)
  File "test_project/venv/lib/python3.10/site-packages/dill/source.py", line 158, in findsource
    sourcefile = getsourcefile(module)
  File "/usr/lib/python3.10/inspect.py", line 817, in getsourcefile
    filename = getfile(object)
  File "/usr/lib/python3.10/inspect.py", line 775, in getfile
    if ismodule(object):
  File "/usr/lib/python3.10/inspect.py", line 189, in ismodule
    return isinstance(object, types.ModuleType)
RecursionError: maximum recursion depth exceeded while calling a Python object
@mmckerns
Copy link
Member

mmckerns commented Dec 3, 2022

I can confirm this behavior for at least the following:

Python 3.10.8 (main, Oct 12 2022, 03:24:38) [Clang 10.0.1 (clang-1001.0.46.4)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import mystic
>>> import pathos
>>> import ppft
>>> import dill
>>> mystic.__version__
'0.4.1.dev0'
>>> pathos.__version__
'0.3.1.dev0'
>>> ppft.__version__
'1.7.6.7.dev0'
>>> dill.__version__
'0.3.7.dev0'
>>> 

There have been some recent changes in dill which appear to have broken this example. Potentially this:

  File "test_project/venv/lib/python3.10/site-packages/dill/source.py", line 962, in importable
    src = _closuredsource(obj, alias=alias)
  File "test_project/venv/lib/python3.10/site-packages/dill/source.py", line 905, in _closuredsource
    src = importable(fobj,alias=name)#        wrong ref 'name'

stems from this change, which touched dill.source:
uqfoundation/dill#531
but, the root cause will have to be traced down.

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

2 participants