Skip to content

Commit

Permalink
Add databackend option in
Browse files Browse the repository at this point in the history
  • Loading branch information
kartik4949 committed Nov 28, 2023
1 parent e3c12d1 commit d6f30ae
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
7 changes: 5 additions & 2 deletions superduperdb/base/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,11 +68,13 @@ def build_compute(cfg):
return LocalComputeBackend()


def build_datalayer(cfg=None, **kwargs) -> Datalayer:
def build_datalayer(cfg=None, databackend=None, **kwargs) -> Datalayer:
"""
Build a Datalayer object as per ``db = superduper(db)`` from configuration.
:param cfg: Configuration to use. If None, use ``superduperdb.CFG``.
:param databackend: Databacked to use.
If None, use ``superduperdb.CFG.data_backend``.
"""

# Configuration
Expand All @@ -87,7 +89,8 @@ def build_datalayer(cfg=None, **kwargs) -> Datalayer:
# Connect to data backend.
# ------------------------------
try:
databackend = build(cfg.data_backend, data_backends)
if not databackend:
databackend = build(cfg.data_backend, data_backends)
logging.info("Data Client is ready.", databackend.conn)
except Exception as e:
# Exit quickly if a connection fails.
Expand Down
2 changes: 1 addition & 1 deletion superduperdb/base/superduper.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ def create(cls, item: t.Any, **kwargs) -> t.Any:

logging.warn('Note: This is only recommended in development mode')
databackend = MongoDataBackend(conn=item.client, name=item.name)
return build_datalayer(cfg=CFG, data_backend=databackend, **kwargs)
return build_datalayer(cfg=CFG, databackend=databackend, **kwargs)


class SklearnTyper(_DuckTyper):
Expand Down

0 comments on commit d6f30ae

Please sign in to comment.