Skip to content

nest-server: BadRequest: 400 Bad Request: name '<function name>' is not defined #2666

Open
@espenhgn

Description

@espenhgn

Describe the bug
The nest-server has issues with nest simulation scripts that rely on (nested?) function definitions, like the LambertWm1 function in the PyNest brunel_alpha_nest.py example.

To Reproduce
Steps to reproduce the behavior:

$ export NEST_SERVER_RESTRICTION_OFF=false  # doesn't matter if true/false
$ nest-server start -d
$ ipython
>>> from NESTServerClient import NESTServerClient
>>> nsc = NESTServerClient()
>>> response = nsc.from_file('brunel_alpha_nest.py')
...
nest.raster_plot.from_device(espikes, hist=True)
plt.show()

--------------------
---------------------------------------------------------------------------
BadRequest                                Traceback (most recent call last)
Cell In[5], line 4
      1 from NESTServerClient import NESTServerClient
      2 nsc = NESTServerClient()
----> 4 response = nsc.from_file('brunel_alpha_nest.py')

File ~/miniforge3/envs/hybridlfpy/lib/python3.10/site-packages/NESTServerClient/NESTServerClient.py:68, in NESTServerClient.from_file(self, filename, return_vars)
     66 print(script)
     67 print(20 * '-')
---> 68 return self.exec_script(script, return_vars)

File ~/miniforge3/envs/hybridlfpy/lib/python3.10/site-packages/NESTServerClient/NESTServerClient.py:57, in NESTServerClient.exec_script(self, source, return_vars)
     52 params = {
     53     'source': source,
     54     'return': return_vars,
     55 }
     56 response = requests.post(self.url + 'exec', json=params, headers=self.headers)
---> 57 return encode(response)

File ~/miniforge3/envs/hybridlfpy/lib/python3.10/site-packages/NESTServerClient/NESTServerClient.py:35, in encode(response)
     33     return response.json()
     34 elif response.status_code == 400:
---> 35     raise BadRequest(response.text)

BadRequest: 400 Bad Request: name 'LambertWm1' is not defined

Expected behavior
Should work I suppose

Desktop/Environment (please complete the following information):

  • OS: MacOS 13.3.1
  • Shell: zsh
  • Python-Version: 3.10.10
  • NEST-Version: 3.4
  • Installation: from source

Metadata

Metadata

Assignees

Labels

I: User InterfaceUsers may need to change their code due to changes in function callsS: HighShould be handled nextT: BugWrong statements in the code or documentationstaleAutomatic marker for inactivity, please have another look here

Type

No type

Projects

Status

To do

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions