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

Fix minor bug in transformers ext #1417

Merged
merged 2 commits into from
Nov 29, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
7 changes: 5 additions & 2 deletions superduperdb/base/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,11 +75,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 @@ -94,7 +96,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
17 changes: 12 additions & 5 deletions superduperdb/base/superduper.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

def superduper(item: t.Optional[t.Any] = None, **kwargs) -> t.Any:
"""
Attempts to automatically wrap an item in a superduperdb container by
Attempts to automatically wrap an item in a superduperdb component by
using duck typing to recognize it.

:param item: A database or model
Expand Down Expand Up @@ -55,7 +55,7 @@ def run(item: t.Any, **kwargs) -> t.Any:
if not dts:
raise ValueError(
f'Couldn\'t auto-identify {item}, please wrap explicitly using '
'``superduperdb.container.*``'
'``superduperdb.components.*``'
)

if len(dts) == 1:
Expand All @@ -75,7 +75,7 @@ def accept(cls, item: t.Any) -> bool:

@classmethod
def create(cls, item: t.Any, **kwargs) -> t.Any:
"""Create a superduperdb container for an item that has already been accepted"""
"""Create a superduperdb component for an item that has already been accepted"""
raise NotImplementedError

_DUCK_TYPES: t.List[t.Type] = []
Expand Down Expand Up @@ -105,9 +105,16 @@ def create(cls, item: t.Any, **kwargs) -> t.Any:
if not isinstance(item, (Database, MockDatabase)):
raise TypeError(f'Expected Database but got {type(item)}')

logging.warn('Note: This is only recommended in development mode')
logging.warn(
'Note: This is only recommended in development mode, since config\
still holds `data_backend` with the default value, services \
like vector search and cdc cannot be reached due to configuration\
mismatch. Services will be configured with a `data_backend` uri using \
config file hence this client config and\
services config will be different.'
)
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