Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
khaeru opened this issue Jan 15, 2020 · 1 comment
Open

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

khaeru opened this issue Jan 15, 2020 · 1 comment
Labels
enh New features & functionality help welcome

Comments

@khaeru
Copy link
Member

khaeru commented Jan 15, 2020

@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'.

ixmp/ixmp/core.py

Lines 61 to 72 in c2e8929

def __init__(self, *args, name=None, backend=None, **backend_args):
if name is None:
if backend is None and not len(backend_args):
# No arguments given: use the default platform config
name = 'default'
elif backend is None:
# Only backend_args given
log.info('Using default JDBC backend')
kwargs = {'class': 'jdbc'}
else:
# Backend and maybe backend_args were given
kwargs = {'class': backend}

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

@khaeru khaeru added enh New features & functionality help welcome labels Jan 15, 2020
@khaeru
Copy link
Member Author

khaeru commented Jan 15, 2020

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enh New features & functionality help welcome
Projects
None yet
Development

No branches or pull requests

1 participant