Python commands vs source codes + stop at syntax error

Asked by Daniele

Dear all,

I have 2 questions.

The first is about the names of the parameters to be inserted in the python scripts and the corresponding names in the source cpp and h files.

It seems that the names can be different between these two.
For instance, the interaction
NRotElasticPrms
of the examples apparently refers to the file
Module/ElasticInteraction.cpp
1.1) Is this true ?

But in examples of the tutorial the name of the parameter is
 normalK
but this is cannot be found in the source file.
Instead it is called
kn
1.2) Is my deduction correct ?

This seems to be the case in other interaction potentials.
1.3) How can one know the correct names to be used in the python launch script for a given interaction just by looking at the source cpp and h files ?

Are the names written somewhere ?
The only way seems to run the job interactively (not in background) and to see the error given by the code

The second question is about the stopping of the code.
It seems that the code does not stop running is any mistake (i.e. spelling or not matching function) is found in the python script.
In this way if the code is sent in background one can never know if it is running or it is stalled.
2.1) Is there a way to know it or to impose a stop or kill if any problem is encountered ?

Thank you for the information you will give me

Bests,

Daniele Scopece

Question information

Language:
English Edit question
Status:
Answered
For:
ESyS-Particle Edit question
Assignee:
No assignee Edit question
Last query:
Last reply:
Revision history for this message
Dion Weatherley (d-weatherley) said :
#1

Hi Daniele,

Thanks for your questions.

You are correct that the names of the various interactions and parameters are different for the Python interface as compared with the C++ source files. This is because we have attempted to make the Python interface more user-friendly than the original C++ API. Unfortunately that does lead to some confusion when navigating the code.

To find out the mapping between the Python names and C++ names, you need to look at the .cpp files in Python/esys/lsm. For the various InteractionGroups, the place to look is:
Python/esys/lsm/InteractionParamsPy.cpp

This is where the (boost) Python wrappers for the various InteractionGroupPrms classes are defined.

Another important file for defining the wrapper around the LatticeMaster (LsmMpi in Python) is:
Python/esys/lsm/LsmMpiPy.cpp

Every sim.someFunction(..) call in Python is defined here with links back to the equivalent LatticeMaster subroutines.

> It seems that the code does not stop running is any mistake

This is indeed a rather annoying problem but very difficult to fix. It comes about because of a combination of Python and MPI. The master process simply runs the Python interpretter and parses the simulation script whilst all the worker processes await MPI instructions from the master process. If there is an error in the simulation script, the master process simply hangs and cannot send MPI instructions to the workers to, for example, terminate on such an error. To be more specific, the LatticeMaster gets destroyed when Python detects an error, so we have no way to communicate with the worker processes. As far as mpirun is concerned, all the MPI threads are still alive so it won't terminate either.

There may be ways to fix this problem. I will discuss it with the other developers.

I hope this helps and have fun!

Cheers,

Dion

Can you help with this problem?

Provide an answer of your own, or ask Daniele for more information if necessary.

To post a message you must log in.