From 3cb04480fb927dfb976d17b6e84a0476e138ae6d Mon Sep 17 00:00:00 2001 From: Ishaan Jaff Date: Sat, 5 Oct 2024 16:58:10 +0530 Subject: [PATCH] (code clean up) use a folder for gcs bucket logging + add readme in folder (#6080) * refactor gcs bucket * add readme --- litellm/integrations/gcs_bucket/Readme.md | 12 ++++++++++++ litellm/integrations/{ => gcs_bucket}/gcs_bucket.py | 2 +- .../integrations/{ => gcs_bucket}/gcs_bucket_base.py | 0 litellm/litellm_core_utils/litellm_logging.py | 2 +- litellm/proxy/common_utils/load_config_utils.py | 4 ++-- litellm/secret_managers/google_secret_manager.py | 2 +- tests/local_testing/test_gcs_bucket.py | 5 ++++- 7 files changed, 21 insertions(+), 6 deletions(-) create mode 100644 litellm/integrations/gcs_bucket/Readme.md rename litellm/integrations/{ => gcs_bucket}/gcs_bucket.py (99%) rename litellm/integrations/{ => gcs_bucket}/gcs_bucket_base.py (100%) diff --git a/litellm/integrations/gcs_bucket/Readme.md b/litellm/integrations/gcs_bucket/Readme.md new file mode 100644 index 000000000..2ab0b2335 --- /dev/null +++ b/litellm/integrations/gcs_bucket/Readme.md @@ -0,0 +1,12 @@ +# GCS (Google Cloud Storage) Bucket Logging on LiteLLM Gateway + +This folder contains the GCS Bucket Logging integration for LiteLLM Gateway. + +## Folder Structure + +- `gcs_bucket.py`: This is the main file that handles failure/success logging to GCS Bucket +- `gcs_bucket_base.py`: This file contains the GCSBucketBase class which handles Authentication for GCS Buckets + +## Further Reading +- [Doc setting up GCS Bucket Logging on LiteLLM Proxy (Gateway)](https://docs.litellm.ai/docs/proxy/bucket) +- [Doc on Key / Team Based logging with GCS](https://docs.litellm.ai/docs/proxy/team_logging) \ No newline at end of file diff --git a/litellm/integrations/gcs_bucket.py b/litellm/integrations/gcs_bucket/gcs_bucket.py similarity index 99% rename from litellm/integrations/gcs_bucket.py rename to litellm/integrations/gcs_bucket/gcs_bucket.py index d58350621..744361453 100644 --- a/litellm/integrations/gcs_bucket.py +++ b/litellm/integrations/gcs_bucket/gcs_bucket.py @@ -11,7 +11,7 @@ from pydantic import BaseModel, Field import litellm from litellm._logging import verbose_logger from litellm.integrations.custom_logger import CustomLogger -from litellm.integrations.gcs_bucket_base import GCSBucketBase +from litellm.integrations.gcs_bucket.gcs_bucket_base import GCSBucketBase from litellm.litellm_core_utils.logging_utils import ( convert_litellm_response_object_to_dict, ) diff --git a/litellm/integrations/gcs_bucket_base.py b/litellm/integrations/gcs_bucket/gcs_bucket_base.py similarity index 100% rename from litellm/integrations/gcs_bucket_base.py rename to litellm/integrations/gcs_bucket/gcs_bucket_base.py diff --git a/litellm/litellm_core_utils/litellm_logging.py b/litellm/litellm_core_utils/litellm_logging.py index e040bfb40..3673e6b67 100644 --- a/litellm/litellm_core_utils/litellm_logging.py +++ b/litellm/litellm_core_utils/litellm_logging.py @@ -65,7 +65,7 @@ from ..integrations.clickhouse import ClickhouseLogger from ..integrations.datadog.datadog import DataDogLogger from ..integrations.dynamodb import DyanmoDBLogger from ..integrations.galileo import GalileoObserve -from ..integrations.gcs_bucket import GCSBucketLogger +from ..integrations.gcs_bucket.gcs_bucket import GCSBucketLogger from ..integrations.greenscale import GreenscaleLogger from ..integrations.helicone import HeliconeLogger from ..integrations.lago import LagoLogger diff --git a/litellm/proxy/common_utils/load_config_utils.py b/litellm/proxy/common_utils/load_config_utils.py index a3b809859..f262837d9 100644 --- a/litellm/proxy/common_utils/load_config_utils.py +++ b/litellm/proxy/common_utils/load_config_utils.py @@ -53,9 +53,9 @@ def get_file_contents_from_s3(bucket_name, object_key): async def get_config_file_contents_from_gcs(bucket_name, object_key): try: - from litellm.integrations.gcs_bucket_base import GCSBucketBase + from litellm.integrations.gcs_bucket.gcs_bucket import GCSBucketLogger - gcs_bucket = GCSBucketBase( + gcs_bucket = GCSBucketLogger( bucket_name=bucket_name, ) file_contents = await gcs_bucket.download_gcs_object(object_key) diff --git a/litellm/secret_managers/google_secret_manager.py b/litellm/secret_managers/google_secret_manager.py index 0d0c31005..7d661555a 100644 --- a/litellm/secret_managers/google_secret_manager.py +++ b/litellm/secret_managers/google_secret_manager.py @@ -5,7 +5,7 @@ from typing import Optional import litellm from litellm._logging import verbose_logger from litellm.caching import InMemoryCache -from litellm.integrations.gcs_bucket_base import GCSBucketBase +from litellm.integrations.gcs_bucket.gcs_bucket_base import GCSBucketBase from litellm.llms.custom_httpx.http_handler import _get_httpx_client from litellm.proxy._types import CommonProxyErrors, KeyManagementSystem diff --git a/tests/local_testing/test_gcs_bucket.py b/tests/local_testing/test_gcs_bucket.py index 711f45459..67e125593 100644 --- a/tests/local_testing/test_gcs_bucket.py +++ b/tests/local_testing/test_gcs_bucket.py @@ -16,7 +16,10 @@ import pytest import litellm from litellm import completion from litellm._logging import verbose_logger -from litellm.integrations.gcs_bucket import GCSBucketLogger, StandardLoggingPayload +from litellm.integrations.gcs_bucket.gcs_bucket import ( + GCSBucketLogger, + StandardLoggingPayload, +) from litellm.types.utils import StandardCallbackDynamicParams verbose_logger.setLevel(logging.DEBUG)