Page 1 of 2

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

PostPosted: Mon Feb 13, 2012 8:16 pm
by bhcho
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

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

PostPosted: Mon Feb 13, 2012 10:45 pm
by jmoore
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

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

PostPosted: Mon Feb 13, 2012 11:26 pm
by bhcho
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

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

PostPosted: Tue Feb 14, 2012 11:59 pm
by jmoore
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

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

PostPosted: Wed Feb 15, 2012 12:20 am
by bhcho
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

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

PostPosted: Wed Feb 15, 2012 7:33 am
by jmoore
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

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

PostPosted: Fri Feb 24, 2012 9:23 pm
by bhcho
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

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

PostPosted: Sat Feb 25, 2012 8:24 pm
by jmoore
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

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

PostPosted: Sat Feb 25, 2012 10:46 pm
by bhcho
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

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

PostPosted: Sun Feb 26, 2012 5:16 pm
by jmoore
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