[ome-devel] Calling the importer from Python

Niko Ehrenfeuchter nikolaus.ehrenfeuchter at unibas.ch
Tue May 12 14:26:51 BST 2015


Hi Will & Ola,

many many thanks for the additional pointers, that's exactly what I've 
been looking for!

Ola, I assume the set_client() method was added with OMERO 5.1, right?

Cheers
~Niko

On 12.05.2015 11:19, Aleksandra Tarkowska (Staff) wrote:
> Hi Niko,
>
> First looks like example in the thread was moved to
> https://github.com/openmicroscopy/openmicroscopy/blob/develop/components/tests/python/library/__init__.py#L219
> That may gives you a better idea ;-)
>
> Also in the example below client object should be set using:
>
> cli.set_client(conn.c)
>
> Kind regards
> Ola
>
> From: William Moore <will at lifesci.dundee.ac.uk
> <mailto:will at lifesci.dundee.ac.uk>>
> Reply-To: OME External Developer List
> <ome-devel at lists.openmicroscopy.org.uk
> <mailto:ome-devel at lists.openmicroscopy.org.uk>>
> Date: Tue, 12 May 2015 10:05:34 +0100
> To: OME External Developer List <ome-devel at lists.openmicroscopy.org.uk
> <mailto:ome-devel at lists.openmicroscopy.org.uk>>
> Subject: Re: [ome-devel] Calling the importer from Python
>
> Hi Niko,
>
>   You should be able to use conn.c to access the underlying omero.client
> in the
> Blitz Gateway. This client is already connected (don't need to call
> createClient).
> So you can simply do:
>
> cli = omero.cli.CLI()
> cli.loadplugins()
> cli._client = conn.c
> cli.invoke(["import", path_to_file])
>
>
> You might also find something useful at
> https://www.openmicroscopy.org/community/viewtopic.php?f=6&t=7562&p=14258
>
> which links to this example:
> https://github.com/ome/omego/blob/master/auto_import.py
>
> Regards,
>
>    Will.
>
>
>
> On 12 May 2015, at 08:29, Niko Ehrenfeuchter
> <nikolaus.ehrenfeuchter at unibas.ch
> <mailto:nikolaus.ehrenfeuchter at unibas.ch>> wrote:
>
>> Hi again,
>>
>> one more question regarding this: is there a way to create the CLI()
>> object using an existing BlitzGateway connection?
>>
>> I'm only asking since all the rest of my script is currently based on
>> the conn object only, so it were very nice if I could simply re-use that.
>>
>> Thanks
>> ~Niko
>>
>> On 12.05.2015 00:00, Niko Ehrenfeuchter wrote:
>>> Hi Ola,
>>>
>>> thanks for the quick response, I'll go for the omero.cli version then.
>>>
>>> The example in the thread mentioned is very helpful, btw!
>>>
>>> Best
>>> ~Niko
>>>
>>> On 11.05.2015 23:47, Aleksandra Tarkowska (Staff) wrote:
>>>> Hi Niko,
>>>>
>>>> I am affraid that is the way to do it. Please see similar thread
>>>>
>>>> http://lists.openmicroscopy.org.uk/pipermail/ome-devel/2014-September/002982.html
>>>>
>>>>
>>>>
>>>> Kind regards
>>>> Ola
>>>>
>>>>> On 11 May 2015, at 21:45, Niko Ehrenfeuchter
>>>>> <nikolaus.ehrenfeuchter at unibas.ch
>>>>> <mailto:nikolaus.ehrenfeuchter at unibas.ch>> wrote:
>>>>>
>>>>> Hi all,
>>>>>
>>>>> I was wondering what the best method for calling the importer from
>>>>> within a Python script might be?
>>>>>
>>>>> I've looked at uploadFile() from omero.util.script_utils, but in my
>>>>> understanding that's not for images - or am I wrong here?
>>>>>
>>>>> Delusively, the most simple thing would be to use
>>>>> omero.plugins.import, but as far as I can see the plugins are not
>>>>> meant as modules to be imported in other Python scripts but rather
>>>>> for extending the OMERO command line interface.
>>>>>
>>>>> Of course I could use popen() to call the "real" command line
>>>>> interface directly, but it feels a bit stupid calling a Python script
>>>>> from another one where all the OMERO stuff has already been set up.
>>>>>
>>>>> My approach now would be to use the CLI class from omero.cli, but I
>>>>> wanted to know if there is a better way that I am overlooking?
>>>>>
>>>>> Many Thanks,
>>>>> ~Niko
>>>>> --
>>>>> Niko Ehrenfeuchter | Image Analysis Specialist | Biozentrum,
>>>>> University of Basel | Klingelbergstr. 50/70 | CH-4056 Basel
>>>>> Phone: +41 (61) 26 72673 | nikolaus.ehrenfeuchter at unibas.ch
>>>>> <mailto:nikolaus.ehrenfeuchter at unibas.ch> |
>>>>> www.biozentrum.unibas.ch | www.microscopynetwork.unibas.ch
>>>>> _______________________________________________
>>>>> ome-devel mailing list
>>>>> ome-devel at lists.openmicroscopy.org.uk
>>>>> <mailto:ome-devel at lists.openmicroscopy.org.uk>
>>>>> http://lists.openmicroscopy.org.uk/mailman/listinfo/ome-devel
>>>>
>>>> The University of Dundee is a registered Scottish Charity, No: SC015096
>>>> _______________________________________________
>>>> ome-devel mailing list
>>>> ome-devel at lists.openmicroscopy.org.uk
>>>> <mailto:ome-devel at lists.openmicroscopy.org.uk>
>>>> http://lists.openmicroscopy.org.uk/mailman/listinfo/ome-devel
>>>>
>>>
>>
>> --
>> Niko Ehrenfeuchter | Image Analysis Specialist | Biozentrum,
>> University of Basel | Klingelbergstr. 50/70 | CH-4056 Basel
>> Phone: +41 (61) 26 72673 | nikolaus.ehrenfeuchter at unibas.ch
>> <mailto:nikolaus.ehrenfeuchter at unibas.ch> | www.biozentrum.unibas.ch
>> <http://www.biozentrum.unibas.ch> | www.microscopynetwork.unibas.ch
>> <http://www.microscopynetwork.unibas.ch>
>> _______________________________________________
>> ome-devel mailing list
>> ome-devel at lists.openmicroscopy.org.uk
>> <mailto:ome-devel at lists.openmicroscopy.org.uk>
>> http://lists.openmicroscopy.org.uk/mailman/listinfo/ome-devel
>
> _______________________________________________ ome-devel mailing list
> ome-devel at lists.openmicroscopy.org.uk
> <mailto:ome-devel at lists.openmicroscopy.org.uk>
> http://lists.openmicroscopy.org.uk/mailman/listinfo/ome-devel
> The University of Dundee is a registered Scottish Charity, No: SC015096
>
>
> _______________________________________________
> ome-devel mailing list
> ome-devel at lists.openmicroscopy.org.uk
> http://lists.openmicroscopy.org.uk/mailman/listinfo/ome-devel
>

-- 
Niko Ehrenfeuchter | Image Analysis Specialist | Biozentrum, University 
of Basel | Klingelbergstr. 50/70 | CH-4056 Basel
Phone: +41 (61) 26 72673 | nikolaus.ehrenfeuchter at unibas.ch | 
www.biozentrum.unibas.ch | www.microscopynetwork.unibas.ch


More information about the ome-devel mailing list