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

Neuron doesn't return exit code to command line when there is an error #335

Closed
iomaganaris opened this issue Nov 26, 2019 · 4 comments · Fixed by #1633
Closed

Neuron doesn't return exit code to command line when there is an error #335

iomaganaris opened this issue Nov 26, 2019 · 4 comments · Fixed by #1633

Comments

@iomaganaris
Copy link
Member

During creating tests for NEURON I found out that when there is an error and NEURON quits from the HOC interpreter, it doesn't return an exit code (1) to the command-line shell.
This would be a useful addition, especially for extending the unit tests.
Example:

magkanar:~/bbp/nrn_bbp/build$ bin/nrniv /home/magkanar/bbp/nrn_bbp/test/hoc_tests/connect_dend/connect_dend.hoc
NEURON -- VERSION 7.8.0-162-g597ea9dc+ catch_test (597ea9dc+) 2019-11-25
Duke, Yale, and the BlueBrain Project -- Copyright 1984-2019
See http://neuron.yale.edu/neuron/credits

bin/nrniv: Couldn't find: nrngui.hoc
 in /home/magkanar/bbp/nrn_bbp/test/hoc_tests/connect_dend/connect_dend.hoc near line 1
 load_file("nrngui.hoc")
                        ^
        0 
        1 
        Vector[1] 
        Vector[0] 
bin/nrniv: run undefined function
 in /home/magkanar/bbp/nrn_bbp/test/hoc_tests/connect_dend/connect_dend.hoc near line 58
 run()
      ^
        run()
sh: 1: /home/magkanar/bbp/nrn_bbp/build/install/share/nrn/lib/cleanup: not found
magkanar:~/bbp/nrn_bbp/build$ echo $?
0

Another related useful addition for testing would be a function in HOC or/and python like quit() to return specific values, like: quit(0) to return 0 to the command-line shell and quit(1) to return 1.

@Helveg
Copy link
Contributor

Helveg commented Dec 3, 2019

I've also had to rely on parsing stderr and stdout to gain insight into the status of the process.

@iomaganaris Do you deploy NEURON on any Continuous Integration platforms? If so, which, and could you share your yaml configuration with me? I have trouble getting NEURON installed on Travis CI.

@iomaganaris
Copy link
Member Author

Hello @Helveg ,

There is currently an open PR regarding the addition of the cmake build system in Neuron to make the building of the simulator easier which includes a Travis CI plan for building Neuron with autotools as before and with the new cmake system. You can find the PR here and the included travis.yml file here.
Please feel free to check the Travis CI plan and also test the cmake build and let us know if you need any further help.

@WeinaJi
Copy link
Collaborator

WeinaJi commented Jan 21, 2022

I recalled an earlier investigation similar to this issue reported in JIRA : the exit code of execerror is not correct in the non-mpi case.

For example

 > echo "execerror(\"HOC error\")" > test.hoc
 > nrniv test.hoc
 > echo $?
 0
 > srun -n 2 nrniv -mpi test.hoc
 > echo $?
 137

@WeinaJi WeinaJi linked a pull request Feb 15, 2022 that will close this issue
alexsavulescu added a commit that referenced this issue Apr 6, 2022
* Return proper exit code in hoc execution
* Add unittest to check exit code of execerror

Co-authored-by: Alexandru Săvulescu <alexandru.savulescu@epfl.ch>
@WeinaJi
Copy link
Collaborator

WeinaJi commented Apr 6, 2022

The PR #1633 has been merged including two features:

  • return proper exit code in hoc execution
  • allow quit with user-defined code in hoc_quit(exit_code)

As proposed by @nrnhines , in the future we will extend the behavior to

$ nrniv -c '1/0'
NEURON -- VERSION 8.2.dev-12-gfa5ca235 weji/hoc_exitcode (fa5ca235) 2022-03-28
Duke, Yale, and the BlueBrain Project -- Copyright 1984-2021
See http://neuron.yale.edu/neuron/credits

nrniv: division by zero
 near line 1
 1/0
    ^
nrniv: arg not valid statement: 1/0
 near line 0
 ^
hines@hines-T7500:~/neuron/temp/build$ echo $?
0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants