Skip to content

Commit

Permalink
Merge pull request #96 from iQuxLE/venomx
Browse files Browse the repository at this point in the history
#81 Venomx integration
  • Loading branch information
caufieldjh authored Nov 4, 2024
2 parents c14b3c1 + f02aff0 commit 767d43f
Show file tree
Hide file tree
Showing 12 changed files with 782 additions and 259 deletions.
30 changes: 25 additions & 5 deletions src/curategpt/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@
"main",
]

from venomx.model.venomx import Dataset, Index, Model


def dump(
obj: Union[str, AnnotatedObject, Dict],
Expand Down Expand Up @@ -2086,8 +2088,9 @@ def list_collections(database_type, path, peek: bool, minimal: bool, derived: bo
cm = db.collection_metadata(cn, include_derived=derived)
if database_type == "chromadb":
# TODO: make get_or_create abstract and implement in DBAdapter?
c = db.client.get_or_create_collection(cn)
print(f"## Collection: {cn} N={c.count()} meta={c.metadata} // {cm}")
c = db.client.get_collection(cn)
print(f"## Collection: {cn} N={c.count()} meta={c.metadata} \n"
f"Metadata: {cm}\n")
if peek:
r = c.peek()
for id_ in r["ids"]:
Expand Down Expand Up @@ -2322,7 +2325,6 @@ def index_ontology_command(
curategpt ontology index -p stagedb/duck.db -c ont-hp sqlite:obo:hp -D duckdb
"""

s = time.time()
oak_adapter = get_adapter(ont)
view = OntologyWrapper(oak_adapter=oak_adapter)
Expand All @@ -2343,8 +2345,26 @@ def _text_lookup(obj: Dict):
if not append:
db.remove_collection(collection, exists_ok=True)
click.echo(f"Indexing {len(list(view.objects()))} objects")
db.insert(view.objects(), collection=collection, model=model)
db.update_collection_metadata(collection, object_type="OntologyClass")

venomx = Index(
id=collection,
dataset=Dataset(
name=ont
),
embedding_model=Model(
name=model if model else None
)
)

db.insert(
view.objects(),
collection=collection,
model=model,
venomx=venomx,
object_type="OntologyClass"

)

e = time.time()
click.echo(f"Indexed {len(list(view.objects()))} in {e - s} seconds")

Expand Down
6 changes: 3 additions & 3 deletions src/curategpt/store/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,15 @@
from .chromadb_adapter import ChromaDBAdapter
from .db_adapter import DBAdapter
from .duckdb_adapter import DuckDBAdapter
from .metadata import CollectionMetadata
from .metadata import Metadata
from .schema_proxy import SchemaProxy

__all__ = [
"DBAdapter",
"ChromaDBAdapter",
"DuckDBAdapter",
"SchemaProxy",
"CollectionMetadata",
"Metadata",
"get_store",
]

Expand All @@ -40,7 +40,7 @@ def get_all_subclasses(cls):
]


def get_store(name: str, *args, **kwargs) -> DBAdapter: # duckdb_vss or chromadb
def get_store(name: str, *args, **kwargs) -> DBAdapter: # duckdb or chromadb
from .in_memory_adapter import InMemoryAdapter # noqa F401

# noqa I005
Expand Down
Loading

0 comments on commit 767d43f

Please sign in to comment.