diff --git a/py/core/main/api/v3/users_router.py b/py/core/main/api/v3/users_router.py index 0b24eb89c..5c4dc9d24 100644 --- a/py/core/main/api/v3/users_router.py +++ b/py/core/main/api/v3/users_router.py @@ -1537,9 +1537,6 @@ async def create_user_api_key( 403, ) - print("name =", name) - print("description =", description) - api_key = await self.services.auth.create_user_api_key( id, name=name, description=description ) @@ -1753,28 +1750,31 @@ async def get_user_limits( "x-codeSamples": [ { "lang": "Python", - "source": """ -from r2r import R2RClient + "source": textwrap.dedent( + """ + from r2r import R2RClient -client = R2RClient() -client.login(...) # Or some other auth flow + client = R2RClient() + client.login(...) # Or some other auth flow -metadata_update = { - "some_key": "some_value", - "old_key": "" -} -updated_user = client.users.patch_metadata("550e8400-e29b-41d4-a716-446655440000", metadata_update) -print(updated_user) - """, + metadata_update = { + "some_key": "some_value", + "old_key": "" + } + updated_user = client.users.patch_metadata("550e8400-e29b-41d4-a716-446655440000", metadata_update) + """, + ), }, { "lang": "cURL", - "source": """ -curl -X PATCH "https://api.example.com/v3/users/550e8400-e29b-41d4-a716-446655440000/metadata" \\ - -H "Authorization: Bearer YOUR_API_TOKEN" \\ - -H "Content-Type: application/json" \\ - -d '{"some_key":"some_value","old_key":""}' - """, + "source": textwrap.dedent( + """ + curl -X PATCH "https://api.example.com/v3/users/550e8400-e29b-41d4-a716-446655440000/metadata" \\ + -H "Authorization: Bearer YOUR_API_TOKEN" \\ + -H "Content-Type: application/json" \\ + -d '{"some_key":"some_value","old_key":""}' + """, + ), }, ] }, diff --git a/py/core/telemetry/telemetry_decorator.py b/py/core/telemetry/telemetry_decorator.py index 40f7216da..24630f9b6 100644 --- a/py/core/telemetry/telemetry_decorator.py +++ b/py/core/telemetry/telemetry_decorator.py @@ -4,11 +4,10 @@ import uuid from concurrent.futures import ThreadPoolExecutor from functools import wraps +from importlib import metadata from pathlib import Path from typing import Optional -import toml - from core.telemetry.events import ErrorEvent, FeatureUsageEvent from core.telemetry.posthog import telemetry_client @@ -25,11 +24,7 @@ class ProductTelemetryClient: def version(self) -> str: if self._version is None: try: - pyproject_path = ( - Path(__file__).parent.parent.parent / "pyproject.toml" - ) - pyproject_data = toml.load(pyproject_path) - self._version = pyproject_data["tool"]["poetry"]["version"] + self._version = metadata.version("r2r") except Exception as e: logger.error( f"Error reading version from pyproject.toml: {str(e)}" diff --git a/py/pyproject.toml b/py/pyproject.toml index 43f473d72..7d31c6b2b 100644 --- a/py/pyproject.toml +++ b/py/pyproject.toml @@ -5,7 +5,7 @@ build-backend = "poetry.core.masonry.api" [tool.poetry] name = "r2r" readme = "README.md" -version = "3.3.22" +version = "3.3.23" description = "SciPhi R2R" authors = ["Owen Colegrove "] @@ -16,7 +16,9 @@ include = [ "compose.full.yaml", "compose.full_with_replicas.yaml", "pyproject.toml", - "migrations/**/*" + "migrations/**/*", + "r2r/**/*.yaml", + "r2r/**/*.toml" ] packages = [ { include = "r2r" }, diff --git a/py/r2r/__init__.py b/py/r2r/__init__.py index e8a931905..2206e091e 100644 --- a/py/r2r/__init__.py +++ b/py/r2r/__init__.py @@ -1,7 +1,5 @@ import logging -from pathlib import Path - -import toml +from importlib import metadata from sdk.async_client import R2RAsyncClient from sdk.models import R2RException @@ -9,9 +7,7 @@ logger = logging.getLogger() -pyproject_path = Path(__file__).parent.parent / "pyproject.toml" -pyproject_data = toml.load(pyproject_path) -__version__ = pyproject_data["tool"]["poetry"]["version"] +__version__ = metadata.version("r2r") __all__ = [ "R2RAsyncClient",