Groups keyboard shortcuts have been updated
Dismiss
See shortcuts

failing to continue next iteration with voronoi bins

54 views
Skip to first unread message

Chloe Sheen

unread,
May 3, 2024, 8:24:52 PM5/3/24
to westpa-users
Hello WESTPA users,

I'm trying to use the VoronoiBinMapper along with the string method (westext.stringmethod.string_driver), and I have been unable to get past an error message. Following this wiki,  I have a 3-dimensional progress coordinate that gets passed into a distance function (dfunc), which outputs an array of distances from each of the bin centers to the pcoord. Then, the VoronoiBinMapper's assign method assigns the pcoord to the closest bin based on distance.

Currently, w_init runs successfully and the first iteration completes, but the run fails after the first iteration. 

Here's the specific error message that shows up in my west.log file:
exception caught; shutting down
-- ERROR    [w_run] -- Traceback (most recent call last):
  File "/home/csheen/anaconda3/envs/westpa-2020.05/westpa-2020.05/lib/cmds/w_run.py", line 49, in <module>
    sim_manager.run()
  File "/home/csheen/anaconda3/envs/westpa-2020.05/westpa-2020.05/src/west/sim_manager.py", line 640, in run
    self.prepare_new_iteration()
  File "/home/csheen/anaconda3/envs/westpa-2020.05/westpa-2020.05/src/west/sim_manager.py", line 586, in prepare_new_iteration
    self.invoke_callbacks(self.prepare_new_iteration)
  File "/home/csheen/anaconda3/envs/westpa-2020.05/westpa-2020.05/src/west/sim_manager.py", line 114, in invoke_callbacks
    sorted_callbacks = sorted(callbacks)
TypeError: '<' not supported between instances of 'method' and 'method'

When I look at the seg_logs and traj_segs directories, I don't see any glaring errors. I seem to be having issues propagating the second iteration, but I'm not quite sure what else could be going wrong just based on this error. I think the bin mapping that's specified in my system.py works correctly. Here's the sanity check I did for that:

coords = numpy.array([[0,0,0], [0.1,0.1,0.2], [0.9,0.9,1.0]], dtype=pcoord_dtype)
output = self.bin_mapper.assign(coords)

>> This outputs [0,3,19], which are my expected answers. 

I've attached my system.py and west.cfg files.

Thank you,
Chloe
system.py
west.cfg

Joshua

unread,
May 4, 2024, 9:37:26 AM5/4/24
to westpa-users
Hi Chloe,

I took a brief look at this and it’s a little strange. I believe you've stumbled across a bug in WESTPA (I'll submit a Github issue for this), although it's still unclear to me what you're doing that's triggering it. First I'll describe the bug and then at the end give you a suggestion to give us more info to help further debug this.

 The failing line is:
File "/home/csheen/anaconda3/envs/westpa-2020.05/westpa-2020.05/src/west/sim_manager.py", line 114, in invoke_callbacks
    sorted_callbacks = sorted(callbacks)
TypeError: '<' not supported between instances of 'method' and 'method'

`callbacks` should be a set of tuple of `(priority, function.__name__, function)`. Priority should b an int, `function.__name__` should be a string, and `function` is a method. This should work as long as the pair of `priority` and `function.__name__` are unique. The problem is is that you should never compare functions in the call to `sorted`, because this throws the above error. For example:

```
import math

x = set([(0, 'foo', math.cos), (0, 'foo', math.sin)])
y = sorted(x)
```

errors with:
TypeError: '<' not supported between instances of 'builtin_function_or_method' and ‘builtin_function_or_method'

So what looks to be happening is that there are callbacks being registered that have the same priority and name. The code here can error whenever this happens, which isn’t good. It should probably be fixed to at least warn users that callbacks have been registered with duplicate (priority, name). You could also change the `sorted(callbacks)` to `sorted(callbacks, key=operator.itemgetter(0, 1))` to only sort on the priority and name. 

What I would do here is throw in a print statement in the `sim_manger.py` `invoke_callback` method and print what is in `callbacks` before it tries to sort them (so between lines 137 and 138). Then we can see what is registered at that callback and that will give some hints as to what might be going on. I don’t see anything that looks immediately wrong in the west.cfg

Josh

Chloe Sheen

unread,
May 6, 2024, 12:18:33 AM5/6/24
to westpa-users

Hi Josh,

When I tried printing out what's going on in the invoke_callback method, this is what I got:

{(0, 'prepare_new_iteration', <bound method WEEDDriver.prepare_new_iteration of <westext.weed.weed_driver.WEEDDriver object at 0x1554dfa41ca0>>), (0, 'prepare_new_iteration', <bound method StringDriver.prepare_new_iteration of <westext.stringmethod.string_driver.StringDriver object at 0x155412a798b0>>)}

So it makes sense why the error was being thrown. I was able to get around the issue once I made the change to sort on the priority and name only. 

Thank you so much for the help! 

-Chloe

Chloe Sheen

unread,
May 7, 2024, 9:29:51 PM5/7/24
to westpa-users
Hi again,

I'm having a bit of trouble getting the analysis tools to work. I'm mainly interested in figuring out how my string/bin centers change at each update, and later generate some figures of the changing Voronoi bins. 
I followed this section for analyzing data, and just cloned the /analysis, /bin, and /configs directories from this example directory to try it out, but I'm just running into a bunch of Modulenotfound errors. Perhaps I'm not running these analysis scripts correctly, but bin/run_we_analysis.py can't find module 'westpa'. I've tried changing all instances of 'import westpa' to 'import west' instead since I'm on westpa-2020.05, but I'm still getting ModuleNotFoundError: No module named 'west'

I'm confused because this doesn't seem to be the case when I look for the module.  

    (westpa-2020.05) [abc@def ]$ which west

    ~/anaconda3/envs/westpa-2020.05/westpa-2020.05/bin/west

    (westpa-2020.05) [abc@def ]$ which python

    ~/anaconda3/envs/westpa-2020.05/bin/python 

Is there a simpler way for me to just print out a log of bin centers every time the string evolves? Is this information stored in the h5 file already?

Thank you,
Chloe

Jeremy Leung

unread,
May 8, 2024, 11:17:16 AM5/8/24
to westpa-users
Hi Chloe,

Unfortunately the WESTPA 1.0 (v2020.XX) installation is structured a little differently and it's often not easy import things like in WESTPA 2.0 (v2022.XX).

I haven't personally used the string method plugin before, but I suggest the following:
1) Work with the "master" branch of the stringmethodexamples, which is written for WESTPA 1.0 and calls `os.system` to analyze the file. To get the bin centers, you'll need to load in the pickled bin_mapper and grab "bin_mapper.centers" attribute. 
2) Use what's linked in $WEST_PYTHON, which might be different from the environment python. From Josh's code, I'm seeing that he's using `$WEST_ROOT/bin/west` as the python.

Hope this helps!

Best,

Jeremy L.
Reply all
Reply to author
Forward
0 new messages