rbc icon indicating copy to clipboard operation
rbc copied to clipboard

FR: RemoteOmnisci connect using session_id

Open mikehinchey opened this issue 4 years ago • 2 comments

Feature request: I'd like to connect to RemoteOmnisci using an existing pyomnisci or omniscidb-ibis connection.

The following works now:

    si = con.con._client.get_session_info(con.con._session)
    c = RemoteOmnisci(
        user=si.user,
        host=con.host,
        port=con.port,
        dbname=si.database)
    c._session_id = con.con._session

Can we provide an option to make this easier for the user by adding a param for session_id? Is it enough to just set the c.__session_id, or is there value in the __init__ calling get_session_info for the other values?

    c = RemoteOmnisci(session_id=con.con._session)

https://github.com/xnd-project/rbc/blob/9dfc0ee038dbd2ebcce66e478d67ab04eaac0b1a/rbc/omniscidb.py#L221

mikehinchey avatar Feb 12 '21 17:02 mikehinchey

Hi @mikehinchey, we plan to support this in the next release of RBC (v0.6.0). See https://github.com/xnd-project/rbc/issues/180

guilhermeleobas avatar Feb 12 '21 17:02 guilhermeleobas

@mikehinchey , the same hook is implemented in pyomniscidb, see https://github.com/omnisci/omniscidb-internal/blob/master/python/omnisci/connection.py#L397-L406 So, instead of using RemoteOmnisci instance for defining UDF/UDTFs, you can use pyomniscidb Connection instance as well.

However, I think pyomniscidb and rbc should communicate the connection information a little better as the RemoteOmnisci may implement features that would be awkward to access from the Connection instance (one should use con._rbc the first call to Connection.__call__).

It looks like sessionid is sufficient to reuse a connection either from RemoteOmnisci or Connection instances.

My suggestion is as follows:

  • We'll introduce sessionid keyword argument to RemoteOmnisci constructor. When specified, all other credentials must be None (this is analogous to the behavior implemented in Connection).

As a result, one can do:

c = rbc.omniscidb.RemoteOmnisci(sessionid=con.con.sessionid)

or

con = omnisci.Connection(sessionid=c.sessionid)

pearu avatar Feb 14 '21 20:02 pearu