Python gadget in docker

51 views
Skip to first unread message

Franck Mauconduit

unread,
Apr 30, 2020, 3:15:16 PM4/30/20
to Gadgetron
Dear Gadgetron users,

I'm trying to use python gadgets within a docker insall ( ubuntu_1804_no_cuda ), I am not sure what should be the arguments in "process" method.

Also, where can I see the python output from print command ?


Thank you for your help
Franck

class MyRecoGadget(Gadget):

    def process_config(self, cfg):
        print("SparklingReco -> process_config()")

    def process(self, header, data, metadata=None):
        print("SparklingReco -> process()")
        return 0


04-30 17:34:17.863 DEBUG [PythonGadget.h:155] Successfully declare class : MyRecoGadget
04-30 17:34:17.863 DEBUG [PythonGadget.h:186] Call process_config ... 
04-30 17:34:17.864 DEBUG [PythonGadget.h:198] Call process_config completed - success 
04-30 17:34:17.864 DEBUG [PythonGadget.h:394] Passing data on to python module failed
terminate called after throwing an instance of 'boost::python::error_already_set'
04-30 17:34:19.123 INFO [main.cpp:191] Starting ReST interface on port 9080
04-30 17:34:19.134 INFO [main.cpp:203] Starting cloudBus: 127.0.0.1:8002
04-30 17:34:19.135 INFO [main.cpp:251] Configuring services, Running on port 9002
04-30 17:34:19.135 DEBUG [CloudBus.cpp:191] CloudBus connected to relay at  127.0.0.1:8002

Franck Mauconduit

unread,
May 4, 2020, 2:27:11 AM5/4/20
to Gadgetron
Hi,

I finally found a way to get the log informations. I post my solution for future users.

After starting the docker container, I first stopped the gadgetron server from a web browser in the HOST ( address : http://localhost:9001/ ). 

Then, I can start again the gadgetron server from the host with the command: sudo docker -ti gt1 gadgetron -r 127.0.0.1


Like so, I can see the print() statements within python gadgets. It is also working to use break points by using pdb.set_trace()

Regards
Franck

David Hansen

unread,
May 4, 2020, 3:01:29 AM5/4/20
to Gadgetron
Hi Frank,

Sorry for not replying earlier.

We had this issue on and off in Gadgetron 3, where the python errors wouldn't get back to Gadgetron.
In Gadgetron 4, this has all been fixed, and debugging python has become much much easier.
Using the connect facility, you can even use python with a debugger, a jupyter notebook, or an IDE like Spyder or PyCharm.


Best,
David
Reply all
Reply to author
Forward
0 new messages