OpenMDAO SimpleGADriver Run Parallel - parallel-processing

Have some of you succeeded to run the OpenMDAO SimpleGADriver with the run parallel mod enabled?
When I am trying to run their example from the official website (https://openmdao.org/newdocs/versions/latest/features/building_blocks/drivers/genetic_algorithm.html#running-a-ga-in-parallel), it fails every time and returns me this error:
Traceback (most recent call last):
File "C:\Program Files\Python39\lib\code.py", line 90, in runcode
exec(code, self.locals)
File "<input>", line 24, in <module>
File "C:\Users\z004cn5y\.virtualenvs\python-flask-server-generated\lib\site-packages\openmdao\utils\hooks.py", line 130, in execute_hooks
ret = f(*args, **kwargs)
File "C:\Users\z004cn5y\.virtualenvs\python-flask-server-generated\lib\site-packages\openmdao\core\problem.py", line 856, in run_driver
return self.driver.run()
File "C:\Users\z004cn5y\.virtualenvs\python-flask-server-generated\lib\site-packages\openmdao\drivers\genetic_algorithm_driver.py", line 385, in run
desvar_new, obj, self._nfit = ga.execute_ga(x0, lower_bound, upper_bound, outer_bound,
File "C:\Users\z004cn5y\.virtualenvs\python-flask-server-generated\lib\site-packages\openmdao\drivers\genetic_algorithm_driver.py", line 716, in execute_ga
x_pop = comm.bcast(x_pop, root=0)
AttributeError: 'FakeComm' object has no attribute 'bcast'
Has someone ever faced and solved this issue ?
Many thanks in advance

It looks like instead of the script using a proper MPI installation, it's using the FakeComm, which is a dummy class used if mpi4py is not installed. You should be able to pip install mpi4py and then run that example in parallel.

Related

YFinance JSONDecodeError--latest version

When I tried to dowload historic data, I get the following error message:
Exception in thread Thread-6:
Traceback (most recent call last):
File "E:\Anaconda\envs\finrl\lib\threading.py", line 932, in _bootstrap_inner
self.run()
File "E:\Anaconda\envs\finrl\lib\threading.py", line 870, in run
self._target(*self._args, **self._kwargs)
File "E:\Anaconda\envs\finrl\lib\site-packages\multitasking\__init__.py", line 104, in _run_via_pool
return callee(*args, **kwargs)
File "E:\Anaconda\envs\finrl\lib\site-packages\yfinance\multi.py", line 169, in _download_one_threaded
data = _download_one(ticker, start, end, auto_adjust, back_adjust,
File "E:\Anaconda\envs\finrl\lib\site-packages\yfinance\multi.py", line 181, in _download_one
return Ticker(ticker).history(period=period, interval=interval,
File "E:\Anaconda\envs\finrl\lib\site-packages\yfinance\base.py", line 162, in history
data = data.json()
File "E:\Anaconda\envs\finrl\lib\site-packages\requests\models.py", line 910, in json
return complexjson.loads(self.text, **kwargs)
File "E:\Anaconda\envs\finrl\lib\json\__init__.py", line 357, in loads
return _default_decoder.decode(s)
File "E:\Anaconda\envs\finrl\lib\json\decoder.py", line 337, in decode
obj, end = self.raw_decode(s, idx=_w(s, 0).end())
File "E:\Anaconda\envs\finrl\lib\json\decoder.py", line 355, in raw_decode
raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)
here is my code:
import yfinance as yf
data = yf.download("SPY AAPL", start="2017-01-01", end="2017-04-30")
I have tried many methods:
install the latest version of yfinance
install the old version of yfinance
revise the code
In fact, when I use yahoo_fin, the same error occurs too.
Wish someone to help me solve this problem
your code is correct.
This is happening because Anaconda is used to simulate an environment so packets have determined versions so that everything is compatible. The thing that happens in your case is that yfinance is older and your version of JSON is not compatible with some functions of yfinance since yfinance is no anymore updated.
I recommend you to just install on your computer with pip the packet yfinance as follows instead of using the environment of anaconda:
pip install yfinance
and then it should try to get the correct versions of the libraries that it needs. After that, you can create a python file and then import the packet
import yfinance as yf
and then execute your download code
data = yf.download("SPY AAPL", start="2017-01-01", end="2017-04-30")
As a recommendation, try to pass different values as a list instead of a string, because it will be hard to debug later. Instead of "SPY AAPL" -> ['SPY', 'AAPL']
Edit: Also it can be that your finance version is YEARS old (but I don't think so), is this is the case then you should try to update inside of the anaconda updater. Otherwise, with the terminal, it would be something like:
pip install yfinance --upgrade

Pyusb and Libusb giving NoBackendError on MacOS

I'm on MacOS Big Sur trying to run rfcat. I am running anaconda as well and I have set up an environment with Python2.7 when I originally got errors with Python3.x. I have downloaded the pyusb, pyreadline, ipython, PySide2, and the libusb dependancies. Libusb seems to be giving me the most trouble. I keep getting the following error:
Error in resetup():NoBackendError('No backend available',)
Error in resetup():NoBackendError('No backend available',)
Error in resetup():NoBackendError('No backend available',)
^CTraceback (most recent call last):
File "/opt/anaconda3/envs/rftools/bin/rfcat", line 4, in <module>
__import__('pkg_resources').run_script('rfcat==1.9.5', 'rfcat')
File "/opt/anaconda3/envs/rftools/lib/python2.7/site-packages/pkg_resources/__init__.py", line 666, in run_script
self.require(requires)[0].run_script(script_name, ns)
File "/opt/anaconda3/envs/rftools/lib/python2.7/site-packages/pkg_resources/__init__.py", line 1469, in run_script
exec(script_code, namespace, namespace)
File "/opt/anaconda3/envs/rftools/lib/python2.7/site-packages/rfcat-1.9.5-py2.7.egg/EGG-INFO/scripts/rfcat", line 63, in <module>
File "build/bdist.macosx-10.7-x86_64/egg/rflib/__init__.py", line 208, in interactive
File "build/bdist.macosx-10.7-x86_64/egg/rflib/chipcon_nic.py", line 103, in __init__
File "build/bdist.macosx-10.7-x86_64/egg/rflib/chipcon_usb.py", line 93, in __init__
File "build/bdist.macosx-10.7-x86_64/egg/rflib/chipcon_usb.py", line 238, in resetup
KeyboardInterrupt
From my research so far, backend is how pyusb refers to libusb, libusb1 or openusb. It is unable to find the libusb within the environment. I did a little tracking and found that ultimately, the find_library() function is found in ctypes in util.py. It refers to the executable path for MacOS with #executable_path/../lib/libusb%s..... I tried to put libusb into a folder on my executable path to hopefully match this functions search, and still got the same errors. I then found instructions on inputting a custom path for the backend for pyusb here. This appears to be a method where you input the device and backend information at the beginning of your program. The code I inserted is as follows:
import usb.core
import usb.backend.libusb1 as libusb1
backend = libusb1.get_backend(find_library=lambda x: "/path/to/file/lib/libusb-1.0.0.dylib")
dev = usb.core.find(idVendor=“MyVID”, idProduct=“MyPID”, backend=backend)
This induced a similar error but with a different traceback when I placed the code in rflib.init and the rfcat codes:
Traceback (most recent call last):
File "/opt/anaconda3/envs/rftools/bin/rfcat", line 4, in <module>
__import__('pkg_resources').run_script('rfcat==1.9.5', 'rfcat')
File "/opt/anaconda3/envs/rftools/lib/python2.7/site-packages/pkg_resources/__init__.py", line 666, in run_script
self.require(requires)[0].run_script(script_name, ns)
File "/opt/anaconda3/envs/rftools/lib/python2.7/site-packages/pkg_resources/__init__.py", line 1469, in run_script
exec(script_code, namespace, namespace)
File "/opt/anaconda3/envs/rftools/lib/python2.7/site-packages/rfcat-1.9.5-py2.7.egg/EGG-INFO/scripts/rfcat", line 12, in <module>
File "build/bdist.macosx-10.7-x86_64/egg/rflib/__init__.py", line 15, in <module>
File "/opt/anaconda3/envs/rftools/lib/python2.7/site-packages/usb/core.py", line 1304, in find
raise NoBackendError('No backend available')
usb.core.NoBackendError: No backend available
I have since reset things back to how I started and am still getting the original error listed above.
I think this largely has to do with the anaconda environment, which I can of course remove. I want to try to find a way to make this work though. Is there a better method to help rfcat find the libusb as required? Another possible solution is resolving the actual executable_path. Does anyone know how to find the executable_path?
In case it helps, I will list the default locations for commands and files.
rfcat: /opt/anaconda3/envs/rftools/lib/python2.7/site-packages/rfcat
pyusb: /opt/anaconda3/envs/rftools/lib/python2.7/site-packages/usb
ctypes: /opt/anaconda3/envs/rftools/lib/python2.7/ctypes
libusb: /opt/anaconda3/envs/rftools/lib/python2.7/site-packages/usb/lib

SerpentAI Installation error

I have been trying to install SerpentAI. I am on a Mac, and I have followed all the steps. I have all the dependencies, but when I use the keyword serpent it gives me this error.
I know I am missing a config file but I don't know where to find it, or how to solve this.
Any command that started with serpent gave me this error.
Here is the error
Traceback (most recent call last):
File "/anaconda3/bin/serpent", line 11, in <module>
load_entry_point('SerpentAI==2018.1.2', 'console_scripts', 'serpent')()
File "/anaconda3/lib/python3.6/site- packages/pkg_resources/__init__.py", line 480, in load_entry_point
return get_distribution(dist).load_entry_point(group, name)
File "/anaconda3/lib/python3.6/site-packages/pkg_resources/__init__.py", line 2691, in load_entry_point
return ep.load()
File "/anaconda3/lib/python3.6/site-packages/pkg_resources/__init__.py", line 2322, in load
return self.resolve()
File "/anaconda3/lib/python3.6/site-packages/pkg_resources/__init__.py", line 2328, in resolve
module = __import__(self.module_name, fromlist=['__name__'], level=0)
File "/anaconda3/lib/python3.6/site-packages/SerpentAI-2018.1.2-py3.6.egg/serpent/serpent.py", line 11, in <module>
from serpent.utilities import clear_terminal, display_serpent_logo, is_linux, is_macos, is_windows, is_unix, wait_for_crossbar
File "/anaconda3/lib/python3.6/site-packages/SerpentAI-2018.1.2-py3.6.egg/serpent/utilities.py", line 8, in <module>
from serpent.config import config
File "/anaconda3/lib/python3.6/site-packages/SerpentAI-2018.1.2-py3.6.egg/serpent/config.py", line 18, in <module>
raise Exception("Configuration file not found at: 'config/config.yml'...")
Exception: Configuration file not found at: 'config/config.yml'...
So I think I found the problem, you can clone the GitHub repo, and it will have the config files. Then when you run pip install it will clone a version, and that version won't have the config files.
I had the same issue when trying to run serpent vi sual_debugger after following all installation guide steps.
Try to run serpent setup, it might solve the problem you have. It helped in my case.

Spacy and sputnik issue on Python3

I am currently using space(0.101.0), tensorflox (1.0.0) and sputnik (0.9.3). I do have this issue happening :
super(Pool, self).__init__(app_name, app_version, path, **kwargs)
File "/Users/sebastien/xxx/venv/lib/python3.6/site-packages/sputnik/package_list.py", line 33, in __init__
self.load()
File "/Users/sebastien/xxx/venv/lib/python3.6/site-packages/sputnik/package_list.py", line 51, in load
for package in self.packages():
File "/Users/sebastien/xxx/venv/lib/python3.6/site-packages/sputnik/package_list.py", line 47, in packages
yield self.__class__.package_class(path=os.path.join(self.path, path))
File "/Users/sebastien/xxx/venv/lib/python3.6/site-packages/sputnik/package.py", line 15, in __init__
super(Package, self).__init__(defaults=meta['package'])
KeyError: 'package'
I have tried to combine different version but my make stuff is no more working. I have issues to build the overall system.
Based on what I gave as version used, This issue also happened when I am running the "python3 -m spacy.en.download"
Any idea?

Unable to run Windmill, multiple errors

I have been having all kinds of problems getting Windmill setup and installed. I thought I finally got it setup, but now when I try to just run windmill, I get the following errors. Any help is appreciated.
c:\Python33\Scripts>windmill firefox http://www.google.com Traceback
(most recent call last): File
"c:\Python33\Scripts\windmill-script.py", line 9, in
load_entry_point('windmill==1.6', 'console_scripts', 'windmill')() File
"C:\Python33\lib\site-packages\distribute-0.6.49-py3.3.egg\pkg_resources.
py", line 345, in load_entry_point
return get_distribution(dist).load_entry_point(group, name) File "C:\Python33\lib\site-packages\distribute-0.6.49-py3.3.egg\pkg_resources.
py", line 2382, in load_entry_point
return ep.load() File "C:\Python33\lib\site-packages\distribute-0.6.49-py3.3.egg\pkg_resources.
py", line 2088, in load
entry = import(self.module_name, globals(),globals(), ['name']) File
"C:\Python33\lib\site-packages\windmill-1.6-py3.3.egg\windmill__init__.p
y", line 17, in
import bin, browser, server, conf, tools, sys ImportError: No module named 'bin'
I had the same issue; Windmill doesn't work with Python 3.x. To fix the problem install Python 2.x

Resources