[chimerax-users] ChimeraX tool installationg
Anthony James Schaefer
tony.schaefer at uga.edu
Thu Feb 4 17:05:02 PST 2021
Yongcheng,
I think there are some other issues than what Eric mentioned. The register_command method of BundleAPI's should take three arguments: bundle info, command info, and a logger. Your register_command only has 2 arguments (CL_Tensorflow, and logger). You'll have to add an argument to your function.
You might also want to check the variable names you're using. When you call register:
from chimerax.core.commands import register
register(CL_Tensorflow, desc, cmd.CL_Tensorflow)
The first argument here should be a string (the name of the command). But you've got CL_Tensorflow as an argument in your BundleAPI's register_command definition. None of the arguments that get passed to the BundleAPI's register_command are strings. I think you can change that by setting api_version = 0, but I'm not sure. You might want something more like:
class CL_Tensorflow(BundleAPI):
api_version = 1
@statismethod
def register_command(bundle_info, command_info, logger):
# I'm going to skip importing the command function and
# description because I don't know what your code looks like
# let's just say your CmdDesc was imported as 'desc' and the function was
# imported as 'func'
# you'll have to fill that in yourself
from chimerax.core.commands import register
# use the command_info variable given to register_command to specify
# the name of the command
register(command_info.name, desc, func)
Best,
Tony
________________________________
From: ChimeraX-users <chimerax-users-bounces at cgl.ucsf.edu> on behalf of Yongcheng MU <ymu004 at odu.edu>
Sent: Thursday, February 4, 2021 5:51 PM
To: ChimeraX Users Help <chimerax-users at cgl.ucsf.edu>
Subject: Re: [chimerax-users] ChimeraX tool installationg
[EXTERNAL SENDER - PROCEED CAUTIOUSLY]
Hi Eric,
I really appreciate your quick response. It really helps me a lot to understand it. But I have another question, following your instructions, I modified the _init_.py file but it still holds an error. I attached some related information below.
Thank you for your time and help.
Best regards,
Yongcheng
On Thu, Feb 4, 2021 at 4:09 PM Eric Pettersen <pett at cgl.ucsf.edu<mailto:pett at cgl.ucsf.edu>> wrote:
Hi Yongcheng,
You probably know this, but in order to avoid registering all commands at startup, which would involve executing the code from dozens of bundles and make startup really slow, ChimeraX uses information from the Toolshed to know which bundles implement which commands and only when the time comes to actually execute a command does it invoke the bundle's code that fully registers the command, which then allows ChimeraX to know what arguments and keywords the command allows and what function the command executes so that it can parse the command text and call that function.
So all that error text you got is indicating that there is an error in your command-registration function. ChimeraX asks you to register your command by calling the register_command() method of your BundleAPI subclass. Does the implementation of register_command() in your __init__.py look something like this?:
from chimerax.core.toolshed import BundleAPI
class CL_TensorFlowAPI(BundleAPI):
@staticmethod
def register_command(command_name, logger):
from . import cmd
cmd.register_command(command_name, logger)
If it does, then the problem is that you have no cmd.py file in your bundle, producing the error:
cannot import name 'cmd' from 'chimerax.CL_Tensorflow' (/Users/jackmu/Library/Application Support/ChimeraX/1.1/site-packages/chimerax/CL_Tensorflow/__init__.py))
Let me know if you need further clarification.
--Eric
Eric Pettersen
UCSF Computer Graphics Lab
On Feb 4, 2021, at 10:45 AM, Yongcheng MU <ymu004 at odu.edu<mailto:ymu004 at odu.edu>> wrote:
Hello,
Hope you are doing well. This is Yongcheng. I am writing this email because I am trying to install a Deep learning tool in ChimeraX, but I have some issues about it.
I built and installed my code following the steps on the Chimera Guide website. I installed my code successfully, but when I run using command that I created, it hold some errors:
"RuntimeError: delayed command registration for 'CL_Tensorflow' failed (register_command() failed for command CL_Tensorflow in bundle ChimeraX-CL-Tensorflow:
cannot import name 'cmd' from 'chimerax.CL_Tensorflow' (/Users/jackmu/Library/Application Support/ChimeraX/1.1/site-packages/chimerax/CL_Tensorflow/__init__.py))
File "/Users/jackmu/Desktop/ChimeraX-1.1.1.app/Contents/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/chimerax/core/commands/cli.py", line 2142, in lazy_register
raise RuntimeError("delayed command registration for %r failed (%s)" % (cmd_name, e))"
"During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/Users/jackmu/Desktop/ChimeraX-1.1.1.app/Contents/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/chimerax/cmd_line/tool.py", line 275, in execute
cmd.run(cmd_text)
File "/Users/jackmu/Desktop/ChimeraX-1.1.1.app/Contents/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/chimerax/core/commands/cli.py", line 2746, in run
self._find_command_name(final, used_aliases=_used_aliases)
File "/Users/jackmu/Desktop/ChimeraX-1.1.1.app/Contents/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/chimerax/core/commands/cli.py", line 2489, in _find_command_name
what.lazy_register(cmd_name)
File "/Users/jackmu/Desktop/ChimeraX-1.1.1.app/Contents/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/chimerax/core/commands/cli.py", line 2142, in lazy_register
raise RuntimeError("delayed command registration for %r failed (%s)" % (cmd_name, e))
RuntimeError: delayed command registration for 'CL_Tensorflow' failed (register_command() failed for command CL_Tensorflow in bundle ChimeraX-CL-Tensorflow:
cannot import name 'cmd' from 'chimerax.CL_Tensorflow' (/Users/jackmu/Library/Application Support/ChimeraX/1.1/site-packages/chimerax/CL_Tensorflow/__init__.py))
RuntimeError: delayed command registration for 'CL_Tensorflow' failed (register_command() failed for command CL_Tensorflow in bundle ChimeraX-CL-Tensorflow:
cannot import name 'cmd' from 'chimerax.CL_Tensorflow' (/Users/jackmu/Library/Application Support/ChimeraX/1.1/site-packages/chimerax/CL_Tensorflow/__init__.py))
File "/Users/jackmu/Desktop/ChimeraX-1.1.1.app/Contents/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/chimerax/core/commands/cli.py", line 2142, in lazy_register
raise RuntimeError("delayed command registration for %r failed (%s)" % (cmd_name, e))"
I wonder if you know what's going on here, and how to fix it. Thank you so much for your time.
Best regards,
Yongcheng
_______________________________________________
ChimeraX-users mailing list
ChimeraX-users at cgl.ucsf.edu<mailto:ChimeraX-users at cgl.ucsf.edu>
Manage subscription:
https://www.rbvi.ucsf.edu/mailman/listinfo/chimerax-users
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://plato.cgl.ucsf.edu/pipermail/chimerax-users/attachments/20210205/599ee9be/attachment.html>
More information about the ChimeraX-users
mailing list