ixmp icon indicating copy to clipboard operation
ixmp copied to clipboard

Platform.__init__() with backend_args= but without name=

Open khaeru opened this issue 5 years ago • 1 comments

@behnam-zakeri reports trying the following:

import ixmp
ixmp.Platform(jvmargs=['-Xfoo'])

The intent is to load the default platform (i.e. to imply name='default'), and then pass the jvmargs to JDBCBackend.

However, this currently fails, because the second branch of this inner if statement is activated, not the first. So name='default' is not inferred; only backend='jdbc'. https://github.com/iiasa/ixmp/blob/c2e892911280c18030a48fc75997521d4701056c/ixmp/core.py#L61-L72

Behnam says it would be desirable to support the example code above.

khaeru avatar Jan 15 '20 10:01 khaeru

The code was written to support usage like:

ixmp.Platform(driver='hsqldb', path='/path/to/database')

…in this case, name is None, backend is None, and len(backend_args) > 0. To make this enhancement, the last condition is the tricky one: sometimes giving backend_args means "use the default JDBCBackend", and at other times it means "use the default Platform config"; it's difficult for Platform.init to guess which is which.

Will ponder…suggestions welcome.

khaeru avatar Jan 15 '20 10:01 khaeru