orcalib.client#
PagedResponse
#
Bases: TypedDict
The response from a paged query
Attributes:
-
page_index
(int
) –The index of the current page
-
page_size
(int
) –The size of the current page
-
total_size
(int
) –The total number of items
-
num_pages
(int
) –The total number of pages
-
has_next
(bool
) –If there is a next page
-
items
(list[Any]
) –The items on the current page
ColumnSpec
dataclass
#
OrcaClient
#
The OrcaClient class is used to make requests to the Orca web service
set_credentials
staticmethod
#
check_version_compatibility
staticmethod
#
Check if the OrcaLib version is compatible with the OrcaDB instance version and log a warning if not.
Returns:
-
bool | None
–True if the versions match, False if they do not, None if the version check is skipped
get_server_version
staticmethod
#
create_database
staticmethod
#
drop_database
staticmethod
#
database_exists
staticmethod
#
restore_backup
staticmethod
#
create_backup
staticmethod
#
Create a backup of the database
Parameters:
-
db_name
(str
) –The name of the database
Returns:
-
Response
–Create backup response
download_backup
staticmethod
#
upload_backup
staticmethod
#
delete_backup
staticmethod
#
list_databases
staticmethod
#
list_tables
staticmethod
#
table_info
staticmethod
#
Get the information about a table
Parameters:
Returns:
-
list[ColumnSpec]
–List with schema information for each column in the table
healthcheck
staticmethod
#
create_table
staticmethod
#
Create a new table in the database
Parameters:
-
db_name
(str
) –The name of the database
-
table_name
(str
) –The name of the table
-
table_schema
(list[ColumnSpec]
) –The schema of the table
-
if_table_exists
(TableCreateMode
, default:ERROR_IF_TABLE_EXISTS
) –What to do if the table already exists
insert
staticmethod
#
update
staticmethod
#
upsert
staticmethod
#
delete
staticmethod
#
count
staticmethod
#
add_column
staticmethod
#
Add a new column to the table
Parameters:
drop_column
staticmethod
#
drop_table
staticmethod
#
drop_index
staticmethod
#
select
staticmethod
#
Perform a select query on the table
Parameters:
-
table
(TableHandle
) –The TableHandle for the table we’re querying
-
columns
(list[ColumnName] | None
, default:None
) –The columns to select. If None, all columns are selected
-
limit
(int | None
, default:None
) –The maximum number of rows to return
-
filter
(ApiFilter | None
, default:None
) –The filter to apply to the query
-
order_by_columns
(OrderByColumns | None
, default:None
) –The columns to order by. If None, no order is applied.
-
default_order
(Order
, default:ASCENDING
) –The default order to use if no order is specified. Defaults to ascending.
Returns:
-
TableSelectResponse
–The response from the select query
create_index
staticmethod
#
Create a new index
Parameters:
-
db_name
(str
) –The name of the database
-
index_name
(str
) –The name of the index
-
table_name
(str
) –The name of the table
-
column
(str
) –The name of the column to index
-
index_type
(str
) –The type of the index
-
ann_index_type
(str
, default:'hnswlib'
) –The type of the approximate nearest neighbors index
-
embedding_model
(EmbeddingModel
, default:SENTENCE_TRANSFORMER
) –The name of the embedding model
Returns:
-
IndexHandle
–handle for the created index
get_index_status
staticmethod
#
get_index
staticmethod
#
scan_index
staticmethod
#
Scan an index
Parameters:
-
db
(OrcaDatabase
) –The OrcaDatabase object
-
index_name
(str
) –The name of the index
-
query
(Any
) –The query to apply
-
limit
(int
) –The maximum number of rows to return
-
columns
(list[str] | None
, default:None
) –The columns to return (optional)
-
filter
(str | None
, default:None
) –The filter to apply (optional)
-
drop_exact_match
(bool
, default:False
) –Drops the exact match from the results, if it’s found
-
exact_match_threshold
(float
, default:EXACT_MATCH_THRESHOLD
) –The minimum distance threshold for the exact match
Returns:
-
Any
–The response from the scan index query
vector_scan_index
staticmethod
#
Performs a vector scan index query
Parameters:
-
table
(TableHandle
) –The TableHandle for the table we’re querying
-
index_name
(str
) –The name of the index
-
query
(Any
) –The query to apply
-
limit
(int
) –The maximum number of rows to return
-
columns
(list[str] | None
, default:None
) –The columns to return (optional)
-
filter
(str | None
, default:None
) –The filter to apply (optional)
-
drop_exact_match
(bool
, default:False
) –The flag to drop exact matches
-
exact_match_threshold
(float
, default:EXACT_MATCH_THRESHOLD
) –The threshold for exact matches
-
curate_run_ids
(list[int] | None
, default:None
) –The curate run ids to apply (optional)
-
curate_layer_name
(str | None
, default:None
) –The curate layer name to apply (optional)
Returns:
-
BatchedScanResult
–The response from the scan index query
full_vector_memory_join
staticmethod
#
Perform a full vector memory join
Parameters:
-
db_name
(str
) –The name of the database
-
index_name
(str
) –The name of the index
-
memory_index_name
(str
) –The name of the memory index
-
num_memories
(int
) –The number of memory indexes
-
query_columns
(list[str] | str
) –The columns to query (or a single column)
-
page_size
(int
, default:100
) –The size of the page to return
-
page_index
(int
, default:0
) –The index of the page to return
Returns:
-
PagedResponse
–The response from the full vector memory join query
get_index_values
staticmethod
#
get_index_values_paginated
staticmethod
#
Get the values of an index paginated
Parameters:
-
db_name
(str
) –The name of the database
-
index_name
(str
) –The name of the index
-
page_index
(int
, default:0
) –The index of the page to return
-
page_size
(int
, default:100
) –The size of the page to return
Returns:
-
PagedResponse
–A paged response with
dict[int, list[float]]
get_index_table
staticmethod
#
run_sql
staticmethod
#
encode_text
staticmethod
#
index_embed_text
staticmethod
#
Encode text values using the embedding model of a specific index.
Parameters:
-
db_name
(str
) –The name of the database that the index belongs to
-
index_name
(str
) –The name of the index whose embedding will be used to encode the text
-
strings
(list[str]
) –The list of strings to encode
-
result_format
(Literal['list', 'pt']
, default:'pt'
) –If
"list"
, return the results as a list of lists. If"pt"
, return the results as a list of PyTorch tensors.
Returns:
init_forward_pass
staticmethod
#
Generate run ids for a batch of forward passes
Parameters:
-
db_name
(str
) –The name of the database
-
model_id
(str
) –The id of the model
-
batch_size
(int
) –The batch size
-
model_version
(str | None
, default:None
) –The version of the model (optional)
-
seq_id
(UUID | None
, default:None
) –The sequence id for the forward pass (optional)
-
tags
(set[str] | None
, default:None
) –The tags for the forward pass (optional)
-
metadata
(OrcaMetadataDict | None
, default:None
) –The metadata for the forward pass (optional)
Returns:
record_memory_weights
staticmethod
#
Record the memory weights for a batch of forward passes
Parameters: