Skip to content
New issue

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

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

Already on GitHub? # to your account

__init__() missing 1 required keyword-only argument: 'ctx' #22

Open
stmax82 opened this issue Sep 24, 2015 · 1 comment
Open

__init__() missing 1 required keyword-only argument: 'ctx' #22

stmax82 opened this issue Sep 24, 2015 · 1 comment

Comments

@stmax82
Copy link

stmax82 commented Sep 24, 2015

I tried to run the first example from the docs:
http://metaopt.readthedocs.org/en/latest/#

The line:

from metaopt.core.optimize.optimize import optimize

produces the following error:

__init__() missing 1 required keyword-only argument: 'ctx'

This happens on Python 3.4 / Windows 8 x64.

Here's the complete example:

from metaopt.core.paramspec.util import param
from metaopt.core.optimize.optimize import optimize

@param.float("a", interval=[-1, 1])
@param.float("b", interval=[0, 1])
def f(a, b):
    return a**2 + b**2

if __name__ == '__main__':
    args = optimize(f, timeout=60)
    print(args);

And the whole stacktrace:

TypeError                                 Traceback (most recent call last)
<ipython-input-3-dea198b06e06> in <module>()
      1 from metaopt.core.paramspec.util import param
----> 2 from metaopt.core.optimize.optimize import optimize
      3 
      4 @param.float("a", interval=[-1, 1])
      5 @param.float("b", interval=[0, 1])

C:\Anaconda3\lib\site-packages\metaopt\core\optimize\optimize.py in <module>()
      8 
      9 # First Party
---> 10 from metaopt.concurrent.invoker.multiprocess import MultiProcessInvoker
     11 from metaopt.concurrent.invoker.pluggable import PluggableInvoker
     12 from metaopt.core.optimize.util.exception import GlobalTimeoutError, \

C:\Anaconda3\lib\site-packages\metaopt\concurrent\invoker\multiprocess.py in <module>()
     13 
     14 # First Party
---> 15 from metaopt.concurrent.employer.process import ProcessWorkerEmployer
     16 from metaopt.concurrent.invoker.invoker import Invoker
     17 from metaopt.concurrent.invoker.util.call_handle import CallHandle

C:\Anaconda3\lib\site-packages\metaopt\concurrent\employer\process.py in <module>()
     19 
     20 
---> 21 class ProcessWorkerEmployer(Employer):
     22     """
     23     Keeps track of up to as many worker processes as there are CPUs.

C:\Anaconda3\lib\site-packages\metaopt\concurrent\employer\process.py in ProcessWorkerEmployer()
     27     # These are a shared resource for all process provider instances.
     28     # So we keep them in a shared space, by implementing the borg pattern.
---> 29     _lock = Lock()
     30     _worker_processes = []
     31 

TypeError: __init__() missing 1 required keyword-only argument: 'ctx'
@Tamriel
Copy link

Tamriel commented Nov 25, 2015

This issue is solved when using Python 2.
I was able to solve it in Python 3 by adding ctx=None where it was needed, though I don't know if that is ok with the rest of the code.

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

No branches or pull requests

2 participants