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

Disable cdc on output table #2357

Merged
merged 2 commits into from
Jul 30, 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 @@ -18,6 +18,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Use declare_component from base class.
- Use different colors to distinguish logs
- Change all the `_outputs.` to `_outputs__`
- Disable cdc on output tables.


#### New Features & Functionality
Expand Down
1 change: 1 addition & 0 deletions superduper/backends/ibis/data_backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,7 @@ def create_table_and_schema(self, identifier: str, schema: Schema):
t = self.conn.table(identifier)
else:
raise e

return t

def drop(self, force: bool = False):
Expand Down
10 changes: 7 additions & 3 deletions superduper/base/datalayer.py
Original file line number Diff line number Diff line change
Expand Up @@ -338,9 +338,10 @@ def _insert(
inserted_ids = insert.do_execute(self)

cdc_status = s.CFG.cluster.cdc.uri is not None
is_output_table = insert.table.startswith('_outputs__')

if refresh:
if cdc_status:
if cdc_status and not is_output_table:
logging.warn('CDC service is active, skipping model/listener refresh')
else:
return inserted_ids, self.on_event(
Expand Down Expand Up @@ -391,7 +392,9 @@ def on_event(self, query: Query, ids: t.List[str], event_type: str = 'insert'):
identifier = event_data['identifier']
type_id = event_data['type_id']
ids = event_data['ids']
events.extend([Event(type_id, identifier, id, event_type) for id in ids])
events.extend(
[Event(type_id, identifier, str(id), event_type) for id in ids]
)

return self.compute.broadcast(events)

Expand Down Expand Up @@ -437,8 +440,9 @@ def _update(self, update: Query, refresh: bool = True) -> UpdateResult:
updated_ids = update.do_execute(self)

cdc_status = s.CFG.cluster.cdc.uri is not None
is_output_table = update.table.startswith('_outputs__')
if refresh and updated_ids:
if cdc_status:
if cdc_status and not is_output_table:
logging.warn('CDC service is active, skipping model/listener refresh')
else:
# Overwrite should be true since updates could be done on collections
Expand Down
20 changes: 0 additions & 20 deletions superduper/components/vector_index.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import numpy as np
from overrides import override

from superduper import CFG, logging
from superduper.backends.base.query import Query
from superduper.base.datalayer import Datalayer, DBEvent
from superduper.base.document import Document
Expand All @@ -15,7 +14,6 @@
from superduper.ext.utils import str_shape
from superduper.jobs.job import FunctionJob
from superduper.misc.annotations import component
from superduper.misc.server import request_server
from superduper.misc.special_dicts import MongoStyleDict
from superduper.vector_search.base import VectorIndexMeasureType
from superduper.vector_search.update_tasks import copy_vectors, delete_vectors
Expand Down Expand Up @@ -171,30 +169,12 @@ def cleanup(self, db: Datalayer):
db.fast_vector_searchers[self.identifier].drop()
del db.fast_vector_searchers[self.identifier]

@property
def cdc_table(self):
"""Get table for cdc."""
return self.indexing_listener.outputs

@override
def post_create(self, db: "Datalayer") -> None:
"""Post-create hook.

:param db: Data layer instance.
"""
logging.info('Requesting vector index setup on CDC service')
if CFG.cluster.cdc.uri:
logging.info('Sending request to add vector index')
request_server(
service='cdc',
endpoint='component/add',
args={'name': self.identifier, 'type_id': self.type_id},
type='get',
)
else:
logging.info(
'Skipping vector index setup on CDC service since no URI is set'
)
db.compute.queue.declare_component(self)

@property
Expand Down
2 changes: 1 addition & 1 deletion superduper/misc/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ def _request_server(
result = json.loads(response.content)
else:
response = requests.get(url, params=args)
result = None
result = json.loads(response.content)
if response.status_code != 200:
error = json.loads(response.content)
msg = f'Server error at {service} with {response.status_code} :: {error}'
Expand Down
Loading