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

Robot-Marbles-Part-6.ipynb gives an unexpected error when run on windows. #93

Closed
ResourceHog opened this issue Apr 10, 2020 · 10 comments
Closed
Assignees

Comments

@ResourceHog
Copy link

ResourceHog commented Apr 10, 2020

To recreate the bug:

  1. Pull code from default branch.
  2. Run all steps in the robot-marbles-part-6 notebook.

Fails on step 17 with
NameError: name 'rand' is not defined

Expected:
results of both configurations should be appended to the "results" variable.

@mzargham
Copy link
Contributor

Looks like we're sorting through a dependencies issue. Can you run pip freeze in the command line and share the output. I suspect something we take for granted is missing. If so the fix will be an dependencies update.

@ResourceHog
Copy link
Author

alabaster==0.7.12
anaconda-client==1.7.2
anaconda-navigator==1.9.12
anaconda-project==0.8.3
argh==0.26.2
asn1crypto==1.3.0
astroid==2.3.3
astropy==4.0
atomicwrites==1.3.0
attrs==19.3.0
autopep8==1.4.4
Babel==2.8.0
backcall==0.1.0
backports.functools-lru-cache==1.6.1
backports.shutil-get-terminal-size==1.0.0
backports.tempfile==1.0
backports.weakref==1.0.post1
bcrypt==3.1.7
beautifulsoup4==4.8.2
bitarray==1.2.1
bkcharts==0.2
bleach==3.1.0
bokeh==1.4.0
boto==2.49.0
Bottleneck==1.3.2
cadCAD==0.3.1
certifi==2019.11.28
cffi==1.14.0
chardet==3.0.4
Click==7.0
cloudpickle==1.3.0
clyent==1.2.2
colorama==0.4.3
comtypes==1.1.7
conda==4.8.2
conda-build==3.18.11
conda-package-handling==1.6.0
conda-verify==3.4.2
contextlib2==0.6.0.post1
cryptography==2.8
cycler==0.10.0
Cython==0.29.15
cytoolz==0.10.1
dask==2.11.0
decorator==4.4.1
defusedxml==0.6.0
diff-match-patch==20181111
dill==0.3.1.1
distributed==2.11.0
docutils==0.16
entrypoints==0.3
et-xmlfile==1.0.1
fastcache==1.1.0
filelock==3.0.12
flake8==3.7.9
Flask==1.1.1
fn==0.4.3
fsspec==0.6.2
funcy==1.14
future==0.18.2
gevent==1.4.0
glob2==0.7
greenlet==0.4.15
h5py==2.10.0
HeapDict==1.0.1
html5lib==1.0.1
hypothesis==5.5.4
idna==2.8
imageio==2.6.1
imagesize==1.2.0
importlib-metadata==1.5.0
intervaltree==3.0.2
ipykernel==5.1.4
ipython==7.12.0
ipython-genutils==0.2.0
ipywidgets==7.5.1
isort==4.3.21
itsdangerous==1.1.0
jdcal==1.4.1
jedi==0.14.1
Jinja2==2.11.1
joblib==0.14.1
json5==0.9.1
jsonschema==3.2.0
jupyter==1.0.0
jupyter-client==5.3.4
jupyter-console==6.1.0
jupyter-core==4.6.1
jupyterlab==1.2.6
jupyterlab-server==1.0.6
keyring==21.1.0
kiwisolver==1.1.0
lazy-object-proxy==1.4.3
libarchive-c==2.8
llvmlite==0.31.0
locket==0.2.0
lxml==4.5.0
MarkupSafe==1.1.1
matplotlib==3.1.3
mccabe==0.6.1
menuinst==1.4.16
mistune==0.8.4
mkl-fft==1.0.15
mkl-random==1.1.0
mkl-service==2.3.0
mock==4.0.1
more-itertools==8.2.0
mpmath==1.1.0
msgpack==0.6.1
multipledispatch==0.6.0
multiprocess==0.70.9
navigator-updater==0.2.1
nbconvert==5.6.1
nbformat==5.0.4
networkx==2.4
nltk==3.4.5
nose==1.3.7
notebook==6.0.3
numba==0.48.0
numexpr==2.7.1
numpy==1.18.1
numpydoc==0.9.2
olefile==0.46
openpyxl==3.0.3
packaging==20.1
pandas==1.0.1
pandocfilters==1.4.2
paramiko==2.7.1
parso==0.5.2
partd==1.1.0
path==13.1.0
pathlib2==2.3.5
pathos==0.2.5
pathtools==0.1.2
patsy==0.5.1
pep8==1.7.1
pexpect==4.8.0
pickleshare==0.7.5
Pillow==7.0.0
pkginfo==1.5.0.1
pluggy==0.13.1
ply==3.11
pox==0.2.7
ppft==1.6.6.1
prometheus-client==0.7.1
prompt-toolkit==3.0.3
psutil==5.6.7
py==1.8.1
pycodestyle==2.5.0
pycosat==0.6.3
pycparser==2.19
pycrypto==2.6.1
pycurl==7.43.0.5
pydocstyle==4.0.1
pyflakes==2.1.1
Pygments==2.5.2
pylint==2.4.4
PyNaCl==1.3.0
pyodbc===4.0.0-unsupported
pyOpenSSL==19.1.0
pyparsing==2.4.6
pyreadline==2.1
pyrsistent==0.15.7
PySocks==1.7.1
pytest==5.3.5
pytest-arraydiff==0.3
pytest-astropy==0.8.0
pytest-astropy-header==0.1.2
pytest-doctestplus==0.5.0
pytest-openfiles==0.4.0
pytest-remotedata==0.3.2
python-dateutil==2.8.1
python-jsonrpc-server==0.3.4
python-language-server==0.31.7
pytz==2019.3
PyWavelets==1.1.1
pywin32==227
pywin32-ctypes==0.2.0
pywinpty==0.5.7
PyYAML==5.3
pyzmq==18.1.1
QDarkStyle==2.8
QtAwesome==0.6.1
qtconsole==4.6.0
QtPy==1.9.0
requests==2.22.0
rope==0.16.0
Rtree==0.9.3
ruamel-yaml==0.15.87
scikit-image==0.16.2
scikit-learn==0.22.1
scipy==1.4.1
seaborn==0.10.0
Send2Trash==1.5.0
simplegeneric==0.8.1
singledispatch==3.4.0.3
six==1.14.0
snowballstemmer==2.0.0
sortedcollections==1.1.2
sortedcontainers==2.1.0
soupsieve==1.9.5
Sphinx==2.4.0
sphinxcontrib-applehelp==1.0.1
sphinxcontrib-devhelp==1.0.1
sphinxcontrib-htmlhelp==1.0.2
sphinxcontrib-jsmath==1.0.1
sphinxcontrib-qthelp==1.0.2
sphinxcontrib-serializinghtml==1.1.3
sphinxcontrib-websupport==1.2.0
spyder==4.0.1
spyder-kernels==1.8.1
SQLAlchemy==1.3.13
statsmodels==0.11.0
sympy==1.5.1
tables==3.6.1
tabulate==0.8.7
tblib==1.6.0
terminado==0.8.3
testpath==0.4.4
toolz==0.10.0
tornado==6.0.3
tqdm==4.42.1
traitlets==4.3.3
typed-ast==1.4.1
ujson==1.35
unicodecsv==0.14.1
urllib3==1.25.8
watchdog==0.10.2
wcwidth==0.1.8
webencodings==0.5.1
Werkzeug==1.0.0
widgetsnbextension==3.5.1
win-inet-pton==1.1.0
win-unicode-console==0.5
wincertstore==0.2
wrapt==1.11.2
xlrd==1.2.0
XlsxWriter==1.2.7
xlwings==0.17.1
xlwt==1.3.0
xmltodict==0.12.0
yapf==0.28.0
zict==1.0.0
zipp==2.2.0

A dependency issue can't be the case because rand is imported in the first cell of this notebook and I can use it just fine outside of the execute function.

removing rand as a dependency of the robot_arm_1 and robot_arm_2 policy functions just gives the same error except with "robotic_arm" instead of "rand" even though the function doesn't use any libraries whatsoever.

@mzargham
Copy link
Contributor

Good to know. I haven't been able to reproduce the error yet though. Will check with others and keep you posted.

@markusbkoch
Copy link
Contributor

I can't reproduce the error either. @ResourceHog if you could please fork the repo and push your notebook to your fork, seeing the error in context would help a lot. Otherwise, copy pasting the entire output and/or a screenshot here would also help. Thanks!

@ResourceHog
Copy link
Author

After some research, it seems like Pool from multithreading doesn't work on windows. Are you guys per chance running linux?

@ResourceHog
Copy link
Author

ResourceHog commented Apr 11, 2020

I've forked it as requested but I didn't have any changes to upload.
Here are some screenshots:

image

image

image

@markusbkoch
Copy link
Contributor

markusbkoch commented Apr 11, 2020 via email

@ResourceHog
Copy link
Author

ResourceHog commented Apr 12, 2020

Seems like this issue is related.
uqfoundation/multiprocess#6
The workaround right now is to

  1. Put any policy or update functions in a separate file.
  2. place any imports inside the function like:
def robot_arm_3(params, step, sL, s):
    from numpy.random import rand
    _robotId = 1
    if rand()<robots_probabilities[_robotId-1]: # draw a random number between 0 and 1; if it's smaller than the robot's parameter, it acts
        return robot_arm(params, step, sL, s)
    else:
        return({'add_to_A': 0, 'add_to_B': 0})
  1. import the file into the notebook and use those functions in the configuration.

@ResourceHog ResourceHog changed the title Robot-Marbles-Part-6.ipynb gives an unexpected error when run. Robot-Marbles-Part-6.ipynb gives an unexpected error when run on windows. Apr 12, 2020
@markusbkoch
Copy link
Contributor

Thanks, @ResourceHog . I guess that makes sense. For a while now in our internal projects we've been separating the model definition from the analysis notebook for better version control (same project structure used in the prey-predator example), so that's another reason why we didn't catch this.

We need to think about how to handle the tutorials given this. IMO, the ideal experience for a newcomer would not require parsing multiple files, as I believe introducing concepts and corresponding code snippets throughout the notebook makes the tutorial more readable and accessible. I'll think about it and I'm happy to hear different points of view and suggestions others might have.

fjribi added a commit to fjribi/cadCAD that referenced this issue Jun 19, 2020
Concerning errors like ("NameError: name 'np' is not defined") when using multiprocess exec mode on windows: Linked to cadCAD-org#104 & cadCAD-org#93
@JEJodesty
Copy link
Member

JEJodesty commented Jun 23, 2020

@ResourceHog
#104 pertains to your issue and the solution is merged
Thanks for brining it to our attention

@JEJodesty JEJodesty self-assigned this Jun 23, 2020
JEJodesty pushed a commit that referenced this issue Nov 19, 2020
Concerning errors like ("NameError: name 'np' is not defined") when using multiprocess exec mode on windows: Linked to #104 & #93
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

4 participants