code stringlengths 66 870k | docstring stringlengths 19 26.7k | func_name stringlengths 1 138 | language stringclasses 1
value | repo stringlengths 7 68 | path stringlengths 5 324 | url stringlengths 46 389 | license stringclasses 7
values |
|---|---|---|---|---|---|---|---|
def do_insert(self, table, documents, raw: bool = False):
"""Insert data into the database.
:param table: The table to insert into.
:param documents: The documents to insert.
:param raw: If ``True``, insert raw documents.
"""
schema = self.get_schema(self.db[table])
... | Insert data into the database.
:param table: The table to insert into.
:param documents: The documents to insert.
:param raw: If ``True``, insert raw documents.
| do_insert | python | superduper-io/superduper | superduper/backends/base/data_backend.py | https://github.com/superduper-io/superduper/blob/master/superduper/backends/base/data_backend.py | Apache-2.0 |
def pre_like(self, query: Query, **kwargs):
"""Perform a pre-like query.
:param query: The query to perform.
:param kwargs: Additional keyword arguments.
"""
assert query.decomposition.pre_like is not None
ids, scores = self.db.select_nearest(
like=query.dec... | Perform a pre-like query.
:param query: The query to perform.
:param kwargs: Additional keyword arguments.
| pre_like | python | superduper-io/superduper | superduper/backends/base/data_backend.py | https://github.com/superduper-io/superduper/blob/master/superduper/backends/base/data_backend.py | Apache-2.0 |
def post_like(self, query: Query, **kwargs):
"""Perform a post-like query.
:param query: The query to perform.
:param kwargs: Additional keyword arguments.
"""
like_part = query[-1]
prepare_query = query[:-1]
relevant_ids = prepare_query.ids()
ids, score... | Perform a post-like query.
:param query: The query to perform.
:param kwargs: Additional keyword arguments.
| post_like | python | superduper-io/superduper | superduper/backends/base/data_backend.py | https://github.com/superduper-io/superduper/blob/master/superduper/backends/base/data_backend.py | Apache-2.0 |
def get_many(self, *pattern: t.Sequence[str]):
"""Get many items from the database.
:param pattern: The pattern to match.
"""
keys = self.keys(*pattern)
if not keys:
return []
else:
return [self[key] for key in keys] | Get many items from the database.
:param pattern: The pattern to match.
| get_many | python | superduper-io/superduper | superduper/backends/base/data_backend.py | https://github.com/superduper-io/superduper/blob/master/superduper/backends/base/data_backend.py | Apache-2.0 |
def delete(self, table, condition):
"""
Delete data from the database.
:param table: The table to delete from.
:param condition: The condition to delete.
"""
r_table = self._get_with_component_identifier('Table', table)
if not r_table['is_component']:
... |
Delete data from the database.
:param table: The table to delete from.
:param condition: The condition to delete.
| delete | python | superduper-io/superduper | superduper/backends/base/data_backend.py | https://github.com/superduper-io/superduper/blob/master/superduper/backends/base/data_backend.py | Apache-2.0 |
def list_tables(self):
"""List all tables in the database."""
keys = self.keys('*', '*', '*') + self.keys('*', '*')
return sorted(list(set(k[0] for k in keys))) | List all tables in the database. | list_tables | python | superduper-io/superduper | superduper/backends/base/data_backend.py | https://github.com/superduper-io/superduper/blob/master/superduper/backends/base/data_backend.py | Apache-2.0 |
def keys(self, *pattern) -> t.List[t.Tuple[str, str, str]]:
"""Get the keys from the cache.
:param pattern: The pattern to match.
>>> cache.keys('*', '*', '*')
>>> cache.keys('*', '*')
>>> cache.keys('Model', '*', '*')
>>> cache.keys('my_table', '*')
>>> cache.k... | Get the keys from the cache.
:param pattern: The pattern to match.
>>> cache.keys('*', '*', '*')
>>> cache.keys('*', '*')
>>> cache.keys('Model', '*', '*')
>>> cache.keys('my_table', '*')
>>> cache.keys('Model', 'my_model', '*')
>>> cache.keys('*', '*', '1234567... | keys | python | superduper-io/superduper | superduper/backends/base/data_backend.py | https://github.com/superduper-io/superduper/blob/master/superduper/backends/base/data_backend.py | Apache-2.0 |
def _get_with_component(self, component: str):
"""Get all components from the cache of a certain type.
:param component: The component to get.
"""
keys = self.keys(component, '*', '*')
return [self[k] for k in keys] | Get all components from the cache of a certain type.
:param component: The component to get.
| _get_with_component | python | superduper-io/superduper | superduper/backends/base/data_backend.py | https://github.com/superduper-io/superduper/blob/master/superduper/backends/base/data_backend.py | Apache-2.0 |
def _get_all_with_component_identifier(self, component: str, identifier: str):
"""Get a component from the cache with a specific identifier.
:param component: The component to get.
:param identifier: The identifier of the component to
"""
keys = self.keys(component, identifier, ... | Get a component from the cache with a specific identifier.
:param component: The component to get.
:param identifier: The identifier of the component to
| _get_all_with_component_identifier | python | superduper-io/superduper | superduper/backends/base/data_backend.py | https://github.com/superduper-io/superduper/blob/master/superduper/backends/base/data_backend.py | Apache-2.0 |
def _get_with_component_identifier_version(
self, component: str, identifier: str, version: int
):
"""Get a component from the cache with a specific version.
:param component: The component to get.
:param identifier: The identifier of the component to get.
:param version: Th... | Get a component from the cache with a specific version.
:param component: The component to get.
:param identifier: The identifier of the component to get.
:param version: The version of the component to get.
| _get_with_component_identifier_version | python | superduper-io/superduper | superduper/backends/base/data_backend.py | https://github.com/superduper-io/superduper/blob/master/superduper/backends/base/data_backend.py | Apache-2.0 |
def publish(self, events: t.List[Base]):
"""
Publish events to local queue.
:param events: list of events
""" |
Publish events to local queue.
:param events: list of events
| publish | python | superduper-io/superduper | superduper/backends/base/scheduler.py | https://github.com/superduper-io/superduper/blob/master/superduper/backends/base/scheduler.py | Apache-2.0 |
def consume_streaming_events(events, table, db):
"""
Consumer work from streaming events.
Streaming event-types are {'insert', 'update', 'delete'}.
:param events: list of events.
:param table: table on which events were found.
:param db: Datalayer instance.
"""
out = defaultdict(lambda... |
Consumer work from streaming events.
Streaming event-types are {'insert', 'update', 'delete'}.
:param events: list of events.
:param table: table on which events were found.
:param db: Datalayer instance.
| consume_streaming_events | python | superduper-io/superduper | superduper/backends/base/scheduler.py | https://github.com/superduper-io/superduper/blob/master/superduper/backends/base/scheduler.py | Apache-2.0 |
def cluster_events(
events: t.List[Event],
):
"""
Cluster events into table, create and job events.
:param events: List of events to be clustered.
:return: Tuple of table events, create events and job events.
"""
from superduper.base.metadata import Job
table_events = []
create_eve... |
Cluster events into table, create and job events.
:param events: List of events to be clustered.
:return: Tuple of table events, create events and job events.
| cluster_events | python | superduper-io/superduper | superduper/backends/base/scheduler.py | https://github.com/superduper-io/superduper/blob/master/superduper/backends/base/scheduler.py | Apache-2.0 |
def consume_events(
events: t.List[Event],
table: str,
db: 'Datalayer',
batch_size: int | None = None,
):
"""
Consume events from table queue.
:param events: List of events to be consumed.
:param table: Queue Table.
:param db: Datalayer instance.
:param batch_size: Batch size fo... |
Consume events from table queue.
:param events: List of events to be consumed.
:param table: Queue Table.
:param db: Datalayer instance.
:param batch_size: Batch size for processing events.
| consume_events | python | superduper-io/superduper | superduper/backends/base/scheduler.py | https://github.com/superduper-io/superduper/blob/master/superduper/backends/base/scheduler.py | Apache-2.0 |
def find_nearest_from_array(
self,
h: numpy.typing.ArrayLike,
component: str,
vector_index: str,
n: int = 100,
within_ids: t.Sequence[str] = (),
) -> t.Tuple[t.List[str], t.List[float]]:
"""
Find the nearest vectors to the given vector.
:param... |
Find the nearest vectors to the given vector.
:param h: vector.
:param component: component class name.
:param vector_index: vector index identifier.
:param n: number of nearest vectors to return.
:param within_ids: list of ids to search within.
| find_nearest_from_array | python | superduper-io/superduper | superduper/backends/base/vector_search.py | https://github.com/superduper-io/superduper/blob/master/superduper/backends/base/vector_search.py | Apache-2.0 |
def find_nearest_from_id(
self,
id: str,
component: str,
vector_index: str,
n: int = 100,
within_ids: t.Sequence[str] = (),
) -> t.Tuple[t.List[str], t.List[float]]:
"""
Find the nearest vectors to the given vector.
:param id: id of the vector... |
Find the nearest vectors to the given vector.
:param id: id of the vector to search with
:param component: component class name.
:param vector_index: vector index
:param n: number of nearest vectors to return
:param within_ids: list of ids to search within
| find_nearest_from_id | python | superduper-io/superduper | superduper/backends/base/vector_search.py | https://github.com/superduper-io/superduper/blob/master/superduper/backends/base/vector_search.py | Apache-2.0 |
def describe(self, component: str, vector_index: str):
"""Describe the vector index in the backend.
:param component: component class name.
:param vector_index: vector index identifier.
""" | Describe the vector index in the backend.
:param component: component class name.
:param vector_index: vector index identifier.
| describe | python | superduper-io/superduper | superduper/backends/base/vector_search.py | https://github.com/superduper-io/superduper/blob/master/superduper/backends/base/vector_search.py | Apache-2.0 |
def find_nearest_from_array(
self,
h: numpy.typing.ArrayLike,
n: int = 100,
within_ids: t.Sequence[str] = (),
) -> t.Tuple[t.List[str], t.List[float]]:
"""
Find the nearest vectors to the given vector.
:param h: vector
:param n: number of nearest vect... |
Find the nearest vectors to the given vector.
:param h: vector
:param n: number of nearest vectors to return
:param within_ids: list of ids to search within
| find_nearest_from_array | python | superduper-io/superduper | superduper/backends/base/vector_search.py | https://github.com/superduper-io/superduper/blob/master/superduper/backends/base/vector_search.py | Apache-2.0 |
def find_nearest_from_id(
self,
id: str,
n: int = 100,
within_ids: t.Sequence[str] = (),
) -> t.Tuple[t.List[str], t.List[float]]:
"""
Find the nearest vectors to the given vector.
:param id: id of the vector to search with
:param n: number of nearest... |
Find the nearest vectors to the given vector.
:param id: id of the vector to search with
:param n: number of nearest vectors to return
:param within_ids: list of ids to search within
| find_nearest_from_id | python | superduper-io/superduper | superduper/backends/base/vector_search.py | https://github.com/superduper-io/superduper/blob/master/superduper/backends/base/vector_search.py | Apache-2.0 |
def post_create(self):
"""Post create method.
This method is used for searchers which requires
to perform a task after all vectors have been added
""" | Post create method.
This method is used for searchers which requires
to perform a task after all vectors have been added
| post_create | python | superduper-io/superduper | superduper/backends/base/vector_search.py | https://github.com/superduper-io/superduper/blob/master/superduper/backends/base/vector_search.py | Apache-2.0 |
def from_component(cls, index: 'VectorIndex'):
"""Create a vector searcher from a vector index.
:param vi: ``VectorIndex`` instance
"""
return cls(
component=index.component,
identifier=index.uuid,
dimensions=index.dimensions,
measure=inde... | Create a vector searcher from a vector index.
:param vi: ``VectorIndex`` instance
| from_component | python | superduper-io/superduper | superduper/backends/base/vector_search.py | https://github.com/superduper-io/superduper/blob/master/superduper/backends/base/vector_search.py | Apache-2.0 |
def to_numpy(h):
"""Converts a vector to a numpy array.
:param h: vector, numpy.ndarray, or list
"""
if isinstance(h, numpy.ndarray):
return h
if hasattr(h, 'numpy'):
return h.numpy()
if isinstance(h, list):
return numpy.array(h)
... | Converts a vector to a numpy array.
:param h: vector, numpy.ndarray, or list
| to_numpy | python | superduper-io/superduper | superduper/backends/base/vector_search.py | https://github.com/superduper-io/superduper/blob/master/superduper/backends/base/vector_search.py | Apache-2.0 |
def to_list(h):
"""Converts a vector to a list.
:param h: vector
"""
if hasattr(h, 'tolist'):
return h.tolist()
if isinstance(h, list):
return h
raise ValueError(str(h)) | Converts a vector to a list.
:param h: vector
| to_list | python | superduper-io/superduper | superduper/backends/base/vector_search.py | https://github.com/superduper-io/superduper/blob/master/superduper/backends/base/vector_search.py | Apache-2.0 |
def create(
cls,
*,
id: str,
vector: numpy.typing.ArrayLike,
) -> 'VectorItem':
"""Creates a vector item from id and vector.
:param id: ID of the vector
:param vector: Vector of the item
"""
return VectorItem(id=id, vector=BaseVectorSearcher.t... | Creates a vector item from id and vector.
:param id: ID of the vector
:param vector: Vector of the item
| create | python | superduper-io/superduper | superduper/backends/base/vector_search.py | https://github.com/superduper-io/superduper/blob/master/superduper/backends/base/vector_search.py | Apache-2.0 |
def cosine(x, y):
"""Cosine similarity function for vector search.
:param x: numpy.ndarray
:param y: numpy.ndarray, y should be normalized!
"""
x = x / numpy.linalg.norm(x, axis=1)[:, None]
# y which implies all vectors in vectordatabase
# has normalized vectors.
return dot(x, y) | Cosine similarity function for vector search.
:param x: numpy.ndarray
:param y: numpy.ndarray, y should be normalized!
| cosine | python | superduper-io/superduper | superduper/backends/base/vector_search.py | https://github.com/superduper-io/superduper/blob/master/superduper/backends/base/vector_search.py | Apache-2.0 |
def drop(self, component: t.Optional['Component'] = None):
"""Drop the CDC.
:param component: Component to remove.
"""
self.triggers = set()
self._trigger_uuid_mapping = {} | Drop the CDC.
:param component: Component to remove.
| drop | python | superduper-io/superduper | superduper/backends/local/cdc.py | https://github.com/superduper-io/superduper/blob/master/superduper/backends/local/cdc.py | Apache-2.0 |
def drop(self, force: bool = False):
"""Drop the cluster.
:param force: Force drop the cluster.
"""
if not force:
if not click.confirm(
"Are you sure you want to drop the cache? ",
default=False,
):
logging.warn("Ab... | Drop the cluster.
:param force: Force drop the cluster.
| drop | python | superduper-io/superduper | superduper/backends/local/cluster.py | https://github.com/superduper-io/superduper/blob/master/superduper/backends/local/cluster.py | Apache-2.0 |
def release_futures(self, context: str):
"""Release futures for a given context.
:param context: The apply context to release futures for.
"""
try:
del self.futures[context]
except KeyError:
logging.warn(f'Could not release futures for context {context}') | Release futures for a given context.
:param context: The apply context to release futures for.
| release_futures | python | superduper-io/superduper | superduper/backends/local/compute.py | https://github.com/superduper-io/superduper/blob/master/superduper/backends/local/compute.py | Apache-2.0 |
def drop(self):
"""Drop the compute.
:param component: Component to remove.
""" | Drop the compute.
:param component: Component to remove.
| drop | python | superduper-io/superduper | superduper/backends/local/compute.py | https://github.com/superduper-io/superduper/blob/master/superduper/backends/local/compute.py | Apache-2.0 |
def find_nearest_from_array(
self,
h: numpy.typing.ArrayLike,
component: str,
vector_index: str,
n: int = 100,
within_ids: t.Sequence[str] = (),
) -> t.Tuple[t.List[str], t.List[float]]:
"""
Find the nearest vectors to the given vector.
:param... |
Find the nearest vectors to the given vector.
:param vector_index: name of vector-index
:param h: vector
:param n: number of nearest vectors to return
:param within_ids: list of ids to search within
| find_nearest_from_array | python | superduper-io/superduper | superduper/backends/local/vector_search.py | https://github.com/superduper-io/superduper/blob/master/superduper/backends/local/vector_search.py | Apache-2.0 |
def find_nearest_from_id(
self,
id: str,
component: str,
vector_index: str,
n: int = 100,
within_ids: t.Sequence[str] = (),
) -> t.Tuple[t.List[str], t.List[float]]:
"""
Find the nearest vectors to the given vector.
:param vector_index: name o... |
Find the nearest vectors to the given vector.
:param vector_index: name of vector-index
:param id: id of the vector to search with
:param n: number of nearest vectors to return
:param within_ids: list of ids to search within
| find_nearest_from_id | python | superduper-io/superduper | superduper/backends/local/vector_search.py | https://github.com/superduper-io/superduper/blob/master/superduper/backends/local/vector_search.py | Apache-2.0 |
def describe(self):
"""Describe the vector index.
:param component: name of the component
:param vector_index: name of the vector index
"""
return {
'uuid': self.identifier,
'dimensions': self.dimensions,
'measure': self.measure_name,
... | Describe the vector index.
:param component: name of the component
:param vector_index: name of the vector index
| describe | python | superduper-io/superduper | superduper/backends/local/vector_search.py | https://github.com/superduper-io/superduper/blob/master/superduper/backends/local/vector_search.py | Apache-2.0 |
def find_nearest_from_id(self, _id, n=100, within_ids=None):
"""Find the nearest vectors to the given ID.
:param _id: ID of the vector
:param n: number of nearest vectors to return
"""
self.post_create()
return self.find_nearest_from_array(
self.h[self.lookup... | Find the nearest vectors to the given ID.
:param _id: ID of the vector
:param n: number of nearest vectors to return
| find_nearest_from_id | python | superduper-io/superduper | superduper/backends/local/vector_search.py | https://github.com/superduper-io/superduper/blob/master/superduper/backends/local/vector_search.py | Apache-2.0 |
def initialize(self):
"""Initialize the vector index.
:param vector_index: Vector index to initialize
"""
c: VectorIndex = self.db.load(self.component, uuid=self.identifier)
vectors = c.get_vectors()
vectors = [
VectorItem(id=vector['id'], vector=vector['vect... | Initialize the vector index.
:param vector_index: Vector index to initialize
| initialize | python | superduper-io/superduper | superduper/backends/local/vector_search.py | https://github.com/superduper-io/superduper/blob/master/superduper/backends/local/vector_search.py | Apache-2.0 |
def add(self, items: t.Sequence[VectorItem] = (), cache: bool = False) -> None:
"""Add vectors to the index.
Only adds to cache if cache is not full.
:param items: List of vectors to add
:param cache: Flush the cache and add all vectors
"""
if not cache:
ret... | Add vectors to the index.
Only adds to cache if cache is not full.
:param items: List of vectors to add
:param cache: Flush the cache and add all vectors
| add | python | superduper-io/superduper | superduper/backends/local/vector_search.py | https://github.com/superduper-io/superduper/blob/master/superduper/backends/local/vector_search.py | Apache-2.0 |
def post_create(self):
"""Post create method to incorporate remaining vectors to be added in cache."""
if self._cache:
self._add(self._cache)
self._cache = [] | Post create method to incorporate remaining vectors to be added in cache. | post_create | python | superduper-io/superduper | superduper/backends/local/vector_search.py | https://github.com/superduper-io/superduper/blob/master/superduper/backends/local/vector_search.py | Apache-2.0 |
def put_component(self, component: str, uuid: str):
"""Create handler on component declare.
:param component: Component to put.
""" | Create handler on component declare.
:param component: Component to put.
| put_component | python | superduper-io/superduper | superduper/backends/simple/compute.py | https://github.com/superduper-io/superduper/blob/master/superduper/backends/simple/compute.py | Apache-2.0 |
def _start_context_thread(self, context: str):
"""Start a thread for the given context."""
def worker():
with ThreadPoolExecutor() as executor:
while True:
logging.info(f'Waiting for event in context {context}')
event: Job | StopEvent ... | Start a thread for the given context. | _start_context_thread | python | superduper-io/superduper | superduper/backends/simple/compute.py | https://github.com/superduper-io/superduper/blob/master/superduper/backends/simple/compute.py | Apache-2.0 |
def __post_init__(self):
"""Convert vector to list if it's a numpy array."""
if hasattr(self.vector, "tolist"):
self.vector = self.vector.tolist() | Convert vector to list if it's a numpy array. | __post_init__ | python | superduper-io/superduper | superduper/backends/simple/vector_search.py | https://github.com/superduper-io/superduper/blob/master/superduper/backends/simple/vector_search.py | Apache-2.0 |
def add(self, uuid: str, vectors: t.List['VectorItem']):
"""Add vectors to a vector index.
:param uuid: Identifier of index
:param vectors: Vectors to add
:return: Response from the add operation
"""
vectors = [{'id': x.id, 'vector': x.vector.tolist()} for x in vectors]
... | Add vectors to a vector index.
:param uuid: Identifier of index
:param vectors: Vectors to add
:return: Response from the add operation
| add | python | superduper-io/superduper | superduper/backends/simple/vector_search.py | https://github.com/superduper-io/superduper/blob/master/superduper/backends/simple/vector_search.py | Apache-2.0 |
def delete(self, uuid, ids):
"""Delete ids from index.
:param uuid: Identifier of index
:param ids: Ids to delete
:return: Response from the delete operation
"""
response = requests.post(
f'{self.uri}/vector_search/delete',
json={'uuid': uuid, 'id... | Delete ids from index.
:param uuid: Identifier of index
:param ids: Ids to delete
:return: Response from the delete operation
| delete | python | superduper-io/superduper | superduper/backends/simple/vector_search.py | https://github.com/superduper-io/superduper/blob/master/superduper/backends/simple/vector_search.py | Apache-2.0 |
def put_component(self, component: str, uuid: str):
"""Add a component to the vector search service.
:param component: Component to add
:return: Response from the put operation
"""
response = requests.post(
f'{self.uri}/vector_search/put_component?component={componen... | Add a component to the vector search service.
:param component: Component to add
:return: Response from the put operation
| put_component | python | superduper-io/superduper | superduper/backends/simple/vector_search.py | https://github.com/superduper-io/superduper/blob/master/superduper/backends/simple/vector_search.py | Apache-2.0 |
def find_nearest_from_id(
self,
id: str,
component: str,
vector_index: str,
n: int = 100,
within_ids: t.List | None = None,
):
"""Find nearest vectors to a vector with the given id.
:param id: ID of the vector to find nearest neighbors for
:pa... | Find nearest vectors to a vector with the given id.
:param id: ID of the vector to find nearest neighbors for
:param vector_index: Name of the vector index to search
:param n: Number of results to return
:param within_ids: Optional list of IDs to search within
:return: Tuple of ... | find_nearest_from_id | python | superduper-io/superduper | superduper/backends/simple/vector_search.py | https://github.com/superduper-io/superduper/blob/master/superduper/backends/simple/vector_search.py | Apache-2.0 |
def find_nearest_from_array(
self,
h: numpy.typing.ArrayLike,
component: str,
vector_index: str,
n: int = 100,
within_ids: t.List | None = None,
):
"""Find nearest vectors to a given vector array.
:param h: Vector array to find nearest neighbors for
... | Find nearest vectors to a given vector array.
:param h: Vector array to find nearest neighbors for
:param vector_index: Name of the vector index to search
:param n: Number of results to return
:param within_ids: Optional list of IDs to search within
:return: Tuple of (ids, score... | find_nearest_from_array | python | superduper-io/superduper | superduper/backends/simple/vector_search.py | https://github.com/superduper-io/superduper/blob/master/superduper/backends/simple/vector_search.py | Apache-2.0 |
def __init__(self, backend: VectorSearchBackend, *args, **kwargs):
"""Initialize the VectorSearch service.
:param backend: Vector search backend implementation
:param args: Additional arguments passed to parent constructor
:param kwargs: Additional keyword arguments passed to parent con... | Initialize the VectorSearch service.
:param backend: Vector search backend implementation
:param args: Additional arguments passed to parent constructor
:param kwargs: Additional keyword arguments passed to parent constructor
| __init__ | python | superduper-io/superduper | superduper/backends/simple/vector_search.py | https://github.com/superduper-io/superduper/blob/master/superduper/backends/simple/vector_search.py | Apache-2.0 |
def db(self, db):
"""Set the database instance for both this service and the backend.
:param db: Database instance to set
"""
self._db = db
self.backend.db = db | Set the database instance for both this service and the backend.
:param db: Database instance to set
| db | python | superduper-io/superduper | superduper/backends/simple/vector_search.py | https://github.com/superduper-io/superduper/blob/master/superduper/backends/simple/vector_search.py | Apache-2.0 |
def find_nearest_from_id(
self,
id: str,
vector_index: str,
n: int = 100,
within_ids: t.List | None = None,
component: str = 'VectorIndex',
):
"""Query the vector index with an ID.
:param id: ID to query
:param vector_index: Vector index to qu... | Query the vector index with an ID.
:param id: ID to query
:param vector_index: Vector index to query
:param n: Number of results to return
:param within_ids: Optional list of IDs to search within
:param component: Component type
:return: Dictionary with ids and scores of... | find_nearest_from_id | python | superduper-io/superduper | superduper/backends/simple/vector_search.py | https://github.com/superduper-io/superduper/blob/master/superduper/backends/simple/vector_search.py | Apache-2.0 |
def find_nearest_from_array(
self,
h: t.List,
vector_index: str,
n: int = 100,
within_ids: t.List | None = None,
component: str = 'VectorIndex',
):
"""Query the vector index with a vector.
:param h: Vector to query
:param vector_index: Vector ... | Query the vector index with a vector.
:param h: Vector to query
:param vector_index: Vector index to query
:param n: Number of results to return
:param within_ids: Optional list of IDs to search within
:param component: Component type
:return: Dictionary with ids and sco... | find_nearest_from_array | python | superduper-io/superduper | superduper/backends/simple/vector_search.py | https://github.com/superduper-io/superduper/blob/master/superduper/backends/simple/vector_search.py | Apache-2.0 |
def put_component(self, component: str, uuid: str):
"""Create a vector index.
:param component: Vector index component to create
:param uuid: UUID of the component
"""
logging.info(
f"Putting vector index {component}/{uuid} on vector-search "
f"backend {s... | Create a vector index.
:param component: Vector index component to create
:param uuid: UUID of the component
| put_component | python | superduper-io/superduper | superduper/backends/simple/vector_search.py | https://github.com/superduper-io/superduper/blob/master/superduper/backends/simple/vector_search.py | Apache-2.0 |
def build(self, app):
"""Set up FastAPI routes for this service.
:param app: FastAPI application to set routes on
"""
@app.post("/vector_search/initialize")
def initialize():
"""Initialize the vector search service.
:return: Status response
... | Set up FastAPI routes for this service.
:param app: FastAPI application to set routes on
| build | python | superduper-io/superduper | superduper/backends/simple/vector_search.py | https://github.com/superduper-io/superduper/blob/master/superduper/backends/simple/vector_search.py | Apache-2.0 |
def initialize():
"""Initialize the vector search service.
:return: Status response
"""
self.initialize()
return {"status": "ok"} | Initialize the vector search service.
:return: Status response
| initialize | python | superduper-io/superduper | superduper/backends/simple/vector_search.py | https://github.com/superduper-io/superduper/blob/master/superduper/backends/simple/vector_search.py | Apache-2.0 |
def drop():
"""Remove all components from the vector search service.
:return: Status response
"""
self.backend.drop()
return {"status": "ok"} | Remove all components from the vector search service.
:return: Status response
| drop | python | superduper-io/superduper | superduper/backends/simple/vector_search.py | https://github.com/superduper-io/superduper/blob/master/superduper/backends/simple/vector_search.py | Apache-2.0 |
def drop_component(component: str, identifier: str):
"""Remove a specific component from the vector search service.
:param component: Component type
:param identifier: Component identifier
:return: Status response
"""
self.backend.drop_component(c... | Remove a specific component from the vector search service.
:param component: Component type
:param identifier: Component identifier
:return: Status response
| drop_component | python | superduper-io/superduper | superduper/backends/simple/vector_search.py | https://github.com/superduper-io/superduper/blob/master/superduper/backends/simple/vector_search.py | Apache-2.0 |
def put_component(component: str, uuid: str):
"""Add a component to the vector search service.
:param component: Component type
:param uuid: Component UUID
:return: Status response
:raises AssertionError: If component is not a VectorIndex
"""
... | Add a component to the vector search service.
:param component: Component type
:param uuid: Component UUID
:return: Status response
:raises AssertionError: If component is not a VectorIndex
| put_component | python | superduper-io/superduper | superduper/backends/simple/vector_search.py | https://github.com/superduper-io/superduper/blob/master/superduper/backends/simple/vector_search.py | Apache-2.0 |
def trigger(
*event_types: t.Sequence[str],
depends: t.Sequence[str] | str = (),
requires: t.Sequence[str] | str = (),
outputs: str | None = None,
):
"""Decorator to trigger a method when an event is detected.
:param event_types: Event to trigger the method.
:param depends: Triggers which s... | Decorator to trigger a method when an event is detected.
:param event_types: Event to trigger the method.
:param depends: Triggers which should run before this method.
:param requires: Dataclass parameters/ attributes which should be
available to trigger the method
:param outputs: ... | trigger | python | superduper-io/superduper | superduper/base/annotations.py | https://github.com/superduper-io/superduper/blob/master/superduper/base/annotations.py | Apache-2.0 |
def decorator(f):
"""Decorator to trigger a method when an event of type."""
takes_ids = 'ids' in inspect.signature(f).parameters
if event_types != ('apply',):
assert takes_ids, (
f"Method {f.__name__} must take an 'ids' argument"
" to be triggered by... | Decorator to trigger a method when an event of type. | decorator | python | superduper-io/superduper | superduper/base/annotations.py | https://github.com/superduper-io/superduper/blob/master/superduper/base/annotations.py | Apache-2.0 |
def apply(
db: 'Datalayer',
object: t.Union['Component', t.Sequence[t.Any], t.Any],
force: bool | None = None,
wait: bool = False,
jobs: bool = True,
) -> 'Component':
"""
Add functionality in the form of components.
Components are stored in the configured artifact store
and linked ... |
Add functionality in the form of components.
Components are stored in the configured artifact store
and linked to the primary database through metadata.
:param db: Datalayer instance
:param object: Object to be stored.
:param force: List of jobs which should execute before component
... | apply | python | superduper-io/superduper | superduper/base/apply.py | https://github.com/superduper-io/superduper/blob/master/superduper/base/apply.py | Apache-2.0 |
def _delete_bytes(self, file_id: str):
"""Delete artifact from artifact store.
:param file_id: File id uses to identify artifact in store
""" | Delete artifact from artifact store.
:param file_id: File id uses to identify artifact in store
| _delete_bytes | python | superduper-io/superduper | superduper/base/artifacts.py | https://github.com/superduper-io/superduper/blob/master/superduper/base/artifacts.py | Apache-2.0 |
def save_artifact(self, r: t.Dict):
"""Save serialized object in the artifact store.
:param r: dictionary with mandatory fields
"""
blobs = r.get(KEY_BLOBS, {})
files = r.get(KEY_FILES, {})
for file_id, blob in blobs.items():
if blob is None:
... | Save serialized object in the artifact store.
:param r: dictionary with mandatory fields
| save_artifact | python | superduper-io/superduper | superduper/base/artifacts.py | https://github.com/superduper-io/superduper/blob/master/superduper/base/artifacts.py | Apache-2.0 |
def delete_artifact(self, artifact_ids: t.List[str]):
"""Delete artifact from artifact store.
:param artifact_ids: list of artifact ids to delete.
"""
for artifact_id in artifact_ids:
try:
self._delete_bytes(artifact_id)
except FileNotFoundError:
... | Delete artifact from artifact store.
:param artifact_ids: list of artifact ids to delete.
| delete_artifact | python | superduper-io/superduper | superduper/base/artifacts.py | https://github.com/superduper-io/superduper/blob/master/superduper/base/artifacts.py | Apache-2.0 |
def drop(self, force: bool = False):
"""Drop the artifact store.
Please use with caution as this will delete all data in the artifact store.
:param force: Whether to force the drop.
"""
if not force:
if not click.confirm(
'!!!WARNING USE WITH CAUTION... | Drop the artifact store.
Please use with caution as this will delete all data in the artifact store.
:param force: Whether to force the drop.
| drop | python | superduper-io/superduper | superduper/base/artifacts.py | https://github.com/superduper-io/superduper/blob/master/superduper/base/artifacts.py | Apache-2.0 |
def put_bytes(
self,
serialized: bytes,
file_id: str,
) -> t.Any:
"""
Save bytes in artifact store.
:param serialized: The bytes to be saved.
:param file_id: The id of the file.
"""
path = os.path.join(self.blobs, file_id)
if os.path.e... |
Save bytes in artifact store.
:param serialized: The bytes to be saved.
:param file_id: The id of the file.
| put_bytes | python | superduper-io/superduper | superduper/base/artifacts.py | https://github.com/superduper-io/superduper/blob/master/superduper/base/artifacts.py | Apache-2.0 |
def put_file(self, file_path: str, file_id: str):
"""Save file in artifact store and return the relative path.
return the relative path {file_id}/{name}
:param file_path: The path to the file to be saved.
:param file_id: The id of the file.
"""
path = Path(file_path)
... | Save file in artifact store and return the relative path.
return the relative path {file_id}/{name}
:param file_path: The path to the file to be saved.
:param file_id: The id of the file.
| put_file | python | superduper-io/superduper | superduper/base/artifacts.py | https://github.com/superduper-io/superduper/blob/master/superduper/base/artifacts.py | Apache-2.0 |
def get_file(self, file_id: str) -> str:
"""Return the path to the file in the artifact store.
:param file_id: The id of the file.
"""
logging.debug(f"Loading file {file_id} from {self.files}")
path = os.path.join(self.files, file_id)
files = os.listdir(path)
ass... | Return the path to the file in the artifact store.
:param file_id: The id of the file.
| get_file | python | superduper-io/superduper | superduper/base/artifacts.py | https://github.com/superduper-io/superduper/blob/master/superduper/base/artifacts.py | Apache-2.0 |
def __new__(mcs, name, bases, namespace):
"""Create a new class with merged docstrings # noqa."""
# Prepare namespace by extracting annotations and handling fields
annotations = namespace.get('__annotations__', {})
for k, v in list(namespace.items()):
if isinstance(v, (type, ... | Create a new class with merged docstrings # noqa. | __new__ | python | superduper-io/superduper | superduper/base/base.py | https://github.com/superduper-io/superduper/blob/master/superduper/base/base.py | Apache-2.0 |
def _new_fields(cls):
"""Get the schema of the class."""
from superduper.misc.schema import get_schema
s = get_schema(cls)[0]
return s | Get the schema of the class. | _new_fields | python | superduper-io/superduper | superduper/base/base.py | https://github.com/superduper-io/superduper/blob/master/superduper/base/base.py | Apache-2.0 |
def get_cls_from_path(path):
"""Get class from a path.
:param path: Import path to the class.
"""
parts = path.split('.')
cls = parts[-1]
module = '.'.join(parts[:-1])
module = importlib.import_module(module)
return getattr(module, cls) | Get class from a path.
:param path: Import path to the class.
| get_cls_from_path | python | superduper-io/superduper | superduper/base/base.py | https://github.com/superduper-io/superduper/blob/master/superduper/base/base.py | Apache-2.0 |
def get_cls_from_blob(blob_ref, db):
"""Get class from a blob reference.
:param blob_ref: Blob reference identifier.
:param db: Datalayer instance.
"""
from superduper.base.datatype import DEFAULT_SERIALIZER, Blob
bytes_ = Blob(identifier=blob_ref.split(':')[-1], db=db)... | Get class from a blob reference.
:param blob_ref: Blob reference identifier.
:param db: Datalayer instance.
| get_cls_from_blob | python | superduper-io/superduper | superduper/base/base.py | https://github.com/superduper-io/superduper/blob/master/superduper/base/base.py | Apache-2.0 |
def reconnect(self, db):
"""Reconnect the object to a new datalayer.
:param db: Datalayer instance.
"""
r = self.dict()
if '_path' in r:
r.pop('_path')
return self.from_dict(r, db=db) | Reconnect the object to a new datalayer.
:param db: Datalayer instance.
| reconnect | python | superduper-io/superduper | superduper/base/base.py | https://github.com/superduper-io/superduper/blob/master/superduper/base/base.py | Apache-2.0 |
def pydantic(cls):
"""Get the Pydantic model of the class."""
from .schema import create_pydantic
return create_pydantic(name=cls.__name__, schema=cls.class_schema) | Get the Pydantic model of the class. | pydantic | python | superduper-io/superduper | superduper/base/base.py | https://github.com/superduper-io/superduper/blob/master/superduper/base/base.py | Apache-2.0 |
def source_code(cls):
"""Get the source code of the class."""
import inspect
try:
return inspect.getsource(cls)
except OSError:
from superduper import logging
logging.warn(
f"Could not get source code for {cls.__name__} from {cls.__mo... | Get the source code of the class. | source_code | python | superduper-io/superduper | superduper/base/base.py | https://github.com/superduper-io/superduper/blob/master/superduper/base/base.py | Apache-2.0 |
def leaves(self):
"""Get all leaves in the object."""
return {
f.name: getattr(self, f.name)
for f in dc.fields(self)
if isinstance(getattr(self, f.name), Base)
} | Get all leaves in the object. | leaves | python | superduper-io/superduper | superduper/base/base.py | https://github.com/superduper-io/superduper/blob/master/superduper/base/base.py | Apache-2.0 |
def cls_encode(cls, item: 'Base', builds, blobs, files, leaves_to_keep=()):
"""Encode a dictionary component into a `Component` instance.
:param r: Object to be encoded.
"""
return item.encode(
builds=builds, blobs=blobs, files=files, leaves_to_keep=leaves_to_keep
) | Encode a dictionary component into a `Component` instance.
:param r: Object to be encoded.
| cls_encode | python | superduper-io/superduper | superduper/base/base.py | https://github.com/superduper-io/superduper/blob/master/superduper/base/base.py | Apache-2.0 |
def decode(cls, r, db: t.Optional['Datalayer'] = None):
"""Decode a dictionary component into a `Component` instance.
:param r: Object to be decoded.
:param db: Datalayer instance.
"""
from superduper.base.document import Document
if '_path' in r:
from super... | Decode a dictionary component into a `Component` instance.
:param r: Object to be decoded.
:param db: Datalayer instance.
| decode | python | superduper-io/superduper | superduper/base/base.py | https://github.com/superduper-io/superduper/blob/master/superduper/base/base.py | Apache-2.0 |
def encode(
self,
context: t.Optional['EncodeContext'] = None,
**kwargs,
):
"""Encode itself.
After encoding everything is a vanilla dictionary (JSON + bytes).
:param context: Encoding context.
:param kwargs: Additional encoding parameters.
"""
... | Encode itself.
After encoding everything is a vanilla dictionary (JSON + bytes).
:param context: Encoding context.
:param kwargs: Additional encoding parameters.
| encode | python | superduper-io/superduper | superduper/base/base.py | https://github.com/superduper-io/superduper/blob/master/superduper/base/base.py | Apache-2.0 |
def set_variables(self, db: t.Union['Datalayer', None] = None, **kwargs) -> 'Base':
"""Set free variables of self.
:param db: Datalayer instance.
:param kwargs: Keyword arguments to pass to `_replace_variables`.
"""
from superduper import Document
from superduper.base.va... | Set free variables of self.
:param db: Datalayer instance.
:param kwargs: Keyword arguments to pass to `_replace_variables`.
| set_variables | python | superduper-io/superduper | superduper/base/base.py | https://github.com/superduper-io/superduper/blob/master/superduper/base/base.py | Apache-2.0 |
def dict(self, metadata: bool = True) -> t.Dict[str, t.Any]:
"""Return dictionary representation of the object.
:param metadata: Whether to include metadata in the dictionary.
"""
from superduper import Document
r = asdict(self)
r['_path'] = self.__class__.__module__ + ... | Return dictionary representation of the object.
:param metadata: Whether to include metadata in the dictionary.
| dict | python | superduper-io/superduper | superduper/base/base.py | https://github.com/superduper-io/superduper/blob/master/superduper/base/base.py | Apache-2.0 |
def build(cls, r):
"""Build object from an encoded data.
:param r: Encoded data.
"""
signature_params = inspect.signature(cls.__init__).parameters
modified = {k: v for k, v in r.items() if k in signature_params}
return cls(**modified) | Build object from an encoded data.
:param r: Encoded data.
| build | python | superduper-io/superduper | superduper/base/base.py | https://github.com/superduper-io/superduper/blob/master/superduper/base/base.py | Apache-2.0 |
def match(cls, uri):
"""Check if the uri matches the pattern."""
plugin, flavour = None, None
for pattern in cls.patterns:
if re.match(pattern, uri) is not None:
selection = cls.patterns[pattern]
if isinstance(selection, tuple):
plu... | Check if the uri matches the pattern. | match | python | superduper-io/superduper | superduper/base/build.py | https://github.com/superduper-io/superduper/blob/master/superduper/base/build.py | Apache-2.0 |
def build_datalayer(
cfg=None, compute: ComputeBackend | None = None, **kwargs
) -> Datalayer:
"""
Build a Datalayer object as per ``db = superduper(db)`` from configuration.
:param cfg: Configuration to use. If None, use ``superduper.CFG``.
:param kwargs: keyword arguments to be adopted by the `CF... |
Build a Datalayer object as per ``db = superduper(db)`` from configuration.
:param cfg: Configuration to use. If None, use ``superduper.CFG``.
:param kwargs: keyword arguments to be adopted by the `CFG`
| build_datalayer | python | superduper-io/superduper | superduper/base/build.py | https://github.com/superduper-io/superduper/blob/master/superduper/base/build.py | Apache-2.0 |
def show_configuration(cfg):
"""Show the configuration.
Only show the important configuration values and anonymize the URLs.
:param cfg: The configuration object.
"""
table = PrettyTable()
table.field_names = ["Configuration", "Value"]
key_values = [
('DataBackend', anonymize_url(c... | Show the configuration.
Only show the important configuration values and anonymize the URLs.
:param cfg: The configuration object.
| show_configuration | python | superduper-io/superduper | superduper/base/build.py | https://github.com/superduper-io/superduper/blob/master/superduper/base/build.py | Apache-2.0 |
def from_object(obj):
"""Create a Code object from a callable object.
:param obj: The object to create the Code object from.
"""
code = inspect.getsource(obj)
mini_module = template.format(
definition=code,
)
logging.info(f'Created code object:\n{mini... | Create a Code object from a callable object.
:param obj: The object to create the Code object from.
| from_object | python | superduper-io/superduper | superduper/base/code.py | https://github.com/superduper-io/superduper/blob/master/superduper/base/code.py | Apache-2.0 |
def __call__(self, **kwargs):
"""Update the configuration with the given parameters."""
parameters = dc.asdict(self)
for k, v in kwargs.items():
if "__" in k:
parts = k.split("__")
parent = parts[0]
child = "__".join(parts[1:])
... | Update the configuration with the given parameters. | __call__ | python | superduper-io/superduper | superduper/base/config.py | https://github.com/superduper-io/superduper/blob/master/superduper/base/config.py | Apache-2.0 |
def comparables(self):
"""A dict of `self` excluding some defined attributes."""
_dict = dc.asdict(self)
if hasattr(self, 'cluster'):
_dict.update({'cluster': dc.asdict(self.cluster)})
list(map(_dict.pop, ("cluster", "retries", "downloads")))
return _dict | A dict of `self` excluding some defined attributes. | comparables | python | superduper-io/superduper | superduper/base/config.py | https://github.com/superduper-io/superduper/blob/master/superduper/base/config.py | Apache-2.0 |
def match(self, cfg: t.Dict):
"""Match the target cfg dict with `self` comparables dict.
:param cfg: The target configuration dictionary.
"""
self_cfg = self.comparables
self_hash = hash(json.dumps(self_cfg, sort_keys=True))
cfg_hash = hash(json.dumps(cfg, sort_keys=True... | Match the target cfg dict with `self` comparables dict.
:param cfg: The target configuration dictionary.
| match | python | superduper-io/superduper | superduper/base/config.py | https://github.com/superduper-io/superduper/blob/master/superduper/base/config.py | Apache-2.0 |
def to_yaml(self):
"""Return the configuration as a YAML string."""
import yaml
def enum_representer(dumper, data):
return dumper.represent_scalar("tag:yaml.org,2002:str", str(data.value))
yaml.SafeDumper.add_representer(BytesEncoding, enum_representer)
yaml.SafeDum... | Return the configuration as a YAML string. | to_yaml | python | superduper-io/superduper | superduper/base/config.py | https://github.com/superduper-io/superduper/blob/master/superduper/base/config.py | Apache-2.0 |
def _diff(r1, r2):
"""Return the difference between two dictionaries.
>>> _diff({'a': 1, 'b': 2}, {'a': 2, 'b': 2})
{'a': (1, 2)}
>>> _diff({'a': {'c': 3}, 'b': 2}, {'a': 2, 'b': 2})
{'a': ({'c': 3}, 2)}
"""
d = _diff_impl(r1, r2)
out = {}
for path, left, right in d:
out["."... | Return the difference between two dictionaries.
>>> _diff({'a': 1, 'b': 2}, {'a': 2, 'b': 2})
{'a': (1, 2)}
>>> _diff({'a': {'c': 3}, 'b': 2}, {'a': 2, 'b': 2})
{'a': ({'c': 3}, 2)}
| _diff | python | superduper-io/superduper | superduper/base/config.py | https://github.com/superduper-io/superduper/blob/master/superduper/base/config.py | Apache-2.0 |
def combine_configs(dicts: t.Sequence[Dict]) -> Dict:
"""Combine a sequence of dictionaries into a single dictionary.
:param dicts: The dictionaries to combine.
"""
result: Dict = {}
for d in dicts:
_combine_one(result, d)
return result | Combine a sequence of dictionaries into a single dictionary.
:param dicts: The dictionaries to combine.
| combine_configs | python | superduper-io/superduper | superduper/base/config_dicts.py | https://github.com/superduper-io/superduper/blob/master/superduper/base/config_dicts.py | Apache-2.0 |
def environ_to_config_dict(
prefix: str,
parent: StrDict,
environ: t.Optional[StrDict] = None,
err: t.Optional[t.TextIO] = sys.stderr,
fail: bool = False,
):
"""Convert environment variables to a configuration dictionary.
:param prefix: The prefix to use for environment variables.
:para... | Convert environment variables to a configuration dictionary.
:param prefix: The prefix to use for environment variables.
:param parent: The parent dictionary to use as a basis.
:param environ: The environment variables to read from.
:param err: The file to write errors to.
:param fail: Whether to r... | environ_to_config_dict | python | superduper-io/superduper | superduper/base/config_dicts.py | https://github.com/superduper-io/superduper/blob/master/superduper/base/config_dicts.py | Apache-2.0 |
def load_secrets(secrets_dir: str | None = None):
"""Load secrets directory into env vars.
:param secrets_dir: The directory containing the secrets.
"""
if secrets_dir is None:
from superduper import CFG
secrets_dir = CFG.secrets_volume
if not os.path.isdir(secrets_dir):
w... | Load secrets directory into env vars.
:param secrets_dir: The directory containing the secrets.
| load_secrets | python | superduper-io/superduper | superduper/base/config_settings.py | https://github.com/superduper-io/superduper/blob/master/superduper/base/config_settings.py | Apache-2.0 |
def config(self) -> t.Any:
"""Read a configuration using defaults as basis."""
parent = self.cls().dict()
env = dict(os.environ if self.environ is None else self.environ)
prefix = PREFIX
if self.base:
prefix = PREFIX + self.base.upper() + '_'
env = config_dic... | Read a configuration using defaults as basis. | config | python | superduper-io/superduper | superduper/base/config_settings.py | https://github.com/superduper-io/superduper/blob/master/superduper/base/config_settings.py | Apache-2.0 |
def __init__(
self,
databackend: BaseDataBackend,
artifact_store: ArtifactStore,
cluster: Cluster | None,
metadata: BaseDataBackend | None,
):
"""
Initialize Datalayer.
:param databackend: Object containing connection to Databackend.
:param me... |
Initialize Datalayer.
:param databackend: Object containing connection to Databackend.
:param metadata: Object containing connection to Metadatastore.
:param artifact_store: Object containing connection to Artifactstore.
:param compute: Object containing connection to ComputeBa... | __init__ | python | superduper-io/superduper | superduper/base/datalayer.py | https://github.com/superduper-io/superduper/blob/master/superduper/base/datalayer.py | Apache-2.0 |
def insert(self, items: t.List[Base]):
"""
Insert data into a table.
:param items: The instances (`superduper.base.Base`) to insert.
"""
table = self.pre_insert(items)
data = [x.dict() for x in items]
for r in data:
del r['_path']
return self[... |
Insert data into a table.
:param items: The instances (`superduper.base.Base`) to insert.
| insert | python | superduper-io/superduper | superduper/base/datalayer.py | https://github.com/superduper-io/superduper/blob/master/superduper/base/datalayer.py | Apache-2.0 |
def replace(self, condition: t.Dict, item: Base):
"""
Replace data in a table.
:param condition: The condition to match.
:param item: The instances (`superduper.base.Base`) to insert.
"""
table = self.pre_insert([item])
r = item.dict()
del r['_path']
... |
Replace data in a table.
:param condition: The condition to match.
:param item: The instances (`superduper.base.Base`) to insert.
| replace | python | superduper-io/superduper | superduper/base/datalayer.py | https://github.com/superduper-io/superduper/blob/master/superduper/base/datalayer.py | Apache-2.0 |
def drop(self, force: bool = False, data: bool = False):
"""
Drop all data, artifacts, and metadata.
:param force: Force drop.
:param data: Drop data.
"""
if not force and not click.confirm(
"!!!WARNING USE WITH CAUTION AS YOU WILL"
"LOSE ALL DATA... |
Drop all data, artifacts, and metadata.
:param force: Force drop.
:param data: Drop data.
| drop | python | superduper-io/superduper | superduper/base/datalayer.py | https://github.com/superduper-io/superduper/blob/master/superduper/base/datalayer.py | Apache-2.0 |
def wait(
self,
component: str,
identifier: str,
uuid: str | None = None,
heartbeat: float = 1.0,
timeout: int = 30,
) -> None:
"""
Wait for a component to be ready.
:param component: Component to wait for.
:param identifier: Identifie... |
Wait for a component to be ready.
:param component: Component to wait for.
:param identifier: Identifier of the component.
:param uuid: UUID of the component (optional).
:param heartbeat: Time between status checks in seconds
:param timeout: Maximum wait time in seconds... | wait | python | superduper-io/superduper | superduper/base/datalayer.py | https://github.com/superduper-io/superduper/blob/master/superduper/base/datalayer.py | Apache-2.0 |
def show(
self,
component: t.Optional[str] = None,
identifier: t.Optional[str] = None,
version: t.Optional[int] = None,
uuid: t.Optional[str] = None,
):
"""
Show available functionality which has been added using ``self.add``.
If the version is specif... |
Show available functionality which has been added using ``self.add``.
If the version is specified, then print full metadata.
:param component: Component to show ['Model', 'Listener', etc.]
:param identifier: Identifying string to component.
:param version: (Optional) Numerical... | show | python | superduper-io/superduper | superduper/base/datalayer.py | https://github.com/superduper-io/superduper/blob/master/superduper/base/datalayer.py | Apache-2.0 |
def pre_insert(
self,
items: t.List[Base],
):
"""Pre-insert hook for data insertion.
:param items: The items to insert.
"""
table = items[0].__class__.__name__
try:
table = self.load('Table', table)
return table
except exceptio... | Pre-insert hook for data insertion.
:param items: The items to insert.
| pre_insert | python | superduper-io/superduper | superduper/base/datalayer.py | https://github.com/superduper-io/superduper/blob/master/superduper/base/datalayer.py | Apache-2.0 |
def on_event(self, table: str, ids: t.List[str], event_type: 'str'):
"""
Trigger computation jobs after data insertion.
:param table: The table to trigger computation jobs on.
:param ids: IDs that further reduce the scope of computations.
:param event_type: The type of event to ... |
Trigger computation jobs after data insertion.
:param table: The table to trigger computation jobs on.
:param ids: IDs that further reduce the scope of computations.
:param event_type: The type of event to trigger.
| on_event | python | superduper-io/superduper | superduper/base/datalayer.py | https://github.com/superduper-io/superduper/blob/master/superduper/base/datalayer.py | Apache-2.0 |
def create(self, object: t.Type[Base]):
"""Create a new type of component/ leaf.
:param object: The object to create.
"""
try:
self.metadata.create(object)
except exceptions.AlreadyExists:
logging.debug(f'{object} already exists, skipping...') | Create a new type of component/ leaf.
:param object: The object to create.
| create | python | superduper-io/superduper | superduper/base/datalayer.py | https://github.com/superduper-io/superduper/blob/master/superduper/base/datalayer.py | Apache-2.0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.