We're Hiring!

cannot get objects in python script with OME 5

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.

cannot get objects in python script with OME 5

Postby tom_deschamps » Wed Jul 24, 2013 7:02 am

Hi

I just upgraded the server/client to 5.0.0 and one of my scripts is not working anymore when called from the insight client or through the web interface.
Calls like
Code: Select all
import omero.util.script_utils as scriptUtil

scriptUtil.getObjects(conn, parameterMap)

returns nothing.
Previously that was the way for me to get access to images.
Is there a way I could check that everything is working correctly, that I have the correct permissions for accessing the images?

Thanks for the help
tom_deschamps
 
Posts: 22
Joined: Fri Mar 22, 2013 12:22 am

Re: cannot get objects in python script with OME 5

Postby atarkowska » Wed Jul 24, 2013 9:42 am

Hi

What version of omero did you use before? script_util is not something recomannded anymore. We have a whole new Python API you should use.

For example getObjects works as follow:

Code: Select all
params = omero.sys.ParametersI()
params.exp(conn.getUser().getId())  # only show current user's Datasets
datasets = conn.getObjects("Dataset", params=params)


I hope it will help you
Ola
atarkowska
 
Posts: 327
Joined: Mon May 18, 2009 12:44 pm

Re: cannot get objects in python script with OME 5

Postby wmoore » Thu Jul 25, 2013 9:07 am

When you say that
Code: Select all
scriptUtil.getObjects()
returned 'nothing', you mean you got the message that says "No images found" ?

You can see the code here: https://github.com/openmicroscopy/openm ... ls.py#L349

This is simply a wrapper around conn.getObjects() that gives a nice message that is used by most of our scripts.

The script should be run in the permissions/group context that you called it from the client.

Try adding these lines to your script, then check the stdout "info" from the script.

Code: Select all
print conn.getGroupFromContext().getName()
print conn.getEventContext()


Is this the group that the image is in, or can you at least see the image when logged in to that group?
Is this the group that you're running the script from?

Did you run the script from Insight or web? In insight it is possible to run a script from one 'group context' even though the image is in a different group, although if you have the image selected when you run the script then it should run the script under the correct context.
User avatar
wmoore
Team Member
 
Posts: 674
Joined: Mon May 18, 2009 12:46 pm

Re: cannot get objects in python script with OME 5

Postby tom_deschamps » Mon Jul 29, 2013 10:42 pm

Thanks for your reply. I'm giving a shot at it.
tom_deschamps
 
Posts: 22
Joined: Fri Mar 22, 2013 12:22 am


Return to Developer Discussion

Who is online

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