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

Fix of issue 246 - Make help and helpdesk more robust #688

Merged
merged 24 commits into from Jun 9, 2017

Conversation

Projects
None yet
3 participants
@steffengraber
Contributor

steffengraber commented Mar 22, 2017

With this pull request, NEST uses only Python for the help system if you are on the Python level.
Therefore it doesn‘t matter if it is compiled with MPI or not.

In jupyter notebooks nest.help(obj) open a modal window with the help text.
With nest.help(obj, pager), you can open a texeditor like gedit from a notebook. If you use an terminaleditor (vi, nano, less, …) as pager, again the modal window open up.

If you use nest.helpdesk() in a notebook a new tab is created.

This pull request is a fix for issue #246.

Show outdated Hide outdated pynest/nest/lib/hl_api_helper.py
Show outdated Hide outdated pynest/nest/lib/hl_api_helper.py
Show outdated Hide outdated pynest/nest/lib/hl_api_helper.py
Show outdated Hide outdated pynest/nest/lib/hl_api_helper.py
Show outdated Hide outdated pynest/nest/lib/hl_api_helper.py
Show outdated Hide outdated pynest/nest/lib/hl_api_helper.py
Show outdated Hide outdated pynest/nest/lib/hl_api_helper.py
@heplesser

This comment has been minimized.

Show comment
Hide comment
@heplesser

heplesser Mar 23, 2017

Contributor

@steffengraber I am testing now and here are some experiences:

  • If NEST_INSTALL_DIR is not defined, nest.help() crashes. It would be better to provide the user with more guidance, something like:
if 'NEST_INSTALL_DIR' not in os.environ:
    print('NEST help needs to know where NEST is installed. Please source nest_vars.sh or defined NEST_INSTALL_DIR manually.')
    return
  • Instead of os.environ['NEST_INSTALL_DIR'] + "/share/doc/nest/help/" it is better to use os.path.join()
  • Is it best to use less as default parser, or would should we use the even more default more? no matter what we use as default, we should check that it exists and if not, either use cat or read the help file into Python and print() it.
  • We should avoid the low-level subprocess.Popen() and rather use the high-level functions. Since we need to maintain compatibility back to 2.7, we should use the Old-style high-level API.
  • I got this error: FileNotFoundError: [Errno 2] No such file or directory: 'less -S', which is probably because subprocess does not like options combined with the command name in one string (calling from plain python or ipython); the -S comes from .nestrc, if I remove it there, things work
  • nest.help('abs') works from notebook
  • `nest.helpdesk() does nothing when called from plain python or ipython or notebook
Contributor

heplesser commented Mar 23, 2017

@steffengraber I am testing now and here are some experiences:

  • If NEST_INSTALL_DIR is not defined, nest.help() crashes. It would be better to provide the user with more guidance, something like:
if 'NEST_INSTALL_DIR' not in os.environ:
    print('NEST help needs to know where NEST is installed. Please source nest_vars.sh or defined NEST_INSTALL_DIR manually.')
    return
  • Instead of os.environ['NEST_INSTALL_DIR'] + "/share/doc/nest/help/" it is better to use os.path.join()
  • Is it best to use less as default parser, or would should we use the even more default more? no matter what we use as default, we should check that it exists and if not, either use cat or read the help file into Python and print() it.
  • We should avoid the low-level subprocess.Popen() and rather use the high-level functions. Since we need to maintain compatibility back to 2.7, we should use the Old-style high-level API.
  • I got this error: FileNotFoundError: [Errno 2] No such file or directory: 'less -S', which is probably because subprocess does not like options combined with the command name in one string (calling from plain python or ipython); the -S comes from .nestrc, if I remove it there, things work
  • nest.help('abs') works from notebook
  • `nest.helpdesk() does nothing when called from plain python or ipython or notebook
@janhahne

Calling nest.helpdesk() works fine at my workstation. When I call nest.help('iaf_psc_alpha') or any NEST command I end up with the following error

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File ".../nest-fix246.install/lib64/python2.7/site-packages/nest/lib/hl_api_helper.py", line 234, in stack_checker_func
    return f(*args, **kwargs)
  File ".../nest-fix246.install/lib64/python2.7/site-packages/nest/lib/hl_api_info.py", line 90, in help
    pdoc(hlpobj, pager)
  File ".../nest-fix246.install/lib64/python2.7/site-packages/nest/lib/hl_api_helper.py", line 521, in pdoc
    proc = subprocess.Popen([pager, objf])
  File "/usr/lib64/python2.7/subprocess.py", line 709, in __init__
    errread, errwrite)
  File "/usr/lib64/python2.7/subprocess.py", line 1326, in _execute_child
    raise child_exception
OSError: [Errno 2] No such file or directory

Am I using it wrong, is this related to something already mentioned by @heplesser or another bug?

@steffengraber

This comment has been minimized.

Show comment
Hide comment
@steffengraber

steffengraber May 4, 2017

Contributor

@janhahne Sorry for the late response.
How do you compile nest? With MPI on or off?
Under which operating system?

Contributor

steffengraber commented May 4, 2017

@janhahne Sorry for the late response.
How do you compile nest? With MPI on or off?
Under which operating system?

@janhahne

This comment has been minimized.

Show comment
Hide comment
@janhahne

janhahne May 4, 2017

Contributor

@steffengraber I compiled nest with MPI on and my operating system is openSUSE 13.1. The problem still persist with your recent commits. Just to prevent any error on my side: nest.help('iaf_psc_alpha') should be a correct use of nest.help, right?

Contributor

janhahne commented May 4, 2017

@steffengraber I compiled nest with MPI on and my operating system is openSUSE 13.1. The problem still persist with your recent commits. Just to prevent any error on my side: nest.help('iaf_psc_alpha') should be a correct use of nest.help, right?

@steffengraber

This comment has been minimized.

Show comment
Hide comment
@steffengraber

steffengraber May 4, 2017

Contributor

@janhahne yes, nest.help('iaf_psc_alpha') is right.
Is python installed, and what version?

Contributor

steffengraber commented May 4, 2017

@janhahne yes, nest.help('iaf_psc_alpha') is right.
Is python installed, and what version?

@janhahne

This comment has been minimized.

Show comment
Hide comment
@janhahne

janhahne May 4, 2017

Contributor

@steffengraber I am using python 2.7.6 and usually pynest works fine for me

Contributor

janhahne commented May 4, 2017

@steffengraber I am using python 2.7.6 and usually pynest works fine for me

@steffengraber

This comment has been minimized.

Show comment
Hide comment
@steffengraber

steffengraber May 4, 2017

Contributor

@janhahne with Python older than 2.7.8 the help generation did not work correctly. Is it possible for you to update and test ist again?

Contributor

steffengraber commented May 4, 2017

@janhahne with Python older than 2.7.8 the help generation did not work correctly. Is it possible for you to update and test ist again?

@janhahne

This comment has been minimized.

Show comment
Hide comment
@janhahne

janhahne May 4, 2017

Contributor

@steffengraber I updated python to 2.7.13 and did a new clean build, but the error remains the same. I also noticed that if I enter any object that does not exist (as for example nest.help('testtest')) nothing happens, so there is no output and no exception.

Contributor

janhahne commented May 4, 2017

@steffengraber I updated python to 2.7.13 and did a new clean build, but the error remains the same. I also noticed that if I enter any object that does not exist (as for example nest.help('testtest')) nothing happens, so there is no output and no exception.

@steffengraber

This comment has been minimized.

Show comment
Hide comment
@steffengraber

steffengraber May 4, 2017

Contributor

@janhahne Could you please try nest.help('iaf_psc_alpha', 'less').

Contributor

steffengraber commented May 4, 2017

@janhahne Could you please try nest.help('iaf_psc_alpha', 'less').

@janhahne

This comment has been minimized.

Show comment
Hide comment
@janhahne

janhahne May 4, 2017

Contributor

@steffengraber nest.help('iaf_psc_alpha', 'less') works fine. The corresponding documentation is displayed and no error occurs.

Contributor

janhahne commented May 4, 2017

@steffengraber nest.help('iaf_psc_alpha', 'less') works fine. The corresponding documentation is displayed and no error occurs.

@heplesser

It works for me now---thanks! There are just a few little things to clean up, see detailed comments.

Show outdated Hide outdated pynest/nest/lib/hl_api_info.py
Show outdated Hide outdated pynest/nest/lib/hl_api_info.py
Show outdated Hide outdated pynest/nest/lib/hl_api_info.py
Show outdated Hide outdated pynest/nest/lib/hl_api_helper.py
Show outdated Hide outdated pynest/nest/lib/hl_api_info.py
@heplesser

This comment has been minimized.

Show comment
Hide comment
@heplesser

heplesser May 31, 2017

Contributor

@steffengraber PEP8 was still not entirely happy:

MSGBLD0195: [PEP8] pynest/nest/lib/hl_api_info.py:74:56: W291 trailing whitespace
MSGBLD0195: [PEP8] pynest/nest/lib/hl_api_info.py:80:59: W291 trailing whitespace

Otherwise, this looks fine to me.

@janhahne Do you also explicitly approve?

Contributor

heplesser commented May 31, 2017

@steffengraber PEP8 was still not entirely happy:

MSGBLD0195: [PEP8] pynest/nest/lib/hl_api_info.py:74:56: W291 trailing whitespace
MSGBLD0195: [PEP8] pynest/nest/lib/hl_api_info.py:80:59: W291 trailing whitespace

Otherwise, this looks fine to me.

@janhahne Do you also explicitly approve?

@steffengraber

This comment has been minimized.

Show comment
Hide comment
@steffengraber

steffengraber May 31, 2017

Contributor

@heplesser
@janhane found 2 more issues I have to address:

  • exception needed fo something like nest.help('testtest')
  • nest.help('iaf_psc_alpha', 'less') works perfect for @janhahne but not nest.help('iaf_psc_alpha').
Contributor

steffengraber commented May 31, 2017

@heplesser
@janhane found 2 more issues I have to address:

  • exception needed fo something like nest.help('testtest')
  • nest.help('iaf_psc_alpha', 'less') works perfect for @janhahne but not nest.help('iaf_psc_alpha').
@heplesser

I found a few more details ...

Show outdated Hide outdated pynest/nest/lib/hl_api_helper.py
Show outdated Hide outdated pynest/nest/lib/hl_api_helper.py
Show outdated Hide outdated pynest/nest/lib/hl_api_helper.py
Show outdated Hide outdated pynest/nest/lib/hl_api_helper.py
Show outdated Hide outdated pynest/nest/lib/hl_api_info.py
@janhahne

@steffengraber Thank you for addressing my issues! Now everything works as it should for me 👍

@steffengraber

This comment has been minimized.

Show comment
Hide comment
@steffengraber

steffengraber Jun 8, 2017

Contributor

@heplesser I added some documentation and PEP8 is happy now.

Contributor

steffengraber commented Jun 8, 2017

@heplesser I added some documentation and PEP8 is happy now.

@heplesser

This comment has been minimized.

Show comment
Hide comment
@heplesser

heplesser Jun 9, 2017

Contributor

Release notes: Improved help in PyNEST

  • Help will work even if compiled with MPI
  • Help will work in Jupyter Notebooks
Contributor

heplesser commented Jun 9, 2017

Release notes: Improved help in PyNEST

  • Help will work even if compiled with MPI
  • Help will work in Jupyter Notebooks
@heplesser

@steffengraber Thanks for the fixes, just two little details about path construction left to make it entirely pythonic and even windows-safe.

Show outdated Hide outdated pynest/nest/lib/hl_api_info.py
Show outdated Hide outdated pynest/nest/lib/hl_api_helper.py

@heplesser heplesser merged commit d728947 into nest:master Jun 9, 2017

1 check passed

continuous-integration/travis-ci/pr The Travis CI build passed
Details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment