We're Hiring!

Save H5 table on OMERO server (without attaching to anything

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.

Save H5 table on OMERO server (without attaching to anything

Postby bhcho » Mon Nov 21, 2011 6:34 pm

Hi,

I'd like to save a H5 table on OMERO server.

my code for the table is...
Code: Select all
columns = []
columns.append(omero.grid.LongColumn( 'pixels', 'Pixel Index', [] ))
columns.append(omero.grid.LongColumn( 'channel', 'Channel Index', [] ))
columns.append(omero.grid.LongColumn( 'zslice', 'zSlice Index', [] ))
columns.append(omero.grid.LongColumn( 'timepoint', 'Time Point Index', [] ))

resources = session.sharedResources()
table = resources.newTable( 1, 'BK_DB.h5' )
table.initialize(columns)


what I know for a way to save a file onto OMERO server (without attaching it to anything) is
Code: Select all
file_obj = client.upload(DB, type="HDF5/featureDB")

but this method looks like saving a local file ('DB') to OMERO server (instead of OMERO.table object).

1.
Can anyone please tell me how to save an OMERO.table object on OMERO server? (I'm using 4.2.x now and will migrate to 4.3.x soon)
And this table should be able to be retrieved by any OMERO account.

2.
In order to retrieve the saved table, I'd like to use a query by table name and mimetype.
Is this a right way?

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

Re: Save H5 table on OMERO server (without attaching to anyt

Postby wmoore » Tue Nov 22, 2011 10:12 am

Hi BK,

Code: Select all
# get the table as an original file & attach this data to Dataset
orig_file = table.getOriginalFile()
fileAnn = omero.model.FileAnnotationI()
fileAnn.setFile(orig_file)
link = omero.model.DatasetAnnotationLinkI()
link.setParent(omero.model.DatasetI(datasetId, False))
link.setChild(fileAnn)


Whether you can access from any account depends on the permissions and members of the group that you are logged into when you create the table.
You'd want to be in a read-only or 'collaborative'-read-only group.

The code above creates an original file, a file annotation and links this (to a Dataset).
Do you want to attach the table as a file annotation, or just leave it as an original file?

If it's just an Original file, you can use the getObject method of the BlitzGateway
Code: Select all
orig_file = conn.getObject("OriginalFile", attributes={'name': "myFileName.txt", 'mimetype': "text/plain"})
sharedResources.openTable(orig_file._obj)


NB: the getObject method will throw an exception if it finds more than one object matching your query. If it's possible that you're going to get multiple objects back, use getObjects:
Code: Select all
orig_files = conn.getObjects("OriginalFile", attributes={'name': "myFileName.txt", 'mimetype': "text/plain"})
for o in orig_files:
    # handle files


I've updated the examples at http://trac.openmicroscopy.org.uk/ome/w ... MEROtables

Will.
User avatar
wmoore
Team Member
 
Posts: 674
Joined: Mon May 18, 2009 12:46 pm

Re: Save H5 table on OMERO server (without attaching to anyt

Postby bhcho » Tue Nov 22, 2011 3:40 pm

Will,

The method that you told me is attaching it to a particular dataset.
But, I want to save the file on OMERO DB without attaching it to anything.
So I want every account (within read-only or collaborative groups) to be able to read the file (without referring to a specific dataset).

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

Re: Save H5 table on OMERO server (without attaching to anyt

Postby wmoore » Tue Nov 22, 2011 4:36 pm

Then just omit the lines you don't want.
Just do

Code: Select all
orig_file = table.getOriginalFile()
User avatar
wmoore
Team Member
 
Posts: 674
Joined: Mon May 18, 2009 12:46 pm

Re: Save H5 table on OMERO server (without attaching to anyt

Postby bhcho » Tue Nov 22, 2011 9:00 pm

Thank you Will,
It works. I have a follow-up question though.

I tested that the OMERO.table can be readable by other accounts. But it was not possible to update/delete the file by others.
My question is.....Is it possible to make the original file modifiable by other accounts? (it sounds like a bad idea in terms of privacy issue from OMERO server side, though)

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

Re: Save H5 table on OMERO server (without attaching to anyt

Postby jmoore » Wed Nov 23, 2011 8:20 am

Hi BK,

as I've mentioned elsewhere, what you need then is IAdmin.moveToCommonSpace:

In this case, the you'd pass the OriginalFile to moveToCommonSpace:
Code: Select all
import omero
c = omero.client("SERVER")
s = c.createSession("root","ABC")
a = s.getAdminService()
r = s.sharedResources()
t = r.newTable(1, "/test/for-bk.h5")
l = omero.grid.LongColumn(name="l")
t.initialize([l])
o = t.getOriginalFile()
a.moveToCommonSpace([o])
t.getWhereList("l==1", {}, 0, 0, 0)
t.close()
c.closeSession()

s = c.createSession("USER", "XXX")
r = s.sharedResources()
t = r.openTable(o)
t.getWhereList("l==1", {}, 0, 0, 0)
t.close()
c.closeSession()

Cheers,
~Josh
User avatar
jmoore
Site Admin
 
Posts: 1591
Joined: Fri May 22, 2009 1:29 pm
Location: Germany

Re: Save H5 table on OMERO server (without attaching to anyt

Postby bhcho » Wed Nov 23, 2011 4:05 pm

Hi Josh,

1.
what is "t.getWhereList("l==1", {}, 0, 0, 0)" doing?

2.
I firstly initialized a table by admin account. here's my test script.
Code: Select all
In [15]: client = pslid.utilities.connect( server, port )
In [16]: session = pslid.utilities.login( client, 'admin', 'secret' )
In [17]: adminservice=session.getAdminService()
In [18]: resource = session.sharedResources()
In [19]: columns = []
In [20]: columns.append(omero.grid.LongColumn( 'pixels', 'Pixel Index', [] ))
In [21]: columns.append(omero.grid.LongColumn( 'channel', 'Channel Index', [] ))
In [22]: columns.append(omero.grid.LongColumn( 'zslice', 'zSlice Index', [] ))
In [23]: columns.append(omero.grid.LongColumn( 'timepoint', 'Time Point Index', [] ))
In [25]: table = resource.newTable( 1, 'BK_DB_test.h5' )
In [26]: table.initialize(columns)
In [27]: original_file = table.getOriginalFile()
In [28]: adminservice.moveToCommonSpace([original_file])
In [30]: table.getWhereList("columns==zslice",{},0,0,0)
Out[30]: []
In [31]: table.close()
In [32]: client.closeSession()


Then, I failed to modify the file by other account.
Code: Select all
In [12]: client = pslid.utilities.connect( server, port )
In [13]: session = pslid.utilities.login( client, 'USER', 'XXXX' )
In [14]: query = session.getQueryService()
In [15]: DBfilename="BK_DB_test.h5"
In [16]: params = omero.sys.ParametersI()
In [17]: params.addString( "filename", DBfilename );
In [18]: params.addString( "mimetype", 'OMERO.tables' );
In [22]: query_string = "select f from OriginalFile f where f.name=:filename and f.mimetype=:mimetype"
In [23]: result = query.findAllByQuery(query_string, params)
In [24]: len(result)
Out[24]: 1
In [25]: fid = result[0].getId().getValue()
In [27]: resources = session.sharedResources()
In [28]: table = resources.openTable( omero.model.OriginalFileI( fid, False ) )
In [31]: columns = []
In [32]: columns.append(omero.grid.LongColumn( 'pixels', 'Pixel Index', [] ))
In [33]: columns.append(omero.grid.LongColumn( 'channel', 'Channel Index', [] ))
In [34]: columns.append(omero.grid.LongColumn( 'zslice', 'zSlice Index', [] ))
In [35]: columns.append(omero.grid.LongColumn( 'timepoint', 'Time Point Index', [] ))
In [36]:
In [37]: columns[0].values.append( long(10) )
In [38]: columns[1].values.append( long(20) )
In [39]: columns[2].values.append( long(30) )
In [40]: columns[3].values.append( long(40) )
In [41]: table.addData(columns)
---------------------------------------------------------------------------
SecurityViolation                         Traceback (most recent call last)

/usr0/local/omero.server/OMERO.server-Beta-4.2.1/<ipython console> in <module>()

/usr0/local/omero.server/OMERO.server-Beta-4.2.1/lib/python/omero_Tables_ice.pyc in addData(self, cols, _ctx)
    665
    666         def addData(self, cols, _ctx=None):
--> 667             return _M_omero.grid.Table._op_addData.invoke(self, ((cols, ), _ctx))
    668
    669         def addData_async(self, _cb, cols, _ctx=None):

SecurityViolation: exception ::omero::SecurityViolation
{
    serverStackTrace = Current user cannot write to file 40054
    serverExceptionClass =
    message =
}

Could you tell me what I'm doing wrong?

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

Re: Save H5 table on OMERO server (without attaching to anyt

Postby jmoore » Wed Nov 23, 2011 7:47 pm

bhcho wrote:1.
what is "t.getWhereList("l==1", {}, 0, 0, 0)" doing?


Just running a query to show that the file can be accessed.

Then, I failed to modify the file by other account.
...
Code: Select all
SecurityViolation: exception ::omero::SecurityViolation
{
    serverStackTrace = Current user cannot write to file 40054
    serverExceptionClass =
    message =
}

Could you tell me what I'm doing wrong?

Thanks again,
BK


Sorry, but I didn't realize you wanted to modify the file from the other account. That's certainly not a use-case we support at the moment ("world-writeable data").

~Josh.
User avatar
jmoore
Site Admin
 
Posts: 1591
Joined: Fri May 22, 2009 1:29 pm
Location: Germany

Re: Save H5 table on OMERO server (without attaching to anyt

Postby bhcho » Wed Nov 30, 2011 6:32 pm

Josh,

That's certainly not a use-case we support at the moment ("world-writeable data").

Does this also mean that I cannot have a "world-writable" annotation, tag, or anything?
I'm looking for a method that every account can modify/read a text value (,which is the name of a file and should be updated often by everyone).

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

Re: Save H5 table on OMERO server (without attaching to anyt

Postby jmoore » Mon Dec 05, 2011 2:53 pm

Correct, there is currently no world-writable setting anywhere in the system. The only thing I can think of which you could possibly do (with no changes, right now) is to use a share which every user is made a member of and the last added comment is the textValue you're referring to, but even this isn't very user-friendly.

~J.
User avatar
jmoore
Site Admin
 
Posts: 1591
Joined: Fri May 22, 2009 1:29 pm
Location: Germany

Next

Return to Developer Discussion

Who is online

Users browsing this forum: No registered users and 0 guests