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

Add Python DB API backend #400

Draft
wants to merge 28 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
57491f9
Add .backend.dbapi
khaeru Feb 22, 2021
b829683
Register dbapi in BACKENDS
khaeru Feb 22, 2021
dcdc9a8
Handle dbapi configuration in Config.add_platform()
khaeru Feb 22, 2021
860f794
Add .backend.test_dbapi
khaeru Feb 22, 2021
149087f
Implement DatabaseBackend.init()
khaeru Feb 22, 2021
8503a05
Implement 4 DatabaseBackend methods
khaeru Feb 22, 2021
ebc3b61
Implement DatabaseBackend.item_get_elements()
khaeru Feb 22, 2021
620e593
Implement DatabaseBackend.set_as_default() and .check_out()
khaeru Feb 22, 2021
33bc5bb
Implement DatabaseBackend.set_data()
khaeru Feb 23, 2021
d3f618a
Implement DatabaseBackend.get() and .is_default()
khaeru Feb 23, 2021
2445d7b
Implement DatabaseBackend.run_id()
khaeru Feb 23, 2021
1ca8c89
.base.Backend.has_solution() is optional
khaeru Feb 23, 2021
c7b9303
Add stub for .backend.io.s_write_gdx()
khaeru Feb 23, 2021
5313259
Implement DatabaseBackend.write_file()
khaeru Feb 23, 2021
6250813
Handle existing default in DatabaseBackend.set_as_default()
khaeru Feb 23, 2021
e4ba883
Unpickle data in DatabaseBackend._item_data()
khaeru Feb 23, 2021
6583f7c
Handle scalar equ & var in DatabaseBackend.item_get_elements()
khaeru Feb 23, 2021
7fe63a1
Add (failing) test of Scenario.solve() using DatabaseBackend
khaeru Feb 23, 2021
0f3e556
Implement DatabaseBackend.get_data()
khaeru Apr 6, 2021
7c175f1
Implement DatabaseBackend.{get,set}_geo()
khaeru Apr 6, 2021
a241852
Add solve=True argument to .testing.populate_test_platform()
khaeru Apr 6, 2021
b179226
Implement Platform.{get,set}_meta for parameter handling
khaeru Apr 6, 2021
54c7444
Remove JDBCBackend._validate_meta_args and usage
khaeru Apr 6, 2021
9486865
Temporarily copy test_meta contents into test_dbapi
khaeru Apr 6, 2021
d5c5371
Make query under DatabaseBackend.get() reusable in a private method
khaeru Apr 6, 2021
3665e9d
Partly implement DatabaseBackend.{get,remove,set}_meta()
khaeru Apr 6, 2021
b636869
Add a UNIQUE constraint to annotations table
khaeru Apr 6, 2021
d406b52
Remove placeholder for non-Backend method "delete_meta"
khaeru Apr 6, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions ixmp/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

from ._config import config
from .backend import BACKENDS, ItemType
from .backend.dbapi import DatabaseBackend
from .backend.jdbc import JDBCBackend
from .core import IAMC_IDX, Platform, Scenario, TimeSeries
from .model import MODELS
Expand Down Expand Up @@ -33,6 +34,7 @@
__version__ = "999"

# Register Backends provided by ixmp
BACKENDS["dbapi"] = DatabaseBackend
BACKENDS["jdbc"] = JDBCBackend

# Register Models provided by ixmp
Expand Down
4 changes: 4 additions & 0 deletions ixmp/_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,10 @@ def add_platform(self, name, *args, **kwargs):
"JDBCBackend with driver=hsqldb"
)
assert len(args) == 0
elif cls == "dbapi":
from ixmp.backend.dbapi import DatabaseBackend

info = DatabaseBackend.handle_config(args)
else:
raise ValueError(cls)

Expand Down
4 changes: 2 additions & 2 deletions ixmp/backend/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -766,12 +766,12 @@ def clone(
The cloned Scenario.
"""

@abstractmethod
def has_solution(self, s: Scenario):
"""Return `True` if Scenario *s* has been solved.
"""OPTIONAL: Return `True` if Scenario *s* has been solved.

If :obj:`True`, model solution data is available from the Backend.
"""
raise NotImplementedError

@abstractmethod
def list_items(self, s: Scenario, type):
Expand Down
Loading