download/save OMERO.table file from remote/to local server

General and open developer discussion about using OMERO APIs from C++, Java, Python, Matlab and more!

download/save OMERO.table file from remote/to local server

Postby bhcho » Mon Feb 13, 2012 8:16 pm

Hi,

Hope everyone is having a wonderful season.
Another question today.

I have a two Blitz gateway connection objects (one for my local server and the other for a remote server).
what I want to do is....
I want to download a OMERO.table file from the remote server into my local server.
I have the file ID of the table in the remote server.
Could you tell me how to download it and save it with a different filelname on my local server?

Best,
BK
bhcho
 
Posts: 236
Joined: Mon Apr 05, 2010 2:15 pm

Re: download/save OMERO.table file from remote/to local serv

Postby jmoore » Mon Feb 13, 2012 10:45 pm

Hi BK,

there's no direct server-to-server functionality presently in OMERO. Instead, you'll need to use one BlitzGateway connection to download the file from one server, and then use the other BlitzGateway connection to upload the same file.

~Josh
User avatar
jmoore
Team Member
 
Posts: 1011
Joined: Fri May 22, 2009 1:29 pm
Location: Germany

Re: download/save OMERO.table file from remote/to local serv

Postby bhcho » Mon Feb 13, 2012 11:26 pm

Thanks Josh,

I understand what you mean. But could you please give me a snippet of downloading/uploading the OMERO.table file?
-----------------------------------------------
(added)
I have the query results from the code below
Code: Select all
result = conn_remote.getQueryService().findByQuery(query_string,params.page(0,1))

I'm wondering how to save the 'result' to local server (conn_local) with changing the file name (from 'AAA.h5' to 'BBB.h5') .


BK
bhcho
 
Posts: 236
Joined: Mon Apr 05, 2010 2:15 pm

Re: download/save OMERO.table file from remote/to local serv

Postby jmoore » Tue Feb 14, 2012 11:59 pm

Hi BK,

bhcho wrote:I understand what you mean. But could you please give me a snippet of downloading/uploading the OMERO.table file?


Do you not already have code that's downloading the files? For example what Will pasted to you under "idea about attaching/retrieving a same-name file on servers"

If so, can you show us what you have for downloading so that we can adapt it?

Cheers,
~Josh
User avatar
jmoore
Team Member
 
Posts: 1011
Joined: Fri May 22, 2009 1:29 pm
Location: Germany

Re: download/save OMERO.table file from remote/to local serv

Postby bhcho » Wed Feb 15, 2012 12:20 am

After getting the query 'result',

Code: Select all
In [23]: fid = result.getId().getValue()
In [24]: file_remote = conn_remote.getObject("OriginalFile", fid)
In [25]: file_remote
Out[25]: <_OriginalFileWrapper id=15454>


I know until here. But I'm wondering how I can upload this to a local server using 'conn_local'.

BK
bhcho
 
Posts: 236
Joined: Mon Apr 05, 2010 2:15 pm

Re: download/save OMERO.table file from remote/to local serv

Postby jmoore » Wed Feb 15, 2012 7:33 am

Morning, BK.

Code: Select all
In [1]: from omero.gateway import BlitzGateway
In [2]: remote_conn = BlitzGateway(client_obj=client) # For testing only
In [3]: local_conn = BlitzGateway(client_obj=client) # For testing only
In [4]: import omero
In [5]: orig_file = omero.model.OriginalFileI(4453, False)
In [7]: remote_conn.c.download(orig_file, filename="/tmp/4453")
In [8]: local_conn.c.upload(filename="/tmp/4453", type="OMERO.tables")


should work.

Cheers,
~Josh
User avatar
jmoore
Team Member
 
Posts: 1011
Joined: Fri May 22, 2009 1:29 pm
Location: Germany

Re: download/save OMERO.table file from remote/to local serv

Postby bhcho » Fri Feb 24, 2012 9:23 pm

Code: Select all
    In [1]: from omero.gateway import BlitzGateway
    In [2]: remote_conn = BlitzGateway(client_obj=client) # For testing only
    In [3]: local_conn = BlitzGateway(client_obj=client) # For testing only
    In [4]: import omero
    In [5]: orig_file = omero.model.OriginalFileI(4453, False)
    In [7]: remote_conn.c.download(orig_file, filename="/tmp/4453")
    In [8]: local_conn.c.upload(filename="/tmp/4453", type="OMERO.tables")

from above, what is '4453'? Can I use my 'fid' of the table instead of 4453 in line 5?
what does the line 5 actually do? (it seems like it creates an empty file forcing its id as 4453.)
then line 7 download the orig_file into local server in a directory /tmp filename as 4453.
line 8 looks upload the file as OMERO.tables.

BK
bhcho
 
Posts: 236
Joined: Mon Apr 05, 2010 2:15 pm

Re: download/save OMERO.table file from remote/to local serv

Postby jmoore » Sat Feb 25, 2012 8:24 pm

bhcho wrote:from above, what is '4453'? Can I use my 'fid' of the table instead of 4453 in line 5?


Yes, of course. 4453 is just the fid that I was testing.

what does the line 5 actually do? (it seems like it creates an empty file forcing its id as 4453.)


Correct since the API requires passing an original file object, I created one for fid==4453.

then line 7 download the orig_file into local server in a directory /tmp filename as 4453.
line 8 looks upload the file as OMERO.tables.


Correct.

Cheers,
~Josh
User avatar
jmoore
Team Member
 
Posts: 1011
Joined: Fri May 22, 2009 1:29 pm
Location: Germany

Re: download/save OMERO.table file from remote/to local serv

Postby bhcho » Sat Feb 25, 2012 10:46 pm

So, given my file's ID, can I do the following for downloading it from remote and uploading it on the local server?
Code: Select all
fid = result.getId().getValue()
file_remote = conn_remote.getObject("OriginalFile", fid)
remote_conn.c.download(file_remote , filename="/tmp/FileFromRemoteServer.h5")
local_conn.c.upload(filename="/tmp/FileFromRemoteServer.h5", type="OMERO.tables")


Best,
BK
bhcho
 
Posts: 236
Joined: Mon Apr 05, 2010 2:15 pm

Re: download/save OMERO.table file from remote/to local serv

Postby jmoore » Sun Feb 26, 2012 5:16 pm

Assuming "result" is an OriginalFile, yes, but if the result object is already loaded then the first two lines can be omitted, i.e.:
Code: Select all
remote_conn.c.download(result , filename="/tmp/FileFromRemoteServer.h5")
local_conn.c.upload(filename="/tmp/FileFromRemoteServer.h5", type="OMERO.tables")


Just make sure to use a secure temp file name in production.

Cheers,
~Josh
User avatar
jmoore
Team Member
 
Posts: 1011
Joined: Fri May 22, 2009 1:29 pm
Location: Germany

Next

Return to Developer Discussion

Who is online

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

cron