Discussion:
[PyMOL] Faster installation of plugins during development
Matthew Baumgartner
2014-07-18 15:41:45 UTC
Permalink
Hi,
So i am working on a pymol plugin (shameless plug
<https://sourceforge.net/projects/clustermolspy/>) and I have been
annoyed how difficult it is to reinstall my plugin so I can see the
effect of the changes I have made.

Currently, the process is:
Plugin Menu > Plugin Manager > Install New Plugin tab > Choose File... >
Navigate to script file (could be 5-8 clicks plus some scrolling) >
Select plugin directory > Ok > Hit Ok to confirm reinstall > Hit OK to
acknowledge the reinstall > Close the Plugin Manager > Go to the Plugin
Menu > Open my Plugin at the bottom.

It's a super long process that really hampers rapid development, which
is super annoying when trying to tweak GUI elements.

So to my question, is there a faster method for getting the plugin to
use the new code? I am open to basically any solution.
In my frustration, I've looked into reverse engineering the Plugin
Manager and making my own little script. But I figured I should ask here
before doing this.

Thanks,
Matt


I'm using Pymol 1.7.1.7 and Ubuntu 13.10.





--
Andreas Warnecke
2014-07-18 17:23:48 UTC
Permalink
Hej Matthew,

1. The advantage of using the plugin manager is that it will automatically
import all the plugin in the 'plugins' folder of the 'pymol-script-repo'.
This should re-load you plugin if it is located in a folder managed by the
plugin manager. The loading of plugins located therein occurs
automatically.
You can add paths to the plugin manager either manually or using scripts
during startup as described in the link. This is the way I prefer to do it.
Check the examples and linked pages:
http://www.pymolwiki.org/index.php/Plugin_manager

Note that deliberate import of these plugins changes:
e.g. to import colorama.py post startup use:
import pmg_tk.startup.colorama
# this is shown in the info dialog of the Plugin manager

A simple restart of PyMOL should re-load your updated plugin with the
changes made, provided the path is added to its list. It may require a
__init__.py file if it is a module.

2. if you are testing a plugin you can always have it in a separate folder
that you add yourself.
I sometime use the following to test scripts (added in the
run_on_startup.py):
#########################
import sys
import os
sys.path.append(os.path.abspath(os.path.join(os.environ['PYMOL_PATH'],
'plugins_private'))) # contains a folder called private with a (empty)
__init__.py file
import private
#########################

3. Another (maybe deprecated?) way of running your code would be to use
'execfile'. This would correspond to running the python code in PyMOL.

#########################
import os
PYMOLPATH=os.environ['PYMOL_PATH']
#Append 'plugin' folder # Change to 'Pymol-script-repo' if required
PLUGINPATH=os.path.realpath(os.path.join(PYMOLPATH, 'plugins'))

# Run every script in the folder and max. one sub-folder that is '.py'
PLUGINPATH_LIST=[os.path.realpath(os.path.join(PLUGINPATH, name)) for name
in os.listdir(PLUGINPATH) if os.path.isdir(os.path.join(PLUGINPATH, name))]
PLUGINPATH_LIST=[PLUGINPATH]+PLUGINPATH_LIST
print 'paths for plugins: '
for p in PLUGINPATH_LIST: print p
print
'#-------------------------------------------------------------------------------'
for d in PLUGINPATH_LIST:
print 'Initiating (sub)-directory: '+d
for f in os.listdir(d):
if f=='__init__.py': continue
if f.endswith('.py'):
print "Executing plugin: "+f
execfile(os.path.realpath(os.path.join(d, f)))
else:
if not os.path.isdir(os.path.join(d,f)):print 'skipping non .py
file: '+f
#########################

The drawback in 2 or 3 is that this will not work for true plugins that add
menus to PyMOL.

4. For simple script or short chunks of code I often copy-paste:
python
#code here
python end

into the pymol mini shell. This is great for testing part of the code.

In conclusion I recommend using option. 1 and restart PyMOL after making
changes to the script: The plugin manager is a very practical addition to
PyMOL and I love it. It just needs to be configured correctly, which is
something that changed in comparison to other PyMOL versions (cf. the link).
Just beware: removing a installed plugin may physically delete the file. So
be sure to backup your script should you decide to remove scripts or paths
that were added to the Plugin Manager.

Hope this will relieve some of the frustration.

Cheers,

Andreas
Post by Matthew Baumgartner
Hi,
So i am working on a pymol plugin (shameless plug
<https://sourceforge.net/projects/clustermolspy/>) and I have been
annoyed how difficult it is to reinstall my plugin so I can see the effect
of the changes I have made.
Plugin Menu > Plugin Manager > Install New Plugin tab > Choose File... >
Navigate to script file (could be 5-8 clicks plus some scrolling) > Select
plugin directory > Ok > Hit Ok to confirm reinstall > Hit OK to acknowledge
the reinstall > Close the Plugin Manager > Go to the Plugin Menu > Open my
Plugin at the bottom.
It's a super long process that really hampers rapid development, which is
super annoying when trying to tweak GUI elements.
So to my question, is there a faster method for getting the plugin to use
the new code? I am open to basically any solution.
In my frustration, I've looked into reverse engineering the Plugin Manager
and making my own little script. But I figured I should ask here before
doing this.
Thanks,
Matt
I'm using Pymol 1.7.1.7 and Ubuntu 13.10.
--
------------------------------------------------------------------------------
Want fast and easy access to all the code in your enterprise? Index and
search up to 200,000 lines of code with a free copy of Black Duck
Code Sight - the same software that powers the world's largest code
search on Ohloh, the Black Duck Open Hub! Try it now.
http://p.sf.net/sfu/bds
_______________________________________________
Info Page: https://lists.sourceforge.net/lists/listinfo/pymol-users
Matthew Baumgartner
2014-07-18 17:47:03 UTC
Permalink
Hi,
Thank you for you suggestions.
However, I was looking for a way to do it without restarting pymol if
possible. Currently, restarting is the fastest solution, but it still
takes up about 10-15 seconds to close pymol, restart it, and have it
load the structures I need to test my script.

One question that I have is that when pymol starts up, does it load the
scripts in the plugin menu into memory? Or when you click on the plugin
in the menu, does that read from a file on the disk somewhere?
My testing indicates the former, because launching pymol and then
editing the script in the ~/.pymol/startup folder does not change the
plugin.

Ideally, what I would like to be able to do is launch pymol once, then
open my plugin. Then if I make some changes to the code in the
appropriate folder, if I simply close the tk window and open the plugin
from the menu again, it would reopen the plugin with the new changes.

Short of that, running some commands in the command line window would
also be acceptable. I tried using the execfile command you suggested,
but that doesn't seem to do what I want. Did I do something wrong?

Thanks again for your help,
Matt
Post by Andreas Warnecke
Hej Matthew,
1. The advantage of using the plugin manager is that it will
automatically import all the plugin in the 'plugins' folder of the
'pymol-script-repo'. This should re-load you plugin if it is located
in a folder managed by the plugin manager. The loading of plugins
located therein occurs automatically.
You can add paths to the plugin manager either manually or using
scripts during startup as described in the link. This is the way I
http://www.pymolwiki.org/index.php/Plugin_manager
import pmg_tk.startup.colorama
# this is shown in the info dialog of the Plugin manager
A simple restart of PyMOL should re-load your updated plugin with the
changes made, provided the path is added to its list. It may require a
__init__.py file if it is a module.
2. if you are testing a plugin you can always have it in a separate
folder that you add yourself.
I sometime use the following to test scripts (added in the
#########################
import sys
import os
sys.path.append(os.path.abspath(os.path.join(os.environ['PYMOL_PATH'],
'plugins_private'))) # contains a folder called private with a (empty)
__init__.py file
import private
#########################
3. Another (maybe deprecated?) way of running your code would be to
use 'execfile'. This would correspond to running the python code in PyMOL.
#########################
import os
PYMOLPATH=os.environ['PYMOL_PATH']
#Append 'plugin' folder # Change to 'Pymol-script-repo' if required
PLUGINPATH=os.path.realpath(os.path.join(PYMOLPATH, 'plugins'))
# Run every script in the folder and max. one sub-folder that is '.py'
PLUGINPATH_LIST=[os.path.realpath(os.path.join(PLUGINPATH, name)) for
name in os.listdir(PLUGINPATH) if
os.path.isdir(os.path.join(PLUGINPATH, name))]
PLUGINPATH_LIST=[PLUGINPATH]+PLUGINPATH_LIST
print 'paths for plugins: '
for p in PLUGINPATH_LIST: print p
print
'#-------------------------------------------------------------------------------'
print 'Initiating (sub)-directory: '+d
if f=='__init__.py': continue
print "Executing plugin: "+f
execfile(os.path.realpath(os.path.join(d, f)))
if not os.path.isdir(os.path.join(d,f)):print 'skipping
non .py file: '+f
#########################
The drawback in 2 or 3 is that this will not work for true plugins
that add menus to PyMOL.
python
#code here
python end
into the pymol mini shell. This is great for testing part of the code.
In conclusion I recommend using option. 1 and restart PyMOL after
making changes to the script: The plugin manager is a very practical
addition to PyMOL and I love it. It just needs to be configured
correctly, which is something that changed in comparison to other
PyMOL versions (cf. the link).
Just beware: removing a installed plugin may physically delete the
file. So be sure to backup your script should you decide to remove
scripts or paths that were added to the Plugin Manager.
Hope this will relieve some of the frustration.
Cheers,
Andreas
Hi,
So i am working on a pymol plugin (shameless plug
<https://sourceforge.net/projects/clustermolspy/>) and I have been
annoyed how difficult it is to reinstall my plugin so I can see
the effect of the changes I have made.
Plugin Menu > Plugin Manager > Install New Plugin tab > Choose
File... > Navigate to script file (could be 5-8 clicks plus some
scrolling) > Select plugin directory > Ok > Hit Ok to confirm
reinstall > Hit OK to acknowledge the reinstall > Close the Plugin
Manager > Go to the Plugin Menu > Open my Plugin at the bottom.
It's a super long process that really hampers rapid development,
which is super annoying when trying to tweak GUI elements.
So to my question, is there a faster method for getting the plugin
to use the new code? I am open to basically any solution.
In my frustration, I've looked into reverse engineering the Plugin
Manager and making my own little script. But I figured I should
ask here before doing this.
Thanks,
Matt
I'm using Pymol 1.7.1.7 and Ubuntu 13.10.
--
------------------------------------------------------------------------------
Want fast and easy access to all the code in your enterprise? Index and
search up to 200,000 lines of code with a free copy of Black Duck
Code Sight - the same software that powers the world's largest code
search on Ohloh, the Black Duck Open Hub! Try it now.
http://p.sf.net/sfu/bds
_______________________________________________
Info Page: https://lists.sourceforge.net/lists/listinfo/pymol-users
Sampson, Jared
2014-07-18 18:08:23 UTC
Permalink
Hi Matt -

Does your plugin require a GUI, or can you rely on scripted commands and output files for your tests?

For any tests that don’t need the GUI, you might consider running them with something like `pymol -ckq my_test.pml`.

http://www.pymolwiki.org/index.php/Command_Line_Options

Cheers,
Jared

--
Jared Sampson
Xiangpeng Kong Lab
NYU Langone Medical Center
http://kong.med.nyu.edu/






On Jul 18, 2014, at 1:47 PM, Matthew Baumgartner <***@pitt.edu<mailto:***@pitt.edu>> wrote:

Hi,
Thank you for you suggestions.
However, I was looking for a way to do it without restarting pymol if possible. Currently, restarting is the fastest solution, but it still takes up about 10-15 seconds to close pymol, restart it, and have it load the structures I need to test my script.

One question that I have is that when pymol starts up, does it load the scripts in the plugin menu into memory? Or when you click on the plugin in the menu, does that read from a file on the disk somewhere?
My testing indicates the former, because launching pymol and then editing the script in the ~/.pymol/startup folder does not change the plugin.

Ideally, what I would like to be able to do is launch pymol once, then open my plugin. Then if I make some changes to the code in the appropriate folder, if I simply close the tk window and open the plugin from the menu again, it would reopen the plugin with the new changes.

Short of that, running some commands in the command line window would also be acceptable. I tried using the execfile command you suggested, but that doesn't seem to do what I want. Did I do something wrong?

Thanks again for your help,
Matt


On 07/18/2014 01:23 PM, Andreas Warnecke wrote:
Hej Matthew,

1. The advantage of using the plugin manager is that it will automatically import all the plugin in the 'plugins' folder of the 'pymol-script-repo'. This should re-load you plugin if it is located in a folder managed by the plugin manager. The loading of plugins located therein occurs automatically.
You can add paths to the plugin manager either manually or using scripts during startup as described in the link. This is the way I prefer to do it. Check the examples and linked pages:
http://www.pymolwiki.org/index.php/Plugin_manager

Note that deliberate import of these plugins changes:
e.g. to import colorama.py post startup use:
import pmg_tk.startup.colorama
# this is shown in the info dialog of the Plugin manager

A simple restart of PyMOL should re-load your updated plugin with the changes made, provided the path is added to its list. It may require a __init__.py file if it is a module.

2. if you are testing a plugin you can always have it in a separate folder that you add yourself.
I sometime use the following to test scripts (added in the run_on_startup.py):
#########################
import sys
import os
sys.path.append(os.path.abspath(os.path.join(os.environ['PYMOL_PATH'], 'plugins_private'))) # contains a folder called private with a (empty) __init__.py file
import private
#########################

3. Another (maybe deprecated?) way of running your code would be to use 'execfile'. This would correspond to running the python code in PyMOL.

#########################
import os
PYMOLPATH=os.environ['PYMOL_PATH']
#Append 'plugin' folder # Change to 'Pymol-script-repo' if required
PLUGINPATH=os.path.realpath(os.path.join(PYMOLPATH, 'plugins'))

# Run every script in the folder and max. one sub-folder that is '.py'
PLUGINPATH_LIST=[os.path.realpath(os.path.join(PLUGINPATH, name)) for name in os.listdir(PLUGINPATH) if os.path.isdir(os.path.join(PLUGINPATH, name))]
PLUGINPATH_LIST=[PLUGINPATH]+PLUGINPATH_LIST
print 'paths for plugins: '
for p in PLUGINPATH_LIST: print p
print '#-------------------------------------------------------------------------------'
for d in PLUGINPATH_LIST:
print 'Initiating (sub)-directory: '+d
for f in os.listdir(d):
if f=='__init__.py': continue
if f.endswith('.py'):
print "Executing plugin: "+f
execfile(os.path.realpath(os.path.join(d, f)))
else:
if not os.path.isdir(os.path.join(d,f)):print 'skipping non .py file: '+f
#########################

The drawback in 2 or 3 is that this will not work for true plugins that add menus to PyMOL.

4. For simple script or short chunks of code I often copy-paste:
python
#code here
python end

into the pymol mini shell. This is great for testing part of the code.

In conclusion I recommend using option. 1 and restart PyMOL after making changes to the script: The plugin manager is a very practical addition to PyMOL and I love it. It just needs to be configured correctly, which is something that changed in comparison to other PyMOL versions (cf. the link).
Just beware: removing a installed plugin may physically delete the file. So be sure to backup your script should you decide to remove scripts or paths that were added to the Plugin Manager.

Hope this will relieve some of the frustration.

Cheers,

Andreas


On Fri, Jul 18, 2014 at 5:41 PM, Matthew Baumgartner <***@pitt.edu<mailto:***@pitt.edu>> wrote:
Hi,
So i am working on a pymol plugin (shameless plug<https://sourceforge.net/projects/clustermolspy/>) and I have been annoyed how difficult it is to reinstall my plugin so I can see the effect of the changes I have made.

Currently, the process is:
Plugin Menu > Plugin Manager > Install New Plugin tab > Choose File... > Navigate to script file (could be 5-8 clicks plus some scrolling) > Select plugin directory > Ok > Hit Ok to confirm reinstall > Hit OK to acknowledge the reinstall > Close the Plugin Manager > Go to the Plugin Menu > Open my Plugin at the bottom.

It's a super long process that really hampers rapid development, which is super annoying when trying to tweak GUI elements.

So to my question, is there a faster method for getting the plugin to use the new code? I am open to basically any solution.
In my frustration, I've looked into reverse engineering the Plugin Manager and making my own little script. But I figured I should ask here before doing this.

Thanks,
Matt


I'm using Pymol 1.7.1.7 and Ubuntu 13.10.






--



------------------------------------------------------------------------------
Want fast and easy access to all the code in your enterprise? Index and
search up to 200,000 lines of code with a free copy of Black Duck
Code Sight - the same software that powers the world's largest code
search on Ohloh, the Black Duck Open Hub! Try it now.
http://p.sf.net/sfu/bds
_______________________________________________
PyMOL-users mailing list (PyMOL-***@lists.sourceforge.net<mailto:PyMOL-***@lists.sourceforge.net>)
Info Page: https://lists.sourceforge.net/lists/listinfo/pymol-users
Archives: http://www.mail-archive.com/pymol-***@lists.sourceforge.net


------------------------------------------------------------------------------
Want fast and easy access to all the code in your enterprise? Index and
search up to 200,000 lines of code with a free copy of Black Duck
Code Sight - the same software that powers the world's largest code
search on Ohloh, the Black Duck Open Hub! Try it now.
http://p.sf.net/sfu/bds_______________________________________________
PyMOL-users mailing list (PyMOL-***@lists.sourceforge.net)
Info Page: https://lists.sourceforge.net/lists/listinfo/pymol-users
Archives: http://www.mail-archive.com/pymol-***@lists.sourceforge.net

------------------------------------------------------------
This email message, including any attachments, is for the sole use of the intended recipient(s) and may contain information that is proprietary, confidential, and exempt from disclosure under applicable law. Any unauthorized review, use, disclosure, or distribution is prohibited. If you have received this email in error please notify the sender by return email and delete the original message. Please note, the recipient should check this email and any attachments for the presence of viruses. The organization accepts no liability for any damage caused by any virus transmitted by this email.
=================================
Matthew Baumgartner
2014-07-18 18:12:10 UTC
Permalink
Hi,
It is possible for users to run without a GUI, but it has a GUI and when
I am making changes to it I would like faster turn around times between
edits to my code.
Matt
Post by Sampson, Jared
Hi Matt -
Does your plugin require a GUI, or can you rely on scripted commands
and output files for your tests?
For any tests that don’t need the GUI, you might consider running them
with something like `pymol -ckq my_test.pml`.
http://www.pymolwiki.org/index.php/Command_Line_Options
Cheers,
Jared
--
Jared Sampson
Xiangpeng Kong Lab
NYU Langone Medical Center
http://kong.med.nyu.edu/
Post by Matthew Baumgartner
Hi,
Thank you for you suggestions.
However, I was looking for a way to do it without restarting pymol if
possible. Currently, restarting is the fastest solution, but it still
takes up about 10-15 seconds to close pymol, restart it, and have it
load the structures I need to test my script.
One question that I have is that when pymol starts up, does it load
the scripts in the plugin menu into memory? Or when you click on the
plugin in the menu, does that read from a file on the disk somewhere?
My testing indicates the former, because launching pymol and then
editing the script in the ~/.pymol/startup folder does not change the
plugin.
Ideally, what I would like to be able to do is launch pymol once,
then open my plugin. Then if I make some changes to the code in the
appropriate folder, if I simply close the tk window and open the
plugin from the menu again, it would reopen the plugin with the new
changes.
Short of that, running some commands in the command line window would
also be acceptable. I tried using the execfile command you suggested,
but that doesn't seem to do what I want. Did I do something wrong?
Thanks again for your help,
Matt
Post by Andreas Warnecke
Hej Matthew,
1. The advantage of using the plugin manager is that it will
automatically import all the plugin in the 'plugins' folder of the
'pymol-script-repo'. This should re-load you plugin if it is located
in a folder managed by the plugin manager. The loading of plugins
located therein occurs automatically.
You can add paths to the plugin manager either manually or using
scripts during startup as described in the link. This is the way I
http://www.pymolwiki.org/index.php/Plugin_manager
import pmg_tk.startup.colorama
# this is shown in the info dialog of the Plugin manager
A simple restart of PyMOL should re-load your updated plugin with
the changes made, provided the path is added to its list. It may
require a __init__.py file if it is a module.
2. if you are testing a plugin you can always have it in a separate
folder that you add yourself.
I sometime use the following to test scripts (added in the
#########################
import sys
import os
sys.path.append(os.path.abspath(os.path.join(os.environ['PYMOL_PATH'],
'plugins_private'))) # contains a folder called private with a
(empty) __init__.py file
import private
#########################
3. Another (maybe deprecated?) way of running your code would be to
use 'execfile'. This would correspond to running the python code in PyMOL.
#########################
import os
PYMOLPATH=os.environ['PYMOL_PATH']
#Append 'plugin' folder # Change to 'Pymol-script-repo' if required
PLUGINPATH=os.path.realpath(os.path.join(PYMOLPATH, 'plugins'))
# Run every script in the folder and max. one sub-folder that is '.py'
PLUGINPATH_LIST=[os.path.realpath(os.path.join(PLUGINPATH, name))
for name in os.listdir(PLUGINPATH) if
os.path.isdir(os.path.join(PLUGINPATH, name))]
PLUGINPATH_LIST=[PLUGINPATH]+PLUGINPATH_LIST
print 'paths for plugins: '
for p in PLUGINPATH_LIST: print p
print
'#-------------------------------------------------------------------------------'
print 'Initiating (sub)-directory: '+d
if f=='__init__.py': continue
print "Executing plugin: "+f
execfile(os.path.realpath(os.path.join(d, f)))
if not os.path.isdir(os.path.join(d,f)):print 'skipping non .py file: '+f
#########################
The drawback in 2 or 3 is that this will not work for true plugins
that add menus to PyMOL.
python
#code here
python end
into the pymol mini shell. This is great for testing part of the code.
In conclusion I recommend using option. 1 and restart PyMOL after
making changes to the script: The plugin manager is a very practical
addition to PyMOL and I love it. It just needs to be configured
correctly, which is something that changed in comparison to other
PyMOL versions (cf. the link).
Just beware: removing a installed plugin may physically delete the
file. So be sure to backup your script should you decide to remove
scripts or paths that were added to the Plugin Manager.
Hope this will relieve some of the frustration.
Cheers,
Andreas
Hi,
So i am working on a pymol plugin (shameless plug
<https://sourceforge.net/projects/clustermolspy/>) and I have
been annoyed how difficult it is to reinstall my plugin so I can
see the effect of the changes I have made.
Plugin Menu > Plugin Manager > Install New Plugin tab > Choose
File... > Navigate to script file (could be 5-8 clicks plus some
scrolling) > Select plugin directory > Ok > Hit Ok to confirm
reinstall > Hit OK to acknowledge the reinstall > Close the
Plugin Manager > Go to the Plugin Menu > Open my Plugin at the
bottom.
It's a super long process that really hampers rapid development,
which is super annoying when trying to tweak GUI elements.
So to my question, is there a faster method for getting the
plugin to use the new code? I am open to basically any solution.
In my frustration, I've looked into reverse engineering the
Plugin Manager and making my own little script. But I figured I
should ask here before doing this.
Thanks,
Matt
I'm using Pymol 1.7.1.7 and Ubuntu 13.10.
--
------------------------------------------------------------------------------
Want fast and easy access to all the code in your enterprise? Index and
search up to 200,000 lines of code with a free copy of Black Duck
Code Sight - the same software that powers the world's largest code
search on Ohloh, the Black Duck Open Hub! Try it now.
http://p.sf.net/sfu/bds
_______________________________________________
Info Page: https://lists.sourceforge.net/lists/listinfo/pymol-users
------------------------------------------------------------------------------
Want fast and easy access to all the code in your enterprise? Index and
search up to 200,000 lines of code with a free copy of Black Duck
Code Sight - the same software that powers the world's largest code
search on Ohloh, the Black Duck Open Hub! Try it now.
http://p.sf.net/sfu/bds_______________________________________________
Info Page: https://lists.sourceforge.net/lists/listinfo/pymol-users
------------------------------------------------------------
This email message, including any attachments, is for the sole use of
the intended recipient(s) and may contain information that is
proprietary, confidential, and exempt from disclosure under applicable
law. Any unauthorized review, use, disclosure, or distribution is
prohibited. If you have received this email in error please notify the
sender by return email and delete the original message. Please note,
the recipient should check this email and any attachments for the
presence of viruses. The organization accepts no liability for any
damage caused by any virus transmitted by this email.
=================================
Thomas Holder
2014-07-18 18:25:33 UTC
Permalink
Hi Matt,

python has some limited support to reload a module. I actually used that a lot when developing the plugin manager. This is just a hint, use with caution:

set_key F1, import pmg_tk;reload(pmg_tk.startup.foo)

https://docs.python.org/2/library/functions.html#reload

This will not re-invoke the plugin registration function (__init_plugin__) so if you have a menu item for your GUI, that might still launch the old (not reloaded) version.

Cheers,
Thomas
Hi,
It is possible for users to run without a GUI, but it has a GUI and when I am making changes to it I would like faster turn around times between edits to my code.
Matt
Post by Sampson, Jared
Hi Matt -
Does your plugin require a GUI, or can you rely on scripted commands and output files for your tests?
For any tests that don’t need the GUI, you might consider running them with something like `pymol -ckq my_test.pml`.
http://www.pymolwiki.org/index.php/Command_Line_Options
Cheers,
Jared
--
Jared Sampson
Xiangpeng Kong Lab
NYU Langone Medical Center
http://kong.med.nyu.edu/
Post by Matthew Baumgartner
Hi,
Thank you for you suggestions.
However, I was looking for a way to do it without restarting pymol if possible. Currently, restarting is the fastest solution, but it still takes up about 10-15 seconds to close pymol, restart it, and have it load the structures I need to test my script.
One question that I have is that when pymol starts up, does it load the scripts in the plugin menu into memory? Or when you click on the plugin in the menu, does that read from a file on the disk somewhere?
My testing indicates the former, because launching pymol and then editing the script in the ~/.pymol/startup folder does not change the plugin.
Ideally, what I would like to be able to do is launch pymol once, then open my plugin. Then if I make some changes to the code in the appropriate folder, if I simply close the tk window and open the plugin from the menu again, it would reopen the plugin with the new changes.
Short of that, running some commands in the command line window would also be acceptable. I tried using the execfile command you suggested, but that doesn't seem to do what I want. Did I do something wrong?
Thanks again for your help,
Matt
Post by Andreas Warnecke
Hej Matthew,
1. The advantage of using the plugin manager is that it will automatically import all the plugin in the 'plugins' folder of the 'pymol-script-repo'. This should re-load you plugin if it is located in a folder managed by the plugin manager. The loading of plugins located therein occurs automatically.
http://www.pymolwiki.org/index.php/Plugin_manager
import pmg_tk.startup.colorama
# this is shown in the info dialog of the Plugin manager
A simple restart of PyMOL should re-load your updated plugin with the changes made, provided the path is added to its list. It may require a __init__.py file if it is a module.
2. if you are testing a plugin you can always have it in a separate folder that you add yourself.
#########################
import sys
import os
sys.path.append(os.path.abspath(os.path.join(os.environ['PYMOL_PATH'], 'plugins_private'))) # contains a folder called private with a (empty) __init__.py file
import private
#########################
3. Another (maybe deprecated?) way of running your code would be to use 'execfile'. This would correspond to running the python code in PyMOL.
#########################
import os
PYMOLPATH=os.environ['PYMOL_PATH']
#Append 'plugin' folder # Change to 'Pymol-script-repo' if required
PLUGINPATH=os.path.realpath(os.path.join(PYMOLPATH, 'plugins'))
# Run every script in the folder and max. one sub-folder that is '.py'
PLUGINPATH_LIST=[os.path.realpath(os.path.join(PLUGINPATH, name)) for name in os.listdir(PLUGINPATH) if os.path.isdir(os.path.join(PLUGINPATH, name))]
PLUGINPATH_LIST=[PLUGINPATH]+PLUGINPATH_LIST
print 'paths for plugins: '
for p in PLUGINPATH_LIST: print p
print '#-------------------------------------------------------------------------------'
print 'Initiating (sub)-directory: '+d
if f=='__init__.py': continue
print "Executing plugin: "+f
execfile(os.path.realpath(os.path.join(d, f)))
if not os.path.isdir(os.path.join(d,f)):print 'skipping non .py file: '+f
#########################
The drawback in 2 or 3 is that this will not work for true plugins that add menus to PyMOL.
python
#code here
python end
into the pymol mini shell. This is great for testing part of the code.
In conclusion I recommend using option. 1 and restart PyMOL after making changes to the script: The plugin manager is a very practical addition to PyMOL and I love it. It just needs to be configured correctly, which is something that changed in comparison to other PyMOL versions (cf. the link).
Just beware: removing a installed plugin may physically delete the file. So be sure to backup your script should you decide to remove scripts or paths that were added to the Plugin Manager.
Hope this will relieve some of the frustration.
Cheers,
Andreas
Hi,
So i am working on a pymol plugin (shameless plug) and I have been annoyed how difficult it is to reinstall my plugin so I can see the effect of the changes I have made.
Plugin Menu > Plugin Manager > Install New Plugin tab > Choose File... > Navigate to script file (could be 5-8 clicks plus some scrolling) > Select plugin directory > Ok > Hit Ok to confirm reinstall > Hit OK to acknowledge the reinstall > Close the Plugin Manager > Go to the Plugin Menu > Open my Plugin at the bottom.
It's a super long process that really hampers rapid development, which is super annoying when trying to tweak GUI elements.
So to my question, is there a faster method for getting the plugin to use the new code? I am open to basically any solution.
In my frustration, I've looked into reverse engineering the Plugin Manager and making my own little script. But I figured I should ask here before doing this.
Thanks,
Matt
I'm using Pymol 1.7.1.7 and Ubuntu 13.10.
--
Thomas Holder
PyMOL Developer
Schrödinger, Inc.
Matthew Baumgartner
2014-07-18 20:00:30 UTC
Permalink
Ah, thank you very much this is exactly what I need!
I know it's not super safe, but for rapid development, this will be p=
erfect!

Thanks!
Post by Thomas Holder
Hi Matt,
python has some limited support to reload a module. I actually used=
that a lot when developing the plugin manager. This is just a hint, =
Post by Thomas Holder
set_key F1, import pmg_tk;reload(pmg_tk.startup.foo)
https://docs.python.org/2/library/functions.html#reload
This will not re-invoke the plugin registration function (__init_pl=
ugin__) so if you have a menu item for your GUI, that might still lau=
nch the old (not reloaded) version.
Post by Thomas Holder
Cheers,
Thomas
Hi,
It is possible for users to run without a GUI, but it has a GUI an=
d when I am making changes to it I would like faster turn around time=
s between edits to my code.
Post by Thomas Holder
Matt
Post by Sampson, Jared
Hi Matt -
Does your plugin require a GUI, or can you rely on scripted comma=
nds and output files for your tests?
Post by Thomas Holder
Post by Sampson, Jared
For any tests that don=92t need the GUI, you might consider runni=
ng them with something like `pymol -ckq my_test.pml`.
Post by Thomas Holder
Post by Sampson, Jared
http://www.pymolwiki.org/index.php/Command_Line_Options
Cheers,
Jared
--
Jared Sampson
Xiangpeng Kong Lab
NYU Langone Medical Center
http://kong.med.nyu.edu/
Post by Matthew Baumgartner
Hi,
Thank you for you suggestions.
However, I was looking for a way to do it without restarting pym=
ol if possible. Currently, restarting is the fastest solution, but it=
still takes up about 10-15 seconds to close pymol, restart it, and h=
ave it load the structures I need to test my script.
Post by Thomas Holder
Post by Sampson, Jared
Post by Matthew Baumgartner
One question that I have is that when pymol starts up, does it l=
oad the scripts in the plugin menu into memory? Or when you click on =
the plugin in the menu, does that read from a file on the disk somewh=
ere?
Post by Thomas Holder
Post by Sampson, Jared
Post by Matthew Baumgartner
My testing indicates the former, because launching pymol and the=
n editing the script in the ~/.pymol/startup folder does not change t=
he plugin.
Post by Thomas Holder
Post by Sampson, Jared
Post by Matthew Baumgartner
Ideally, what I would like to be able to do is launch pymol once=
, then open my plugin. Then if I make some changes to the code in the=
appropriate folder, if I simply close the tk window and open the plu=
gin from the menu again, it would reopen the plugin with the new chan=
ges.
Post by Thomas Holder
Post by Sampson, Jared
Post by Matthew Baumgartner
Short of that, running some commands in the command line window =
would also be acceptable. I tried using the execfile command you sugg=
ested, but that doesn't seem to do what I want. Did I do something wr=
ong?
Post by Thomas Holder
Post by Sampson, Jared
Post by Matthew Baumgartner
Thanks again for your help,
Matt
=20
Post by Andreas Warnecke
Hej Matthew,
1. The advantage of using the plugin manager is that it will au=
tomatically import all the plugin in the 'plugins' folder of the 'pym=
ol-script-repo'. This should re-load you plugin if it is located in a=
folder managed by the plugin manager. The loading of plugins located=
therein occurs automatically.
Post by Thomas Holder
Post by Sampson, Jared
Post by Matthew Baumgartner
Post by Andreas Warnecke
You can add paths to the plugin manager either manually or usin=
g scripts during startup as described in the link. This is the way I =
Post by Thomas Holder
Post by Sampson, Jared
Post by Matthew Baumgartner
Post by Andreas Warnecke
http://www.pymolwiki.org/index.php/Plugin_manager
import pmg_tk.startup.colorama
# this is shown in the info dialog of the Plugin manager
A simple restart of PyMOL should re-load your updated plugin wi=
th the changes made, provided the path is added to its list. It may r=
equire a __init__.py file if it is a module.
Post by Thomas Holder
Post by Sampson, Jared
Post by Matthew Baumgartner
Post by Andreas Warnecke
2. if you are testing a plugin you can always have it in a sepa=
rate folder that you add yourself.
Post by Thomas Holder
Post by Sampson, Jared
Post by Matthew Baumgartner
Post by Andreas Warnecke
I sometime use the following to test scripts (added in the run_=
#########################
import sys
import os
sys.path.append(os.path.abspath(os.path.join(os.environ['PYMOL_=
PATH'], 'plugins_private'))) # contains a folder called private with =
a (empty) __init__.py file
Post by Thomas Holder
Post by Sampson, Jared
Post by Matthew Baumgartner
Post by Andreas Warnecke
import private
#########################
3. Another (maybe deprecated?) way of running your code would b=
e to use 'execfile'. This would correspond to running the python code=
in PyMOL.
Post by Thomas Holder
Post by Sampson, Jared
Post by Matthew Baumgartner
Post by Andreas Warnecke
#########################
import os
PYMOLPATH=3Dos.environ['PYMOL_PATH']
#Append 'plugin' folder # Change to 'Pymol-script-repo' if requ=
ired
Post by Thomas Holder
Post by Sampson, Jared
Post by Matthew Baumgartner
Post by Andreas Warnecke
PLUGINPATH=3Dos.path.realpath(os.path.join(PYMOLPATH, 'plugins'=
))
Post by Thomas Holder
Post by Sampson, Jared
Post by Matthew Baumgartner
Post by Andreas Warnecke
# Run every script in the folder and max. one sub-folder that i=
s '.py'
Post by Thomas Holder
Post by Sampson, Jared
Post by Matthew Baumgartner
Post by Andreas Warnecke
PLUGINPATH_LIST=3D[os.path.realpath(os.path.join(PLUGINPATH, na=
me)) for name in os.listdir(PLUGINPATH) if os.path.isdir(os.path.join=
(PLUGINPATH, name))]
Post by Thomas Holder
Post by Sampson, Jared
Post by Matthew Baumgartner
Post by Andreas Warnecke
PLUGINPATH_LIST=3D[PLUGINPATH]+PLUGINPATH_LIST
print 'paths for plugins: '
for p in PLUGINPATH_LIST: print p
print '#-------------------------------------------------------=
------------------------'
Post by Thomas Holder
Post by Sampson, Jared
Post by Matthew Baumgartner
Post by Andreas Warnecke
print 'Initiating (sub)-directory: '+d
if f=3D=3D'__init__.py': continue
print "Executing plugin: "+f
execfile(os.path.realpath(os.path.join(d, f)))
if not os.path.isdir(os.path.join(d,f)):print 'ski=
pping non .py file: '+f
Post by Thomas Holder
Post by Sampson, Jared
Post by Matthew Baumgartner
Post by Andreas Warnecke
#########################
The drawback in 2 or 3 is that this will not work for true plug=
ins that add menus to PyMOL.
Post by Thomas Holder
Post by Sampson, Jared
Post by Matthew Baumgartner
Post by Andreas Warnecke
4. For simple script or short chunks of code I often copy-paste=
python
#code here
python end
into the pymol mini shell. This is great for testing part of th=
e code.
Post by Thomas Holder
Post by Sampson, Jared
Post by Matthew Baumgartner
Post by Andreas Warnecke
In conclusion I recommend using option. 1 and restart PyMOL aft=
er making changes to the script: The plugin manager is a very practic=
al addition to PyMOL and I love it. It just needs to be configured co=
rrectly, which is something that changed in comparison to other PyMOL=
versions (cf. the link).
Post by Thomas Holder
Post by Sampson, Jared
Post by Matthew Baumgartner
Post by Andreas Warnecke
Just beware: removing a installed plugin may physically delete =
the file. So be sure to backup your script should you decide to remov=
e scripts or paths that were added to the Plugin Manager.
Post by Thomas Holder
Post by Sampson, Jared
Post by Matthew Baumgartner
Post by Andreas Warnecke
Hope this will relieve some of the frustration.
Cheers,
Andreas
Hi,
So i am working on a pymol plugin (shameless plug) and I have b=
een annoyed how difficult it is to reinstall my plugin so I can see t=
he effect of the changes I have made.
Post by Thomas Holder
Post by Sampson, Jared
Post by Matthew Baumgartner
Post by Andreas Warnecke
Plugin Menu > Plugin Manager > Install New Plugin tab > Choose =
File... > Navigate to script file (could be 5-8 clicks plus some scro=
lling) > Select plugin directory > Ok > Hit Ok to confirm reinstall >=
Hit OK to acknowledge the reinstall > Close the Plugin Manager > Go =
to the Plugin Menu > Open my Plugin at the bottom.
Post by Thomas Holder
Post by Sampson, Jared
Post by Matthew Baumgartner
Post by Andreas Warnecke
It's a super long process that really hampers rapid development=
, which is super annoying when trying to tweak GUI elements.
Post by Thomas Holder
Post by Sampson, Jared
Post by Matthew Baumgartner
Post by Andreas Warnecke
So to my question, is there a faster method for getting the plu=
gin to use the new code? I am open to basically any solution.
Post by Thomas Holder
Post by Sampson, Jared
Post by Matthew Baumgartner
Post by Andreas Warnecke
In my frustration, I've looked into reverse engineering the Plu=
gin Manager and making my own little script. But I figured I should a=
sk here before doing this.
Post by Thomas Holder
Post by Sampson, Jared
Post by Matthew Baumgartner
Post by Andreas Warnecke
Thanks,
Matt
I'm using Pymol 1.7.1.7 and Ubuntu 13.10.
Sampson, Jared
2014-07-18 18:10:23 UTC
Permalink
Hi Matt -

Does your plugin require a GUI, or can you rely on scripted commands and output files for your tests?

For any tests that don’t need the GUI, you might consider running them with something like `pymol -ckq my_test.pml`.

http://www.pymolwiki.org/index.php/Command_Line_Options

Cheers,
Jared

--
Jared Sampson
Xiangpeng Kong Lab
NYU Langone Medical Center
http://kong.med.nyu.edu/






On Jul 18, 2014, at 1:47 PM, Matthew Baumgartner <***@pitt.edu<mailto:***@pitt.edu>> wrote:

Hi,
Thank you for you suggestions.
However, I was looking for a way to do it without restarting pymol if possible. Currently, restarting is the fastest solution, but it still takes up about 10-15 seconds to close pymol, restart it, and have it load the structures I need to test my script.

One question that I have is that when pymol starts up, does it load the scripts in the plugin menu into memory? Or when you click on the plugin in the menu, does that read from a file on the disk somewhere?
My testing indicates the former, because launching pymol and then editing the script in the ~/.pymol/startup folder does not change the plugin.

Ideally, what I would like to be able to do is launch pymol once, then open my plugin. Then if I make some changes to the code in the appropriate folder, if I simply close the tk window and open the plugin from the menu again, it would reopen the plugin with the new changes.

Short of that, running some commands in the command line window would also be acceptable. I tried using the execfile command you suggested, but that doesn't seem to do what I want. Did I do something wrong?

Thanks again for your help,
Matt


On 07/18/2014 01:23 PM, Andreas Warnecke wrote:
Hej Matthew,

1. The advantage of using the plugin manager is that it will automatically import all the plugin in the 'plugins' folder of the 'pymol-script-repo'. This should re-load you plugin if it is located in a folder managed by the plugin manager. The loading of plugins located therein occurs automatically.
You can add paths to the plugin manager either manually or using scripts during startup as described in the link. This is the way I prefer to do it. Check the examples and linked pages:
http://www.pymolwiki.org/index.php/Plugin_manager

Note that deliberate import of these plugins changes:
e.g. to import colorama.py post startup use:
import pmg_tk.startup.colorama
# this is shown in the info dialog of the Plugin manager

A simple restart of PyMOL should re-load your updated plugin with the changes made, provided the path is added to its list. It may require a __init__.py file if it is a module.

2. if you are testing a plugin you can always have it in a separate folder that you add yourself.
I sometime use the following to test scripts (added in the run_on_startup.py):
#########################
import sys
import os
sys.path.append(os.path.abspath(os.path.join(os.environ['PYMOL_PATH'], 'plugins_private'))) # contains a folder called private with a (empty) __init__.py file
import private
#########################

3. Another (maybe deprecated?) way of running your code would be to use 'execfile'. This would correspond to running the python code in PyMOL.

#########################
import os
PYMOLPATH=os.environ['PYMOL_PATH']
#Append 'plugin' folder # Change to 'Pymol-script-repo' if required
PLUGINPATH=os.path.realpath(os.path.join(PYMOLPATH, 'plugins'))

# Run every script in the folder and max. one sub-folder that is '.py'
PLUGINPATH_LIST=[os.path.realpath(os.path.join(PLUGINPATH, name)) for name in os.listdir(PLUGINPATH) if os.path.isdir(os.path.join(PLUGINPATH, name))]
PLUGINPATH_LIST=[PLUGINPATH]+PLUGINPATH_LIST
print 'paths for plugins: '
for p in PLUGINPATH_LIST: print p
print '#-------------------------------------------------------------------------------'
for d in PLUGINPATH_LIST:
print 'Initiating (sub)-directory: '+d
for f in os.listdir(d):
if f=='__init__.py': continue
if f.endswith('.py'):
print "Executing plugin: "+f
execfile(os.path.realpath(os.path.join(d, f)))
else:
if not os.path.isdir(os.path.join(d,f)):print 'skipping non .py file: '+f
#########################

The drawback in 2 or 3 is that this will not work for true plugins that add menus to PyMOL.

4. For simple script or short chunks of code I often copy-paste:
python
#code here
python end

into the pymol mini shell. This is great for testing part of the code.

In conclusion I recommend using option. 1 and restart PyMOL after making changes to the script: The plugin manager is a very practical addition to PyMOL and I love it. It just needs to be configured correctly, which is something that changed in comparison to other PyMOL versions (cf. the link).
Just beware: removing a installed plugin may physically delete the file. So be sure to backup your script should you decide to remove scripts or paths that were added to the Plugin Manager.

Hope this will relieve some of the frustration.

Cheers,

Andreas


On Fri, Jul 18, 2014 at 5:41 PM, Matthew Baumgartner <***@pitt.edu<mailto:***@pitt.edu>> wrote:
Hi,
So i am working on a pymol plugin (shameless plug<https://sourceforge.net/projects/clustermolspy/>) and I have been annoyed how difficult it is to reinstall my plugin so I can see the effect of the changes I have made.

Currently, the process is:
Plugin Menu > Plugin Manager > Install New Plugin tab > Choose File... > Navigate to script file (could be 5-8 clicks plus some scrolling) > Select plugin directory > Ok > Hit Ok to confirm reinstall > Hit OK to acknowledge the reinstall > Close the Plugin Manager > Go to the Plugin Menu > Open my Plugin at the bottom.

It's a super long process that really hampers rapid development, which is super annoying when trying to tweak GUI elements.

So to my question, is there a faster method for getting the plugin to use the new code? I am open to basically any solution.
In my frustration, I've looked into reverse engineering the Plugin Manager and making my own little script. But I figured I should ask here before doing this.

Thanks,
Matt


I'm using Pymol 1.7.1.7 and Ubuntu 13.10.






--



------------------------------------------------------------------------------
Want fast and easy access to all the code in your enterprise? Index and
search up to 200,000 lines of code with a free copy of Black Duck
Code Sight - the same software that powers the world's largest code
search on Ohloh, the Black Duck Open Hub! Try it now.
http://p.sf.net/sfu/bds
_______________________________________________
PyMOL-users mailing list (PyMOL-***@lists.sourceforge.net<mailto:PyMOL-***@lists.sourceforge.net>)
Info Page: https://lists.sourceforge.net/lists/listinfo/pymol-users
Archives: http://www.mail-archive.com/pymol-***@lists.sourceforge.net


------------------------------------------------------------------------------
Want fast and easy access to all the code in your enterprise? Index and
search up to 200,000 lines of code with a free copy of Black Duck
Code Sight - the same software that powers the world's largest code
search on Ohloh, the Black Duck Open Hub! Try it now.
http://p.sf.net/sfu/bds_______________________________________________
PyMOL-users mailing list (PyMOL-***@lists.sourceforge.net)
Info Page: https://lists.sourceforge.net/lists/listinfo/pymol-users
Archives: http://www.mail-archive.com/pymol-***@lists.sourceforge.net

------------------------------------------------------------
This email message, including any attachments, is for the sole use of the intended recipient(s) and may contain information that is proprietary, confidential, and exempt from disclosure under applicable law. Any unauthorized review, use, disclosure, or distribution is prohibited. If you have received this email in error please notify the sender by return email and delete the original message. Please note, the recipient should check this email and any attachments for the presence of viruses. The organization accepts no liability for any damage caused by any virus transmitted by this email.
=================================
Loading...