From 9d6c34aba1abb747e2e87f75d2005f448c17fda7 Mon Sep 17 00:00:00 2001 From: efrotenberg Date: Sun, 4 Feb 2024 10:52:57 +0200 Subject: [PATCH] Version 0.1.1 --- README.md | 27 ++++++++++----------------- icebergdiag/cli.py | 6 +++--- icebergdiag/diagnostics/manager.py | 5 ++++- icebergdiag/exceptions.py | 18 ++++++++++++++---- pyproject.toml | 4 +++- 5 files changed, 34 insertions(+), 26 deletions(-) diff --git a/README.md b/README.md index ff5b609..fabe5c5 100644 --- a/README.md +++ b/README.md @@ -9,14 +9,6 @@ It presents a side-by-side comparison of current metrics against potential impro ## Installation `iceberg-diag` can be installed using either Brew or PIP, as detailed below: -### Using Brew -Execute the following commands to install `iceberg-diag` via Brew: - - ```bash - brew tap upsolver/iceberg-diag - brew install iceberg-diag - ``` - ### Using PIP #### Prerequisites @@ -24,15 +16,6 @@ Execute the following commands to install `iceberg-diag` via Brew: ```bash python3 --version ``` -* **Rust**: check if installed: - ```bash - cargo --version - ``` - If Rust is not installed, install it using: - ```bash - curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh - ``` - To install `iceberg-diag` using PIP, ensure you have the latest version of `pip`: ```bash @@ -43,6 +26,16 @@ Then, install the package with `pip` pip install iceberg-diag ``` + +### Using Brew +Execute the following commands to install `iceberg-diag` via Brew: + + ```bash + brew tap upsolver/iceberg-diag + brew install iceberg-diag + ``` + + ## Usage Instructions ```bash diff --git a/icebergdiag/cli.py b/icebergdiag/cli.py index 93f97ae..8907230 100644 --- a/icebergdiag/cli.py +++ b/icebergdiag/cli.py @@ -53,17 +53,17 @@ def display_list(lst: List[str], heading: str) -> None: def list_tables(diagnostics_manager: IcebergDiagnosticsManager, database: str) -> None: - tables = diagnostics_manager.list_tables(database) + tables = run_with_progress(diagnostics_manager.list_tables, "Fetching Iceberg tables...", database) display_list(tables, "Tables") error_message = ( - "Use --table-name to get diagnostics on the iceberg table, " + "Use --table-name to get diagnostics on the Iceberg table, " "you can use a glob pattern to receive diagnostics on multiple tables in one command" ) stderr_print(error_message) def list_databases(diagnostics_manager: IcebergDiagnosticsManager) -> None: - databases = diagnostics_manager.list_databases() + databases = run_with_progress(diagnostics_manager.list_databases, "Fetching databases...") display_list(databases, "Databases") stderr_print("Use --database to get the list of tables") diff --git a/icebergdiag/diagnostics/manager.py b/icebergdiag/diagnostics/manager.py index 1bfabde..ae4944f 100644 --- a/icebergdiag/diagnostics/manager.py +++ b/icebergdiag/diagnostics/manager.py @@ -14,7 +14,8 @@ from pyiceberg.utils.concurrent import ExecutorFactory from icebergdiag.exceptions import ProfileNotFoundError, EndpointConnectionError, \ - IcebergDiagnosticsError, DatabaseNotFound, TableMetricsCalculationError, SSOAuthenticationError + IcebergDiagnosticsError, DatabaseNotFound, TableMetricsCalculationError, SSOAuthenticationError, \ + SessionInitializationError from icebergdiag.metrics.table import Table from icebergdiag.metrics.table_metrics import TableMetrics, MetricsCalculator @@ -40,6 +41,8 @@ def _initialize_catalog(self): raise EndpointConnectionError(self.region) except boto3_exceptions.SSOError as e: raise SSOAuthenticationError(self.profile, e) from e + except boto3_exceptions.BotoCoreError as e: + raise SessionInitializationError(self.profile, e) except Exception as e: raise IcebergDiagnosticsError(f"An unexpected error occurred: {e}") diff --git a/icebergdiag/exceptions.py b/icebergdiag/exceptions.py index 08fd7ec..a574257 100644 --- a/icebergdiag/exceptions.py +++ b/icebergdiag/exceptions.py @@ -15,8 +15,9 @@ def __init__(self, message: str = "An error occurred in Iceberg Diagnostics Mana class ProfileNotFoundError(IcebergDiagnosticsError): """Exception raised when the specified AWS profile does not exist.""" - def __init__(self, profile: str): - super().__init__(f"The AWS profile '{profile}' does not exist.") + def __init__(self, profile: Optional[str]): + profile_msg = f"The AWS profile '{profile}' does not exist." if profile is not None else "No AWS profile found." + super().__init__(profile_msg) class SSOAuthenticationError(IcebergDiagnosticsError): @@ -38,8 +39,17 @@ def __init__(self): class EndpointConnectionError(IcebergDiagnosticsError): """Exception raised when connection to AWS endpoint fails.""" - def __init__(self, region: str): - super().__init__(f"Could not connect to AWS in the region '{region}'.") + def __init__(self, region: Optional[str]): + region_message = f"region '{region}'" if region is not None else "default region" + super().__init__(f"Could not connect to AWS in the {region_message}.") + + +class SessionInitializationError(IcebergDiagnosticsError): + """Exception raised when an AWS session fails to initialize.""" + def __init__(self, profile: Optional[str], original_error: Exception): + profile_part = f"with profile '{profile}'" if profile else "with default profile" + message = f"Failed to initialize AWS session {profile_part}: {original_error}" + super().__init__(message) class UnexpectedError(IcebergDiagnosticsError): diff --git a/pyproject.toml b/pyproject.toml index 24aa108..de6d2f8 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,10 +1,12 @@ [tool.poetry] name = "iceberg-diag" -version = "0.1.0" +version = "0.1.1" description = "Upsolver Iceberg Auditor CLI" authors = ["Upsolver "] license = "MIT" readme = "README.md" +homepage = "https://github.com/Upsolver/iceberg-diag" + packages = [ {include = "icebergdiag"},