We're Hiring!

Omero scripting service debugging

General and open developer discussion about using OMERO APIs from C++, Java, Python, Matlab and more! Please new questions at https://forum.image.sc/tags/omero
Please note:
Historical discussions about OMERO. Please look for and ask new questions at https://forum.image.sc/tags/omero

If you are having trouble with custom code, please provide a link to a public repository, ideally GitHub.

Omero scripting service debugging

Postby Hang » Wed Mar 28, 2018 10:05 pm

Hi,

I have some questions about using the python scripting service:

1. When I use "print" function, where can I see the prints while the script being executed?

2. Can I show/render an image on the screen using python scripts?

Thanks,

Hang
Hang
 
Posts: 46
Joined: Wed Mar 07, 2018 10:22 pm

Re: Omero scripting service debugging

Postby wmoore » Fri Mar 30, 2018 10:49 am

Hi Hang,

It's not really easy to see the print statements while the script is running. They are in a temp folder which you'll see created if you follow the Processor-0.log on the server:

Code: Select all
$ tail -f dist/var/log/Processor-0.log
...
2018-03-30 09:39:39,022 INFO  [                omero.processor.ProcessI] (Dummy-13  ) Created 7639a872-b5df-4823-a215-67273586e69c in /Users/wmoore/omero/tmp/omero_wmoore/31276/processBDrApF.dir


But when it completes you will get a stdout file created in OMERO and returned and this has all the print statements.
If you're running the script from the webclient, this is accessible from the (i) icon in the web Activities dialog (see screenshot). If you "bin/omero script launch" from the command line it is returned in the console.

If you have access to the server itself, you can also look for the latest files under the OMERO binary repository Files/ dir.


You can't show an image on screen when the script is running, but there are a couple of ways you can create an image and return it to the user, both of which require saving the image to OMERO:
- Create a new Image in OMERO (and add it to an appropriate Dataset) - see conn.createImageFromNumpySeq() described at https://docs.openmicroscopy.org/latest/ ... ython.html. An example of creating a new image in this way starting with a PIL image can be seen at https://github.com/ome/omero-figure/blo ... f.py#L1778
Return this from the OMERO.script using
Code: Select all
i = conn.createImageFromNumpySeq(....)
client.setOutput("Image", robject(i._obj))

and the webclient UI will show a link to open the image.

- or create a tiff/png as an Original file linked to a File Annotation. See conn.createFileAnnfromLocalFile(file_name, mimetype="image/png") in the Python.html link above. Again, you can return this in the same way:
Code: Select all
client.setOutput("File_Annotation", robject(file_annotation._obj))

See example at https://github.com/ome/scripts/blob/dev ... re.py#L803
If the file is viewable in the browser (png/jpeg) then the webclient will give you a link to show it in a pop-up window.

Hope that helps.

Will.
Attachments
Screen Shot 2018-03-30 at 09.52.19.png
Screen Shot 2018-03-30 at 09.52.19.png (66.37 KiB) Viewed 1001 times
User avatar
wmoore
Team Member
 
Posts: 674
Joined: Mon May 18, 2009 12:46 pm


Return to Developer Discussion

Who is online

Users browsing this forum: Bing [Bot] and 1 guest

cron