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 default encoding and add cleanup tools for ibis #2359

Merged
merged 1 commit into from
Jul 31, 2024
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Trigger downstream vector indices.
- Fix vector_index function job.
- Fix verbosity in component info
- Change default encoding to sqlvector

## [0.3.0](https://github.com/superduper-io/superduper/compare/0.3.0...0.2.0]) (2024-Jun-21)

Expand Down
18 changes: 13 additions & 5 deletions superduper/backends/ibis/data_backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,13 @@
import typing as t
from warnings import warn

import click
import ibis
import pandas
from pandas.core.frame import DataFrame
from sqlalchemy.exc import NoSuchTableError

from superduper import CFG
from superduper import CFG, logging
from superduper.backends.base.data_backend import BaseDataBackend
from superduper.backends.base.metadata import MetaDataStoreProxy
from superduper.backends.ibis.db_helper import get_db_helper
Expand Down Expand Up @@ -132,7 +133,10 @@ def insert(self, table_name, raw_documents):

def drop_outputs(self):
"""Drop the outputs."""
raise NotImplementedError
for table in self.conn.list_tables():
logging.info(f"Dropping table: {table}")
if CFG.output_prefix in table:
self.conn.drop_table(table)

def drop_table_or_collection(self, name: str):
"""Drop the table or collection.
Expand Down Expand Up @@ -212,9 +216,13 @@ def drop(self, force: bool = False):

:param force: Whether to force the drop.
"""
raise NotImplementedError(
"Dropping tables needs to be done in each DB natively"
)
if not force and not click.confirm("Are you sure you want to drop all tables?"):
logging.info("Aborting drop tables")
return

for table in self.conn.list_tables():
logging.info(f"Dropping table: {table}")
self.conn.drop_table(table)

def get_table_or_collection(self, identifier):
"""Get a table or collection from the database.
Expand Down
17 changes: 14 additions & 3 deletions superduper/backends/sqlalchemy/metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,9 +142,20 @@ def drop(self, force: bool = False):
default=False,
):
logging.warn('Aborting...')
self.job_table.drop(self.conn)
self.parent_child_association_table.drop(self.conn)
self.component_table.drop(self.conn)
try:
self.job_table.drop(self.conn)
except ProgrammingError as e:
logging.warn(f'Error dropping job table: {e}')

try:
self.parent_child_association_table.drop(self.conn)
except ProgrammingError as e:
logging.warn(f'Error dropping parent-child association table: {e}')

try:
self.component_table.drop(self.conn)
except ProgrammingError as e:
logging.warn(f'Error dropping component table {e}')

@contextmanager
def session_context(self):
Expand Down
2 changes: 1 addition & 1 deletion superduper/components/vector_index.py
Original file line number Diff line number Diff line change
Expand Up @@ -365,7 +365,7 @@ def vector(shape, identifier: t.Optional[str] = None):


@component()
def sqlvector(shape, bytes_encoding: str = 'Bytes'):
def sqlvector(shape, bytes_encoding: t.Optional[str] = None):
"""Create an encoder for a vector (list of ints/ floats) of a given shape.

This is used for compatibility with SQL databases, as the default vector
Expand Down
Loading