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

chore: install extras from ragbits index package #199

Merged
merged 5 commits into from
Nov 20, 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
37 changes: 37 additions & 0 deletions packages/ragbits/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,43 @@ dependencies = [
"ragbits-core==0.3.0"
]

[project.optional-dependencies]
chroma = [
"chromadb~=0.4.24",
]
huggingface = [
"datasets~=3.0.1",
]
gcs = [
"gcloud-aio-storage~=9.3.0"
]
lab = [
"gradio~=4.44.0",
]
litellm = [
"litellm~=1.46.0",
]
local = [
"torch~=2.2.1",
"transformers~=4.44.2",
"numpy~=1.26.0"
]
openai = [
"openai~=1.51.0",
]
otel = [
"opentelemetry-api~=1.27.0",
]
promptfoo = [
"PyYAML~=6.0.2",
]
qdrant = [
"qdrant-client~=1.12.1",
]
relari = [
"continuous-eval~=0.3.12",
]

[build-system]
requires = ["hatchling", "hatch-fancy-pypi-readme"]
build-backend = "hatchling.build"
Expand Down
29 changes: 29 additions & 0 deletions scripts/update_ragbits_package.py
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,33 @@ def _create_changelog_release(pkg_name: str, new_version: str) -> None:
changelog_path.write_text(changelog_content)


def _update_ragbits_extras(packages: list[str]) -> None:
subpackages = [pkg for pkg in packages if pkg != "ragbits"]

extras = {}
for pkg in subpackages:
pkg_pyproject_path = PACKAGES_DIR / pkg / "pyproject.toml"
pkg_pyproject = tomlkit.parse(pkg_pyproject_path.read_text())

if "optional-dependencies" in pkg_pyproject["project"]:
for extra, deps in pkg_pyproject["project"]["optional-dependencies"].items():
if extra in extras and extras[extra] != deps:
raise Exception(
f"Duplicate extras: '{extra}' exists in multiple packages with different dependencies."
)
extras[extra] = deps

extras = dict(sorted(extras.items()))

ragbits_pyproject_path = PACKAGES_DIR / "ragbits" / "pyproject.toml"
ragbits_pyproject_data = tomlkit.parse(ragbits_pyproject_path.read_text())

for extra, deps in extras.items():
ragbits_pyproject_data["project"]["optional-dependencies"][extra] = deps

ragbits_pyproject_path.write_text(tomlkit.dumps(ragbits_pyproject_data))


def run(pkg_name: str | None = typer.Argument(None), update_type: str | None = typer.Argument(None)) -> None:
"""
Main entry point for the package version updater. Updates package versions based on user input.
Expand Down Expand Up @@ -214,6 +241,7 @@ def run(pkg_name: str | None = typer.Argument(None), update_type: str | None = t

if pkg_name == "ragbits":
_update_pkg_version(pkg_name, update_type=casted_update_type)
_update_ragbits_extras(packages)

elif pkg_name == "ragbits-core":
if user_prompt_required:
Expand All @@ -223,6 +251,7 @@ def run(pkg_name: str | None = typer.Argument(None), update_type: str | None = t
is_continue = True

if is_continue:
_update_ragbits_extras(packages)
version, new_version = _update_pkg_version(pkg_name, update_type=casted_update_type)
casted_update_type = _check_update_type(version, new_version)

Expand Down
Loading