Skip to content

Commit

Permalink
Feature/dev minor rebased (#1485)
Browse files Browse the repository at this point in the history
* Update pyproject.toml (#1471)

* add alembic migrations to pypi release (#1472)

* add alembic migrations to pypi release

* modify path

* run on main (#1474)

* minor kg-search bug (#1476)

* minor kg-search bug

* fix

* Update pyproject.toml

* Move to psycopg binary (#1477)

---------

Co-authored-by: Shreyas Pimpalgaonkar <shreyas.gp.7@gmail.com>
Co-authored-by: Nolan Tremelling <34580718+NolanTrem@users.noreply.github.com>
  • Loading branch information
3 people authored Oct 25, 2024
1 parent d094467 commit 5eb9ec4
Show file tree
Hide file tree
Showing 11 changed files with 111 additions and 17 deletions.
1 change: 1 addition & 0 deletions .github/workflows/r2r-full-integration-deep-dive-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ on:
branches:
- dev
- dev-minor
- main
workflow_dispatch:

jobs:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ on:
branches:
- dev
- dev-minor
- main
pull_request:
branches:
- dev
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ on:
branches:
- dev
- dev-minor
- main
workflow_dispatch:

jobs:
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/r2r-full-py-integration-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ on:
branches:
- dev
- dev-minor
- main
pull_request:
branches:
- dev
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ on:
branches:
- dev
- dev-minor
- main
pull_request:
branches:
- dev
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ on:
branches:
- dev
- dev-minor
- main
workflow_dispatch:

jobs:
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/r2r-light-py-integration-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ on:
branches:
- dev
- dev-minor
- main
pull_request:
branches:
- dev
Expand Down
11 changes: 10 additions & 1 deletion py/cli/utils/database_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,17 @@ def create_schema_config(
"""Create an Alembic config for a specific schema."""
config = alembic.config.Config()

# Calculate the path to the migrations folder
current_file = Path(__file__)
migrations_path = current_file.parent.parent.parent / "migrations"

if not migrations_path.exists():
raise FileNotFoundError(
f"Migrations folder not found at {migrations_path}"
)

# Set basic options
config.set_main_option("script_location", str(project_root / "migrations"))
config.set_main_option("script_location", str(migrations_path))
config.set_main_option("sqlalchemy.url", db_url)

# Set schema-specific version table
Expand Down
9 changes: 6 additions & 3 deletions py/core/providers/database/kg.py
Original file line number Diff line number Diff line change
Expand Up @@ -459,10 +459,13 @@ async def vector_query(self, query: str, **kwargs: Any) -> Any:
filter_query = "WHERE collection_id = ANY($3)"
filter_ids = collection_ids_dict["$overlap"]

if search_type == "__Community__":
if (
search_type == "__Community__"
or table_name == "collection_entity"
):
logger.info(f"Searching in collection ids: {filter_ids}")

if search_type in ["__Entity__", "__Relationship__"]:
elif search_type in ["__Entity__", "__Relationship__"]:
filter_query = "WHERE document_id = ANY($3)"
# TODO - This seems like a hack, we will need a better way to filter by collection ids for entities and relationships
query = f"""
Expand All @@ -480,7 +483,7 @@ async def vector_query(self, query: str, **kwargs: Any) -> Any:
SELECT {property_names_str} FROM {self._get_table_name(table_name)} {filter_query} ORDER BY {embedding_type} <=> $1 LIMIT $2;
"""

if not filter_query:
if filter_query != "":
results = await self.connection_manager.fetch_query(
QUERY, (str(query_embedding), limit, filter_ids)
)
Expand Down
95 changes: 84 additions & 11 deletions py/poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 4 additions & 2 deletions py/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,19 @@ build-backend = "poetry.core.masonry.api"
[tool.poetry]
name = "r2r"
readme = "README.md"
version = "3.2.32"
version = "3.2.35"

description = "SciPhi R2R"
authors = ["Owen Colegrove <owen@sciphi.ai>"]
license = "MIT"
include = ["r2r.toml", "compose.yaml", "compose.full.yaml", "pyproject.toml"]
include = ["r2r.toml", "compose.yaml", "compose.full.yaml", "pyproject.toml", "migrations/**/*" ]
packages = [
{ include = "r2r" },
{ include = "sdk", from = "." },
{ include = "shared", from = "." },
{ include = "core", from = "." },
{ include = "cli", from = "." },

]

[tool.poetry.dependencies]
Expand All @@ -36,6 +37,7 @@ requests = "^2.31.0"
toml = "^0.10.2"
types-requests = "^2.31.0"
unstructured-client = "^0.25.5"
psycopg-binary = "^3.2.3"

# Shared dependencies (optional)
aiosqlite = { version = "^0.20.0", optional = true }
Expand Down

0 comments on commit 5eb9ec4

Please sign in to comment.